mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Add instance of gmm helper to execution environment
Change-Id: I1b044611fbad91fbb681ba233938f41502f29056
This commit is contained in:

committed by
sys_ocldev

parent
f26535a93d
commit
94dbdb602d
@ -41,27 +41,15 @@ CommandStreamReceiver *createCommandStreamImpl(const HardwareInfo *pHwInfo) {
|
||||
if (csr) {
|
||||
switch (csr) {
|
||||
case CSR_AUB:
|
||||
GmmHelper::initContext(pHwInfo->pPlatform,
|
||||
pHwInfo->pSkuTable,
|
||||
pHwInfo->pWaTable,
|
||||
pHwInfo->pSysInfo);
|
||||
commandStreamReceiver = AUBCommandStreamReceiver::create(*pHwInfo, "aubfile", true);
|
||||
break;
|
||||
case CSR_TBX:
|
||||
GmmHelper::initContext(pHwInfo->pPlatform,
|
||||
pHwInfo->pSkuTable,
|
||||
pHwInfo->pWaTable,
|
||||
pHwInfo->pSysInfo);
|
||||
commandStreamReceiver = TbxCommandStreamReceiver::create(*pHwInfo, false);
|
||||
break;
|
||||
case CSR_HW_WITH_AUB:
|
||||
commandStreamReceiver = funcCreate(*pHwInfo, true);
|
||||
break;
|
||||
case CSR_TBX_WITH_AUB:
|
||||
GmmHelper::initContext(pHwInfo->pPlatform,
|
||||
pHwInfo->pSkuTable,
|
||||
pHwInfo->pWaTable,
|
||||
pHwInfo->pSysInfo);
|
||||
commandStreamReceiver = TbxCommandStreamReceiver::create(*pHwInfo, true);
|
||||
break;
|
||||
default:
|
||||
|
@ -134,6 +134,7 @@ Device::~Device() {
|
||||
}
|
||||
|
||||
bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) {
|
||||
outDevice.executionEnvironment->initGmm(pHwInfo);
|
||||
CommandStreamReceiver *commandStreamReceiver = createCommandStream(pHwInfo);
|
||||
if (!commandStreamReceiver) {
|
||||
return false;
|
||||
|
@ -53,9 +53,10 @@ class Device : public BaseObject<_cl_device_id> {
|
||||
static const cl_ulong objectMagic = 0x8055832341AC8D08LL;
|
||||
|
||||
template <typename T>
|
||||
static T *create(const HardwareInfo *pHwInfo) {
|
||||
static T *create(const HardwareInfo *pHwInfo, ExecutionEnvironment *execEnv) {
|
||||
pHwInfo = getDeviceInitHwInfo(pHwInfo);
|
||||
T *device = new T(*pHwInfo);
|
||||
device->connectToExecutionEnvironment(execEnv);
|
||||
if (false == createDeviceImpl(pHwInfo, *device)) {
|
||||
delete device;
|
||||
return nullptr;
|
||||
|
@ -21,8 +21,15 @@
|
||||
*/
|
||||
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
#include "runtime/os_interface/device_factory.h"
|
||||
|
||||
OCLRT::ExecutionEnvironment::~ExecutionEnvironment() {
|
||||
namespace OCLRT {
|
||||
ExecutionEnvironment::ExecutionEnvironment() = default;
|
||||
ExecutionEnvironment::~ExecutionEnvironment() {
|
||||
DeviceFactory::releaseDevices();
|
||||
}
|
||||
void ExecutionEnvironment::initGmm(const HardwareInfo *hwInfo) {
|
||||
gmmHelper.reset(new GmmHelper(hwInfo));
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
@ -23,8 +23,15 @@
|
||||
#include "runtime/utilities/reference_tracked_object.h"
|
||||
|
||||
namespace OCLRT {
|
||||
class GmmHelper;
|
||||
struct HardwareInfo;
|
||||
class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment> {
|
||||
public:
|
||||
ExecutionEnvironment();
|
||||
~ExecutionEnvironment() override;
|
||||
void initGmm(const HardwareInfo *hwInfo);
|
||||
|
||||
protected:
|
||||
std::unique_ptr<GmmHelper> gmmHelper;
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
@ -30,9 +30,10 @@
|
||||
#include "runtime/helpers/surface_formats.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "runtime/sku_info/operations/sku_info_transfer.h"
|
||||
#include "runtime/os_interface/os_library.h"
|
||||
|
||||
namespace OCLRT {
|
||||
bool GmmHelper::initContext(const PLATFORM *pPlatform,
|
||||
void GmmHelper::initContext(const PLATFORM *pPlatform,
|
||||
const FeatureTable *pSkuTable,
|
||||
const WorkaroundTable *pWaTable,
|
||||
const GT_SYSTEM_INFO *pGtSysInfo) {
|
||||
@ -41,14 +42,12 @@ bool GmmHelper::initContext(const PLATFORM *pPlatform,
|
||||
_WA_TABLE gmmWaTable = {};
|
||||
SkuInfoTransfer::transferFtrTableForGmm(&gmmFtrTable, pSkuTable);
|
||||
SkuInfoTransfer::transferWaTableForGmm(&gmmWaTable, pWaTable);
|
||||
if (!isLoaded) {
|
||||
loadLib();
|
||||
}
|
||||
loadLib();
|
||||
bool success = GMM_SUCCESS == initGlobalContextFunc(*pPlatform, &gmmFtrTable, &gmmWaTable, pGtSysInfo, GMM_CLIENT::GMM_OCL_VISTA);
|
||||
UNRECOVERABLE_IF(!success);
|
||||
GmmHelper::gmmClientContext = GmmHelper::createClientContextFunc(GMM_CLIENT::GMM_OCL_VISTA);
|
||||
}
|
||||
return GmmHelper::gmmClientContext != nullptr;
|
||||
UNRECOVERABLE_IF(!GmmHelper::gmmClientContext);
|
||||
}
|
||||
|
||||
void GmmHelper::destroyContext() {
|
||||
@ -56,6 +55,10 @@ void GmmHelper::destroyContext() {
|
||||
deleteClientContextFunc(GmmHelper::gmmClientContext);
|
||||
GmmHelper::gmmClientContext = nullptr;
|
||||
destroyGlobalContextFunc();
|
||||
if (gmmLib) {
|
||||
delete gmmLib;
|
||||
gmmLib = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +70,6 @@ uint32_t GmmHelper::getMOCS(uint32_t type) {
|
||||
return cacheEnabledIndex;
|
||||
}
|
||||
}
|
||||
|
||||
MEMORY_OBJECT_CONTROL_STATE mocs = GmmHelper::gmmClientContext->CachePolicyGetMemoryObject(nullptr, static_cast<GMM_RESOURCE_USAGE_TYPE>(type));
|
||||
|
||||
return static_cast<uint32_t>(mocs.DwordValue);
|
||||
@ -159,10 +161,17 @@ GMM_YUV_PLANE GmmHelper::convertPlane(OCLPlane oclPlane) {
|
||||
|
||||
return GMM_NO_PLANE;
|
||||
}
|
||||
|
||||
GmmHelper::GmmHelper(const HardwareInfo *pHwInfo) {
|
||||
GmmHelper::hwInfo = pHwInfo;
|
||||
initContext(pHwInfo->pPlatform, pHwInfo->pSkuTable, pHwInfo->pWaTable, pHwInfo->pSysInfo);
|
||||
}
|
||||
GmmHelper::~GmmHelper() {
|
||||
if (isLoaded) {
|
||||
destroyContext();
|
||||
}
|
||||
}
|
||||
bool GmmHelper::useSimplifiedMocsTable = false;
|
||||
GMM_CLIENT_CONTEXT *GmmHelper::gmmClientContext = nullptr;
|
||||
const HardwareInfo *GmmHelper::hwInfo = nullptr;
|
||||
bool GmmHelper::isLoaded = false;
|
||||
|
||||
OsLibrary *GmmHelper::gmmLib = nullptr;
|
||||
} // namespace OCLRT
|
||||
|
@ -35,18 +35,17 @@ struct WorkaroundTable;
|
||||
struct ImageInfo;
|
||||
class GraphicsAllocation;
|
||||
class Gmm;
|
||||
class OsLibrary;
|
||||
|
||||
class GmmHelper {
|
||||
public:
|
||||
GmmHelper() = delete;
|
||||
GmmHelper(const HardwareInfo *hwInfo);
|
||||
~GmmHelper();
|
||||
static constexpr uint32_t cacheDisabledIndex = 0;
|
||||
static constexpr uint32_t cacheEnabledIndex = 4;
|
||||
static constexpr uint32_t maxPossiblePitch = 2147483648;
|
||||
|
||||
static void loadLib();
|
||||
static bool initContext(const PLATFORM *pPlatform, const FeatureTable *pSkuTable, const WorkaroundTable *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo);
|
||||
static void destroyContext();
|
||||
|
||||
static uint64_t canonize(uint64_t address);
|
||||
static uint64_t decanonize(uint64_t address);
|
||||
|
||||
@ -67,6 +66,13 @@ class GmmHelper {
|
||||
static bool useSimplifiedMocsTable;
|
||||
static GMM_CLIENT_CONTEXT *gmmClientContext;
|
||||
static const HardwareInfo *hwInfo;
|
||||
static bool isLoaded;
|
||||
static OsLibrary *gmmLib;
|
||||
|
||||
protected:
|
||||
void loadLib();
|
||||
void initContext(const PLATFORM *pPlatform, const FeatureTable *pSkuTable, const WorkaroundTable *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo);
|
||||
void destroyContext();
|
||||
|
||||
bool isLoaded = false;
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
@ -24,6 +24,9 @@
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
|
||||
namespace OCLRT {
|
||||
GmmMemoryBase::GmmMemoryBase() {
|
||||
clientContext = GmmHelper::gmmClientContext;
|
||||
}
|
||||
bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter,
|
||||
GMM_ESCAPE_HANDLE hDevice,
|
||||
GMM_ESCAPE_FUNC_TYPE pfnEscape,
|
||||
@ -33,7 +36,7 @@ bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter,
|
||||
BOOLEAN BDWL3Coherency,
|
||||
GMM_GFX_SIZE_T SizeOverride,
|
||||
GMM_GFX_SIZE_T SlmGfxSpaceReserve) {
|
||||
return GmmHelper::gmmClientContext->ConfigureDeviceAddressSpace(
|
||||
return clientContext->ConfigureDeviceAddressSpace(
|
||||
{hAdapter},
|
||||
{hDevice},
|
||||
{pfnEscape},
|
||||
@ -46,7 +49,7 @@ bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter,
|
||||
}
|
||||
|
||||
uintptr_t GmmMemoryBase::getInternalGpuVaRangeLimit() {
|
||||
return static_cast<uintptr_t>(GmmHelper::gmmClientContext->GetInternalGpuVaRangeLimit());
|
||||
return static_cast<uintptr_t>(clientContext->GetInternalGpuVaRangeLimit());
|
||||
}
|
||||
|
||||
}; // namespace OCLRT
|
||||
|
@ -42,6 +42,7 @@ class GmmMemoryBase {
|
||||
MOCKABLE_VIRTUAL uintptr_t getInternalGpuVaRangeLimit();
|
||||
|
||||
protected:
|
||||
GmmMemoryBase() = default;
|
||||
GmmMemoryBase();
|
||||
GMM_CLIENT_CONTEXT *clientContext;
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
@ -28,7 +28,7 @@
|
||||
namespace OCLRT {
|
||||
class GmmPageTableMngr {
|
||||
public:
|
||||
MOCKABLE_VIRTUAL ~GmmPageTableMngr() = default;
|
||||
MOCKABLE_VIRTUAL ~GmmPageTableMngr();
|
||||
|
||||
static GmmPageTableMngr *create(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb);
|
||||
|
||||
@ -45,13 +45,10 @@ class GmmPageTableMngr {
|
||||
}
|
||||
|
||||
protected:
|
||||
static void customDeleter(GMM_PAGETABLE_MGR *gmmPageTableManager);
|
||||
using UniquePtrType = std::unique_ptr<GMM_PAGETABLE_MGR, std::function<void(GMM_PAGETABLE_MGR *)>>;
|
||||
|
||||
GmmPageTableMngr() = default;
|
||||
|
||||
GmmPageTableMngr(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb);
|
||||
|
||||
UniquePtrType pageTableManager;
|
||||
GMM_CLIENT_CONTEXT *clientContext = nullptr;
|
||||
GMM_PAGETABLE_MGR *pageTableManager = nullptr;
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
@ -24,13 +24,15 @@
|
||||
#include "runtime/gmm_helper/page_table_mngr.h"
|
||||
|
||||
namespace OCLRT {
|
||||
void GmmPageTableMngr::customDeleter(GMM_PAGETABLE_MGR *gmmPageTableManager) {
|
||||
GmmHelper::gmmClientContext->DestroyPageTblMgrObject(gmmPageTableManager);
|
||||
GmmPageTableMngr::~GmmPageTableMngr() {
|
||||
if (clientContext) {
|
||||
clientContext->DestroyPageTblMgrObject(pageTableManager);
|
||||
}
|
||||
}
|
||||
|
||||
GmmPageTableMngr::GmmPageTableMngr(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) {
|
||||
auto pageTableMngrPtr = GmmHelper::gmmClientContext->CreatePageTblMgrObject(deviceCb, translationTableCb, translationTableFlags);
|
||||
this->pageTableManager = UniquePtrType(pageTableMngrPtr, GmmPageTableMngr::customDeleter);
|
||||
this->clientContext = GmmHelper::gmmClientContext;
|
||||
pageTableManager = clientContext->CreatePageTblMgrObject(deviceCb, translationTableCb, translationTableFlags);
|
||||
}
|
||||
|
||||
} // namespace OCLRT
|
||||
|
@ -75,8 +75,7 @@ bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices) {
|
||||
DeviceFactory::numDevices = devNum;
|
||||
DeviceFactory::hwInfos = ptr;
|
||||
|
||||
return GmmHelper::initContext(hwInfos->pPlatform, hwInfos->pSkuTable,
|
||||
hwInfos->pWaTable, hwInfos->pSysInfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeviceFactory::releaseDevices() {
|
||||
|
@ -39,9 +39,8 @@ decltype(GmmHelper::destroyGlobalContextFunc) GmmHelper::destroyGlobalContextFun
|
||||
decltype(GmmHelper::createClientContextFunc) GmmHelper::createClientContextFunc = nullptr;
|
||||
decltype(GmmHelper::deleteClientContextFunc) GmmHelper::deleteClientContextFunc = nullptr;
|
||||
|
||||
std::unique_ptr<OsLibrary> gmmLib;
|
||||
void GmmHelper::loadLib() {
|
||||
gmmLib.reset(OsLibrary::load(Os::gmmDllName));
|
||||
gmmLib = OsLibrary::load(Os::gmmDllName);
|
||||
|
||||
UNRECOVERABLE_IF(!gmmLib);
|
||||
if (gmmLib->isLoaded()) {
|
||||
|
@ -85,8 +85,6 @@ Wddm::Wddm() : initialized(false),
|
||||
|
||||
Wddm::~Wddm() {
|
||||
resetPageTableManager(nullptr);
|
||||
if (initialized)
|
||||
destroyGmmContext();
|
||||
destroyContext(context);
|
||||
destroyPagingQueue();
|
||||
destroyDevice();
|
||||
|
@ -211,8 +211,6 @@ class Wddm {
|
||||
void getDeviceState();
|
||||
void handleCompletion();
|
||||
unsigned int readEnablePreemptionRegKey();
|
||||
bool initGmmContext();
|
||||
void destroyGmmContext();
|
||||
void resetMonitoredFenceParams(D3DKMT_HANDLE &handle, uint64_t *cpuAddress, D3DGPU_VIRTUAL_ADDRESS &gpuAddress);
|
||||
virtual const bool hwQueuesSupported() const { return false; }
|
||||
|
||||
|
@ -52,9 +52,6 @@ bool Wddm::init() {
|
||||
if (!createPagingQueue()) {
|
||||
return false;
|
||||
}
|
||||
if (!initGmmContext()) {
|
||||
return false;
|
||||
}
|
||||
if (!configureDeviceAddressSpace<GfxFamily>()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -40,15 +40,4 @@ Wddm::VirtualFreeFcn getVirtualFree() {
|
||||
Wddm::VirtualAllocFcn getVirtualAlloc() {
|
||||
return VirtualAlloc;
|
||||
}
|
||||
|
||||
bool Wddm::initGmmContext() {
|
||||
return GmmHelper::initContext(gfxPlatform.get(),
|
||||
featureTable.get(),
|
||||
waTable.get(),
|
||||
gtSystemInfo.get());
|
||||
}
|
||||
|
||||
void Wddm::destroyGmmContext() {
|
||||
GmmHelper::destroyContext();
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
@ -148,7 +148,7 @@ bool Platform::initialize() {
|
||||
|
||||
this->devices.resize(numDevicesReturned);
|
||||
for (size_t deviceOrdinal = 0; deviceOrdinal < numDevicesReturned; ++deviceOrdinal) {
|
||||
auto pDevice = Device::create<OCLRT::Device>(&hwInfo[deviceOrdinal]);
|
||||
auto pDevice = Device::create<OCLRT::Device>(&hwInfo[deviceOrdinal], executionEnvironment);
|
||||
DEBUG_BREAK_IF(!pDevice);
|
||||
if (pDevice) {
|
||||
this->devices[deviceOrdinal] = pDevice;
|
||||
@ -168,7 +168,6 @@ bool Platform::initialize() {
|
||||
}
|
||||
|
||||
compilerExtensions = convertEnabledExtensionsToCompilerInternalOptions(pDevice->getDeviceInfo().deviceExtensions);
|
||||
pDevice->connectToExecutionEnvironment(this->executionEnvironment);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user