mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Use newer GMM API
Related-To: NEO-3832 Change-Id: I9c97a20a6a611118eb14348a8c6960115a20777d Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com> Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
aa7058a2a9
commit
3fc748c0f9
@@ -16,7 +16,8 @@ const char *frontEndDllName = FCL_LIBRARY_NAME;
|
||||
const char *igcDllName = IGC_LIBRARY_NAME;
|
||||
const char *libvaDllName = "libva.so.2";
|
||||
const char *gmmDllName = GMM_UMD_DLL;
|
||||
const char *gmmEntryName = GMM_ENTRY_NAME;
|
||||
const char *gmmInitFuncName = GMM_INIT_NAME;
|
||||
const char *gmmDestroyFuncName = GMM_DESTROY_NAME;
|
||||
|
||||
const char *sysFsPciPath = "/sys/bus/pci/devices/";
|
||||
const char *tbxLibName = "libtbxAccess.so";
|
||||
|
||||
@@ -14,7 +14,8 @@ const char *frontEndDllName = FCL_LIBRARY_NAME;
|
||||
const char *igcDllName = IGC_LIBRARY_NAME;
|
||||
const char *gdiDllName = "gdi32.dll";
|
||||
const char *gmmDllName = GMM_UMD_DLL;
|
||||
const char *gmmEntryName = GMM_ENTRY_NAME;
|
||||
const char *gmmInitFuncName = GMM_INIT_NAME;
|
||||
const char *gmmDestroyFuncName = GMM_DESTROY_NAME;
|
||||
|
||||
// Os specific Metrics Library name
|
||||
#if _WIN64
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
#include "gmm_client_context.h"
|
||||
|
||||
namespace NEO {
|
||||
GmmClientContext::GmmClientContext(GMM_CLIENT clientType, GmmExportEntries &gmmEntries) : GmmClientContextBase(clientType, gmmEntries){};
|
||||
GmmClientContext::GmmClientContext(HardwareInfo *hwInfo, decltype(&InitializeGmm) initFunc, decltype(&GmmDestroy) destroyFunc) : GmmClientContextBase(hwInfo, initFunc, destroyFunc){};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -11,6 +11,6 @@
|
||||
namespace NEO {
|
||||
class GmmClientContext : public GmmClientContextBase {
|
||||
public:
|
||||
GmmClientContext(GMM_CLIENT clientType, GmmExportEntries &gmmEntries);
|
||||
GmmClientContext(HardwareInfo *hwInfo, decltype(&InitializeGmm) initFunc, decltype(&GmmDestroy) destroyFunc);
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -7,12 +7,45 @@
|
||||
|
||||
#include "runtime/gmm_helper/client_context/gmm_client_context_base.h"
|
||||
|
||||
#include "core/helpers/debug_helpers.h"
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "runtime/os_interface/os_interface.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
#include "runtime/sku_info/operations/sku_info_transfer.h"
|
||||
|
||||
namespace NEO {
|
||||
GmmClientContextBase::GmmClientContextBase(GMM_CLIENT clientType, GmmExportEntries &gmmEntries) : gmmEntries(gmmEntries) {
|
||||
clientContext = gmmEntries.pfnCreateClientContext(clientType);
|
||||
GmmClientContextBase::GmmClientContextBase(HardwareInfo *hwInfo, decltype(&InitializeGmm) initFunc, decltype(&GmmDestroy) destroyFunc) : destroyFunc(destroyFunc) {
|
||||
_SKU_FEATURE_TABLE gmmFtrTable = {};
|
||||
_WA_TABLE gmmWaTable = {};
|
||||
SkuInfoTransfer::transferFtrTableForGmm(&gmmFtrTable, &hwInfo->featureTable);
|
||||
SkuInfoTransfer::transferWaTableForGmm(&gmmWaTable, &hwInfo->workaroundTable);
|
||||
|
||||
GMM_INIT_IN_ARGS inArgs;
|
||||
GMM_INIT_OUT_ARGS outArgs;
|
||||
|
||||
inArgs.ClientType = GMM_CLIENT::GMM_OCL_VISTA;
|
||||
inArgs.pGtSysInfo = &hwInfo->gtSystemInfo;
|
||||
inArgs.pSkuTable = &gmmFtrTable;
|
||||
inArgs.pWaTable = &gmmWaTable;
|
||||
inArgs.Platform = hwInfo->platform;
|
||||
|
||||
auto osInterface = platform()->peekExecutionEnvironment()->osInterface.get();
|
||||
if (osInterface) {
|
||||
osInterface->setGmmInputArgs(&inArgs);
|
||||
}
|
||||
|
||||
auto ret = initFunc(&inArgs, &outArgs);
|
||||
|
||||
UNRECOVERABLE_IF(ret != GMM_SUCCESS);
|
||||
|
||||
clientContext = outArgs.pGmmClientContext;
|
||||
}
|
||||
GmmClientContextBase::~GmmClientContextBase() {
|
||||
gmmEntries.pfnDeleteClientContext(clientContext);
|
||||
GMM_INIT_OUT_ARGS outArgs;
|
||||
outArgs.pGmmClientContext = clientContext;
|
||||
|
||||
destroyFunc(&outArgs);
|
||||
};
|
||||
|
||||
MEMORY_OBJECT_CONTROL_STATE GmmClientContextBase::cachePolicyGetMemoryObject(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE usage) {
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace NEO {
|
||||
class GmmClientContext;
|
||||
struct HardwareInfo;
|
||||
|
||||
class GmmClientContextBase {
|
||||
public:
|
||||
virtual ~GmmClientContextBase();
|
||||
@@ -22,8 +24,8 @@ class GmmClientContextBase {
|
||||
MOCKABLE_VIRTUAL void destroyResInfoObject(GMM_RESOURCE_INFO *pResInfo);
|
||||
GMM_CLIENT_CONTEXT *getHandle() const;
|
||||
template <typename T>
|
||||
static std::unique_ptr<GmmClientContext> create(GMM_CLIENT clientType, GmmExportEntries &gmmEntries) {
|
||||
return std::make_unique<T>(clientType, gmmEntries);
|
||||
static std::unique_ptr<GmmClientContext> create(HardwareInfo *hwInfo, decltype(&InitializeGmm) initFunc, decltype(&GmmDestroy) destroyFunc) {
|
||||
return std::make_unique<T>(hwInfo, initFunc, destroyFunc);
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL uint8_t getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format);
|
||||
@@ -31,7 +33,7 @@ class GmmClientContextBase {
|
||||
|
||||
protected:
|
||||
GMM_CLIENT_CONTEXT *clientContext;
|
||||
GmmClientContextBase(GMM_CLIENT clientType, GmmExportEntries &gmmEntries);
|
||||
GmmExportEntries &gmmEntries;
|
||||
GmmClientContextBase(HardwareInfo *hwInfo, decltype(&InitializeGmm) initFunc, decltype(&GmmDestroy) destroyFunc);
|
||||
decltype(&GmmDestroy) destroyFunc;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -33,21 +33,6 @@ GmmHelper *GmmHelper::getInstance() {
|
||||
return platform()->peekExecutionEnvironment()->getGmmHelper();
|
||||
}
|
||||
|
||||
void GmmHelper::initContext(const PLATFORM *platform,
|
||||
const FeatureTable *featureTable,
|
||||
const WorkaroundTable *workaroundTable,
|
||||
const GT_SYSTEM_INFO *pGtSysInfo) {
|
||||
_SKU_FEATURE_TABLE gmmFtrTable = {};
|
||||
_WA_TABLE gmmWaTable = {};
|
||||
SkuInfoTransfer::transferFtrTableForGmm(&gmmFtrTable, featureTable);
|
||||
SkuInfoTransfer::transferWaTableForGmm(&gmmWaTable, workaroundTable);
|
||||
loadLib();
|
||||
bool success = GMM_SUCCESS == gmmEntries.pfnCreateSingletonContext(*platform, &gmmFtrTable, &gmmWaTable, pGtSysInfo);
|
||||
UNRECOVERABLE_IF(!success);
|
||||
gmmClientContext = GmmHelper::createGmmContextWrapperFunc(GMM_CLIENT::GMM_OCL_VISTA, gmmEntries);
|
||||
UNRECOVERABLE_IF(!gmmClientContext);
|
||||
}
|
||||
|
||||
uint32_t GmmHelper::getMOCS(uint32_t type) {
|
||||
MEMORY_OBJECT_CONTROL_STATE mocs = gmmClientContext->cachePolicyGetMemoryObject(nullptr, static_cast<GMM_RESOURCE_USAGE_TYPE>(type));
|
||||
|
||||
@@ -91,10 +76,12 @@ GMM_YUV_PLANE GmmHelper::convertPlane(OCLPlane oclPlane) {
|
||||
return GMM_NO_PLANE;
|
||||
}
|
||||
GmmHelper::GmmHelper(const HardwareInfo *pHwInfo) : hwInfo(pHwInfo) {
|
||||
initContext(&pHwInfo->platform, &pHwInfo->featureTable, &pHwInfo->workaroundTable, &pHwInfo->gtSystemInfo);
|
||||
loadLib();
|
||||
gmmClientContext = GmmHelper::createGmmContextWrapperFunc(const_cast<HardwareInfo *>(pHwInfo), this->initGmmFunc, this->destroyGmmFunc);
|
||||
UNRECOVERABLE_IF(!gmmClientContext);
|
||||
}
|
||||
GmmHelper::~GmmHelper() {
|
||||
gmmEntries.pfnDestroySingletonContext();
|
||||
};
|
||||
|
||||
GmmHelper::~GmmHelper() = default;
|
||||
|
||||
decltype(GmmHelper::createGmmContextWrapperFunc) GmmHelper::createGmmContextWrapperFunc = GmmClientContextBase::create<GmmClientContext>;
|
||||
} // namespace NEO
|
||||
|
||||
@@ -17,8 +17,6 @@ class GmmClientContext;
|
||||
class GraphicsAllocation;
|
||||
class OsLibrary;
|
||||
struct HardwareInfo;
|
||||
struct FeatureTable;
|
||||
struct WorkaroundTable;
|
||||
struct ImageInfo;
|
||||
|
||||
class GmmHelper {
|
||||
@@ -50,15 +48,15 @@ class GmmHelper {
|
||||
static uint32_t getRenderMultisamplesCount(uint32_t numSamples);
|
||||
static GMM_YUV_PLANE convertPlane(OCLPlane oclPlane);
|
||||
|
||||
static std::unique_ptr<GmmClientContext> (*createGmmContextWrapperFunc)(GMM_CLIENT, GmmExportEntries &);
|
||||
static std::unique_ptr<GmmClientContext> (*createGmmContextWrapperFunc)(HardwareInfo *, decltype(&InitializeGmm), decltype(&GmmDestroy));
|
||||
|
||||
protected:
|
||||
void loadLib();
|
||||
void initContext(const PLATFORM *platform, const FeatureTable *featureTable, const WorkaroundTable *workaroundTable, const GT_SYSTEM_INFO *pGtSysInfo);
|
||||
|
||||
const HardwareInfo *hwInfo = nullptr;
|
||||
std::unique_ptr<OsLibrary> gmmLib;
|
||||
std::unique_ptr<GmmClientContext> gmmClientContext;
|
||||
GmmExportEntries gmmEntries = {};
|
||||
decltype(&InitializeGmm) initGmmFunc;
|
||||
decltype(&GmmDestroy) destroyGmmFunc;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -11,23 +11,17 @@
|
||||
|
||||
namespace Os {
|
||||
extern const char *gmmDllName;
|
||||
extern const char *gmmEntryName;
|
||||
extern const char *gmmInitFuncName;
|
||||
extern const char *gmmDestroyFuncName;
|
||||
} // namespace Os
|
||||
|
||||
namespace NEO {
|
||||
|
||||
void GmmHelper::loadLib() {
|
||||
gmmLib.reset(OsLibrary::load(Os::gmmDllName));
|
||||
bool isLoaded = false;
|
||||
UNRECOVERABLE_IF(!gmmLib);
|
||||
auto openGmmFunc = reinterpret_cast<decltype(&OpenGmm)>(gmmLib->getProcAddress(Os::gmmEntryName));
|
||||
auto status = openGmmFunc(&gmmEntries);
|
||||
if (status == GMM_SUCCESS) {
|
||||
isLoaded = gmmEntries.pfnCreateClientContext &&
|
||||
gmmEntries.pfnCreateSingletonContext &&
|
||||
gmmEntries.pfnDeleteClientContext &&
|
||||
gmmEntries.pfnDestroySingletonContext;
|
||||
}
|
||||
UNRECOVERABLE_IF(!isLoaded);
|
||||
initGmmFunc = reinterpret_cast<decltype(&InitializeGmm)>(gmmLib->getProcAddress(Os::gmmInitFuncName));
|
||||
destroyGmmFunc = reinterpret_cast<decltype(&GmmDestroy)>(gmmLib->getProcAddress(Os::gmmDestroyFuncName));
|
||||
UNRECOVERABLE_IF(!initGmmFunc || !destroyGmmFunc);
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -27,4 +27,6 @@ uint32_t OSInterface::getDeviceHandle() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void OSInterface::setGmmInputArgs(void *args) {}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -25,6 +25,7 @@ class OSInterface {
|
||||
static bool osEnableLocalMemory;
|
||||
static bool are64kbPagesEnabled();
|
||||
unsigned int getDeviceHandle() const;
|
||||
void setGmmInputArgs(void *args);
|
||||
|
||||
protected:
|
||||
OSInterfaceImpl *osInterfaceImpl = nullptr;
|
||||
|
||||
@@ -27,6 +27,10 @@ uint32_t OSInterface::getDeviceHandle() const {
|
||||
return static_cast<uint32_t>(osInterfaceImpl->getDeviceHandle());
|
||||
}
|
||||
|
||||
void OSInterface::setGmmInputArgs(void *args) {
|
||||
this->get()->getWddm()->setGmmInputArg(args);
|
||||
}
|
||||
|
||||
OSInterface::OSInterfaceImpl::OSInterfaceImpl() = default;
|
||||
|
||||
D3DKMT_HANDLE OSInterface::OSInterfaceImpl::getAdapterHandle() const {
|
||||
|
||||
@@ -161,6 +161,7 @@ bool Wddm::queryAdapterInfo() {
|
||||
SkuInfoReceiver::receiveWaTableFromAdapterInfo(workaroundTable.get(), &adapterInfo);
|
||||
|
||||
memcpy_s(&gfxPartition, sizeof(gfxPartition), &adapterInfo.GfxPartition, sizeof(GMM_GFX_PARTITIONING));
|
||||
memcpy_s(&adapterBDF, sizeof(adapterBDF), &adapterInfo.stAdapterBDF, sizeof(ADAPTER_BDF));
|
||||
|
||||
deviceRegistryPath = adapterInfo.DeviceRegistryPath;
|
||||
|
||||
@@ -972,6 +973,10 @@ void Wddm::waitOnPagingFenceFromCpu() {
|
||||
;
|
||||
}
|
||||
|
||||
void Wddm::setGmmInputArg(void *args) {
|
||||
reinterpret_cast<GMM_INIT_IN_ARGS *>(args)->stAdapterBDF = this->adapterBDF;
|
||||
}
|
||||
|
||||
void Wddm::updatePagingFenceValue(uint64_t newPagingFenceValue) {
|
||||
interlockedMax(currentPagingFenceValue, newPagingFenceValue);
|
||||
}
|
||||
|
||||
@@ -144,6 +144,8 @@ class Wddm {
|
||||
}
|
||||
void waitOnPagingFenceFromCpu();
|
||||
|
||||
void setGmmInputArg(void *args);
|
||||
|
||||
protected:
|
||||
std::unique_ptr<Gdi> gdi;
|
||||
D3DKMT_HANDLE adapter = 0;
|
||||
@@ -160,6 +162,7 @@ class Wddm {
|
||||
std::unique_ptr<FeatureTable> featureTable;
|
||||
std::unique_ptr<WorkaroundTable> workaroundTable;
|
||||
GMM_GFX_PARTITIONING gfxPartition;
|
||||
ADAPTER_BDF adapterBDF;
|
||||
uint64_t systemSharedMemory = 0;
|
||||
uint64_t dedicatedVideoMemory = 0;
|
||||
uint32_t maxRenderFrequency = 0;
|
||||
|
||||
Reference in New Issue
Block a user