mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Gmm interface update
- Use local gmmClientContext instead of pGMMGlobalContext - ResourceInfo and PTmanager creation from gmmClientContext - Mock Gmm context creation in Wddm to have only one instance per run Change-Id: I67e015c57f0ab5524564760fd9a849615615697f
This commit is contained in:
committed by
sys_ocldev
parent
231ad7cfd9
commit
46003145e9
@@ -24,13 +24,16 @@ set(RUNTIME_SRCS_GMM_HELPER_BASE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gmm_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gmm_lib.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/resource_info.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/resource_info_impl.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/gmm_utils.cpp
|
||||
)
|
||||
|
||||
set(RUNTIME_SRCS_GMM_HELPER_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/page_table_mngr.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/page_table_mngr_impl.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/gmm_memory.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gmm_memory_base.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gmm_memory_base.cpp
|
||||
)
|
||||
|
||||
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_GMM_HELPER_BASE})
|
||||
|
||||
@@ -66,15 +66,25 @@ bool Gmm::initContext(const PLATFORM *pPlatform,
|
||||
const FeatureTable *pSkuTable,
|
||||
const WorkaroundTable *pWaTable,
|
||||
const GT_SYSTEM_INFO *pGtSysInfo) {
|
||||
// fill values Gmmlib requested
|
||||
_SKU_FEATURE_TABLE gmmFtrTable = {};
|
||||
_WA_TABLE gmmWaTable = {};
|
||||
SkuInfoTransfer::transferFtrTableForGmm(&gmmFtrTable, pSkuTable);
|
||||
SkuInfoTransfer::transferWaTableForGmm(&gmmWaTable, pWaTable);
|
||||
if (!Gmm::gmmClientContext) {
|
||||
_SKU_FEATURE_TABLE gmmFtrTable = {};
|
||||
_WA_TABLE gmmWaTable = {};
|
||||
SkuInfoTransfer::transferFtrTableForGmm(&gmmFtrTable, pSkuTable);
|
||||
SkuInfoTransfer::transferWaTableForGmm(&gmmWaTable, pWaTable);
|
||||
|
||||
bool success = GMM_SUCCESS == GmmInitGlobalContext(*pPlatform, &gmmFtrTable, &gmmWaTable, pGtSysInfo, GMM_OGL_VISTA);
|
||||
DEBUG_BREAK_IF(!success);
|
||||
return success;
|
||||
bool success = GMM_SUCCESS == GmmInitGlobalContext(*pPlatform, &gmmFtrTable, &gmmWaTable, pGtSysInfo, GMM_CLIENT::GMM_OCL_VISTA);
|
||||
UNRECOVERABLE_IF(!success);
|
||||
Gmm::gmmClientContext = GmmCreateClientContext(GMM_CLIENT::GMM_OCL_VISTA);
|
||||
}
|
||||
return Gmm::gmmClientContext != nullptr;
|
||||
}
|
||||
|
||||
void Gmm::destroyContext() {
|
||||
if (Gmm::gmmClientContext) {
|
||||
GmmDeleteClientContext(Gmm::gmmClientContext);
|
||||
Gmm::gmmClientContext = nullptr;
|
||||
GmmDestroyGlobalContext();
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t Gmm::getMOCS(uint32_t type) {
|
||||
@@ -86,8 +96,7 @@ uint32_t Gmm::getMOCS(uint32_t type) {
|
||||
}
|
||||
}
|
||||
|
||||
MEMORY_OBJECT_CONTROL_STATE mocs =
|
||||
pGmmGlobalContext->GetCachePolicyObj()->CachePolicyGetMemoryObject(nullptr, static_cast<GMM_RESOURCE_USAGE_TYPE>(type));
|
||||
MEMORY_OBJECT_CONTROL_STATE mocs = Gmm::gmmClientContext->CachePolicyGetMemoryObject(nullptr, static_cast<GMM_RESOURCE_USAGE_TYPE>(type));
|
||||
|
||||
return static_cast<uint32_t>(mocs.DwordValue);
|
||||
}
|
||||
@@ -404,5 +413,6 @@ bool Gmm::unifiedAuxTranslationCapable() const {
|
||||
}
|
||||
|
||||
bool Gmm::useSimplifiedMocsTable = false;
|
||||
GMM_CLIENT_CONTEXT *Gmm::gmmClientContext = nullptr;
|
||||
|
||||
} // namespace OCLRT
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -63,7 +63,7 @@ class Gmm {
|
||||
static Gmm *create(GMM_RESOURCE_INFO *inputGmm);
|
||||
|
||||
static bool initContext(const PLATFORM *pPlatform, const FeatureTable *pSkuTable, const WorkaroundTable *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo);
|
||||
static void destroyContext() { GmmDestroyGlobalContext(); }
|
||||
static void destroyContext();
|
||||
|
||||
static uint32_t getMOCS(uint32_t type);
|
||||
|
||||
@@ -99,5 +99,6 @@ class Gmm {
|
||||
|
||||
bool isRenderCompressed = false;
|
||||
static bool useSimplifiedMocsTable;
|
||||
static GMM_CLIENT_CONTEXT *gmmClientContext;
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
||||
52
runtime/gmm_helper/gmm_memory_base.cpp
Normal file
52
runtime/gmm_helper/gmm_memory_base.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "runtime/gmm_helper/gmm_memory_base.h"
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
|
||||
namespace OCLRT {
|
||||
bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter,
|
||||
GMM_ESCAPE_HANDLE hDevice,
|
||||
GMM_ESCAPE_FUNC_TYPE pfnEscape,
|
||||
GMM_GFX_SIZE_T SvmSize,
|
||||
BOOLEAN FaultableSvm,
|
||||
BOOLEAN SparseReady,
|
||||
BOOLEAN BDWL3Coherency,
|
||||
GMM_GFX_SIZE_T SizeOverride,
|
||||
GMM_GFX_SIZE_T SlmGfxSpaceReserve) {
|
||||
return Gmm::gmmClientContext->ConfigureDeviceAddressSpace(
|
||||
{hAdapter},
|
||||
{hDevice},
|
||||
{pfnEscape},
|
||||
SvmSize,
|
||||
FaultableSvm,
|
||||
SparseReady,
|
||||
BDWL3Coherency,
|
||||
SizeOverride,
|
||||
SlmGfxSpaceReserve) != 0;
|
||||
}
|
||||
|
||||
uintptr_t GmmMemoryBase::getInternalGpuVaRangeLimit() {
|
||||
return static_cast<uintptr_t>(pGmmGlobalContext->GetInternalGpuVaRangeLimit());
|
||||
}
|
||||
|
||||
}; // namespace OCLRT
|
||||
@@ -37,24 +37,9 @@ class GmmMemoryBase {
|
||||
BOOLEAN SparseReady,
|
||||
BOOLEAN BDWL3Coherency,
|
||||
GMM_GFX_SIZE_T SizeOverride,
|
||||
GMM_GFX_SIZE_T SlmGfxSpaceReserve) {
|
||||
return GmmConfigureDeviceAddressSpace(
|
||||
hAdapter,
|
||||
hDevice,
|
||||
pfnEscape,
|
||||
SvmSize,
|
||||
FaultableSvm,
|
||||
SparseReady,
|
||||
BDWL3Coherency,
|
||||
SizeOverride,
|
||||
SlmGfxSpaceReserve) != 0
|
||||
? true
|
||||
: false;
|
||||
}
|
||||
GMM_GFX_SIZE_T SlmGfxSpaceReserve);
|
||||
|
||||
MOCKABLE_VIRTUAL uintptr_t getInternalGpuVaRangeLimit() {
|
||||
return static_cast<uintptr_t>(pGmmGlobalContext->GetInternalGpuVaRangeLimit());
|
||||
}
|
||||
MOCKABLE_VIRTUAL uintptr_t getInternalGpuVaRangeLimit();
|
||||
|
||||
protected:
|
||||
GmmMemoryBase() = default;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -23,11 +23,12 @@
|
||||
#pragma once
|
||||
#include "runtime/gmm_helper/gmm_lib.h"
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
namespace OCLRT {
|
||||
class GmmPageTableMngr {
|
||||
public:
|
||||
virtual ~GmmPageTableMngr() = default;
|
||||
MOCKABLE_VIRTUAL ~GmmPageTableMngr() = default;
|
||||
|
||||
static GmmPageTableMngr *create(GMM_DEVICE_CALLBACKS *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb);
|
||||
|
||||
@@ -44,12 +45,13 @@ 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 *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) {
|
||||
pageTableManager.reset(new GMM_PAGETABLE_MGR(deviceCb, translationTableFlags, translationTableCb));
|
||||
}
|
||||
GmmPageTableMngr(GMM_DEVICE_CALLBACKS *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb);
|
||||
|
||||
std::unique_ptr<GMM_PAGETABLE_MGR> pageTableManager;
|
||||
UniquePtrType pageTableManager;
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
||||
36
runtime/gmm_helper/page_table_mngr_impl.cpp
Normal file
36
runtime/gmm_helper/page_table_mngr_impl.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
#include "runtime/gmm_helper/page_table_mngr.h"
|
||||
|
||||
namespace OCLRT {
|
||||
void GmmPageTableMngr::customDeleter(GMM_PAGETABLE_MGR *gmmPageTableManager) {
|
||||
Gmm::gmmClientContext->DestroyPageTblMgrObject(gmmPageTableManager);
|
||||
}
|
||||
|
||||
GmmPageTableMngr::GmmPageTableMngr(GMM_DEVICE_CALLBACKS *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) {
|
||||
auto pageTableMngrPtr = Gmm::gmmClientContext->CreatePageTblMgrObject(deviceCb, translationTableCb, translationTableFlags);
|
||||
this->pageTableManager = UniquePtrType(pageTableMngrPtr, GmmPageTableMngr::customDeleter);
|
||||
}
|
||||
|
||||
} // namespace OCLRT
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -23,6 +23,7 @@
|
||||
#pragma once
|
||||
#include "runtime/gmm_helper/gmm_lib.h"
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
namespace OCLRT {
|
||||
class GmmResourceInfo {
|
||||
@@ -31,11 +32,7 @@ class GmmResourceInfo {
|
||||
|
||||
static GmmResourceInfo *create(GMM_RESOURCE_INFO *inputGmmResourceInfo);
|
||||
|
||||
virtual ~GmmResourceInfo() {
|
||||
if (resourceInfo) {
|
||||
GmmResFree(resourceInfo);
|
||||
}
|
||||
}
|
||||
MOCKABLE_VIRTUAL ~GmmResourceInfo() = default;
|
||||
|
||||
MOCKABLE_VIRTUAL size_t getSizeAllocation() { return static_cast<size_t>(resourceInfo->GetSizeAllocation()); }
|
||||
|
||||
@@ -81,15 +78,18 @@ class GmmResourceInfo {
|
||||
|
||||
MOCKABLE_VIRTUAL uint64_t getUnifiedAuxSurfaceOffset(GMM_UNIFIED_AUX_TYPE auxType) { return resourceInfo->GetUnifiedAuxSurfaceOffset(auxType); }
|
||||
|
||||
MOCKABLE_VIRTUAL GMM_RESOURCE_INFO *peekHandle() const { return resourceInfo; }
|
||||
MOCKABLE_VIRTUAL GMM_RESOURCE_INFO *peekHandle() const { return resourceInfo.get(); }
|
||||
|
||||
protected:
|
||||
static void customDeleter(GMM_RESOURCE_INFO *gmmResourceInfoHandle);
|
||||
using UniquePtrType = std::unique_ptr<GMM_RESOURCE_INFO, std::function<void(GMM_RESOURCE_INFO *)>>;
|
||||
|
||||
GmmResourceInfo() = default;
|
||||
|
||||
GmmResourceInfo(GMM_RESCREATE_PARAMS *resourceCreateParams) { resourceInfo = GmmResCreate(resourceCreateParams); }
|
||||
GmmResourceInfo(GMM_RESCREATE_PARAMS *resourceCreateParams);
|
||||
|
||||
GmmResourceInfo(GMM_RESOURCE_INFO *inputGmmResourceInfo) { resourceInfo = GmmResCopy(inputGmmResourceInfo); }
|
||||
GmmResourceInfo(GMM_RESOURCE_INFO *inputGmmResourceInfo);
|
||||
|
||||
GMM_RESOURCE_INFO *resourceInfo = nullptr;
|
||||
UniquePtrType resourceInfo;
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
||||
41
runtime/gmm_helper/resource_info_impl.cpp
Normal file
41
runtime/gmm_helper/resource_info_impl.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "runtime/gmm_helper/resource_info.h"
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
|
||||
namespace OCLRT {
|
||||
void GmmResourceInfo::customDeleter(GMM_RESOURCE_INFO *gmmResourceInfo) {
|
||||
Gmm::gmmClientContext->DestroyResInfoObject(gmmResourceInfo);
|
||||
}
|
||||
|
||||
GmmResourceInfo::GmmResourceInfo(GMM_RESCREATE_PARAMS *resourceCreateParams) {
|
||||
auto resourceInfoPtr = Gmm::gmmClientContext->CreateResInfoObject(resourceCreateParams);
|
||||
this->resourceInfo = UniquePtrType(resourceInfoPtr, GmmResourceInfo::customDeleter);
|
||||
}
|
||||
|
||||
GmmResourceInfo::GmmResourceInfo(GMM_RESOURCE_INFO *inputGmmResourceInfo) {
|
||||
auto resourceInfoPtr = Gmm::gmmClientContext->CopyResInfoObject(inputGmmResourceInfo);
|
||||
this->resourceInfo = UniquePtrType(resourceInfoPtr, GmmResourceInfo::customDeleter);
|
||||
}
|
||||
|
||||
} // namespace OCLRT
|
||||
@@ -90,7 +90,7 @@ Wddm::Wddm() : Wddm(new Gdi()) {
|
||||
Wddm::~Wddm() {
|
||||
resetPageTableManager(nullptr);
|
||||
if (initialized)
|
||||
Gmm::destroyContext();
|
||||
destroyGmmContext();
|
||||
destroyContext(context);
|
||||
destroyPagingQueue();
|
||||
destroyDevice();
|
||||
|
||||
@@ -219,6 +219,8 @@ class Wddm {
|
||||
void getDeviceState();
|
||||
void handleCompletion();
|
||||
unsigned int readEnablePreemptionRegKey();
|
||||
bool initGmmContext();
|
||||
void destroyGmmContext();
|
||||
|
||||
static CreateDXGIFactoryFcn createDxgiFactory;
|
||||
static GetSystemInfoFcn getSystemInfo;
|
||||
|
||||
@@ -52,7 +52,7 @@ bool Wddm::init() {
|
||||
if (!createPagingQueue()) {
|
||||
return false;
|
||||
}
|
||||
if (!Gmm::initContext(gfxPlatform.get(), featureTable.get(), waTable.get(), gtSystemInfo.get())) {
|
||||
if (!initGmmContext()) {
|
||||
return false;
|
||||
}
|
||||
if (!configureDeviceAddressSpace<GfxFamily>()) {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
#include "runtime/os_interface/windows/wddm.h"
|
||||
#include <dxgi.h>
|
||||
namespace OCLRT {
|
||||
@@ -44,4 +45,15 @@ Wddm::VirtualAllocFcn getVirtualAlloc() {
|
||||
return VirtualAlloc;
|
||||
}
|
||||
|
||||
bool Wddm::initGmmContext() {
|
||||
return Gmm::initContext(gfxPlatform.get(),
|
||||
featureTable.get(),
|
||||
waTable.get(),
|
||||
gtSystemInfo.get());
|
||||
}
|
||||
|
||||
void Wddm::destroyGmmContext() {
|
||||
Gmm::destroyContext();
|
||||
}
|
||||
|
||||
} // namespace OCLRT
|
||||
|
||||
Reference in New Issue
Block a user