mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 23:03:02 +08:00
Prepare to use gmm as dll on Windows
Since this commit neo on Windows can use static or shared gmm lib Change-Id: I7db70d7f9bc969e8193ac77e8b6d65ecc57d0093
This commit is contained in:
committed by
sys_ocldev
parent
c1782b802a
commit
98b8b4b6a4
@@ -24,6 +24,13 @@ else()
|
||||
set(KMDAF_FILE_SUFFIX "_stub")
|
||||
endif()
|
||||
|
||||
if(USE_STATIC_GMM)
|
||||
set(GMM_INTERFACE_FILE_WINDOWS ${CMAKE_CURRENT_SOURCE_DIR}/gmm_interface_static_win.cpp)
|
||||
else()
|
||||
set(GMM_INTERFACE_FILE_WINDOWS ${CMAKE_CURRENT_SOURCE_DIR}/gmm_interface_dynamic_win.cpp)
|
||||
endif()
|
||||
set_property(GLOBAL PROPERTY GMM_INTERFACE_FILE_WINDOWS ${GMM_INTERFACE_FILE_WINDOWS})
|
||||
|
||||
set(RUNTIME_SRCS_OS_INTERFACE_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/api_win.cpp
|
||||
@@ -39,6 +46,7 @@ set(RUNTIME_SRCS_OS_INTERFACE_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/driver_info.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gdi_interface.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gdi_interface.h
|
||||
${GMM_INTERFACE_FILE_WINDOWS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kmdaf_listener${KMDAF_FILE_SUFFIX}.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kmdaf_listener.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_inc.h
|
||||
|
||||
@@ -99,7 +99,5 @@ class Gdi {
|
||||
|
||||
private:
|
||||
OCLRT::Windows::OsLibrary gdiDll;
|
||||
static const std::string gdiDllName;
|
||||
static const std::string gdiMockDllName;
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
||||
61
runtime/os_interface/windows/gmm_interface_dynamic_win.cpp
Normal file
61
runtime/os_interface/windows/gmm_interface_dynamic_win.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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/helpers/debug_helpers.h"
|
||||
#include "runtime/os_interface/os_library.h"
|
||||
|
||||
namespace Os {
|
||||
extern const char *gmmDllName;
|
||||
}
|
||||
|
||||
namespace OCLRT {
|
||||
GMM_STATUS(GMM_STDCALL *myPfnCreateSingletonContext)
|
||||
(const PLATFORM Platform, const SKU_FEATURE_TABLE *pSkuTable, const WA_TABLE *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo);
|
||||
GMM_STATUS GMM_STDCALL myGmmInitGlobalContext(const PLATFORM Platform, const SKU_FEATURE_TABLE *pSkuTable, const WA_TABLE *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo, GMM_CLIENT ClientType) {
|
||||
return myPfnCreateSingletonContext(Platform, pSkuTable, pWaTable, pGtSysInfo);
|
||||
}
|
||||
decltype(Gmm::initGlobalContextFunc) Gmm::initGlobalContextFunc = &myGmmInitGlobalContext;
|
||||
decltype(Gmm::destroyGlobalContextFunc) Gmm::destroyGlobalContextFunc = nullptr;
|
||||
decltype(Gmm::createClientContextFunc) Gmm::createClientContextFunc = nullptr;
|
||||
decltype(Gmm::deleteClientContextFunc) Gmm::deleteClientContextFunc = nullptr;
|
||||
|
||||
std::unique_ptr<OsLibrary> gmmLib;
|
||||
void Gmm::loadLib() {
|
||||
gmmLib.reset(OsLibrary::load(Os::gmmDllName));
|
||||
|
||||
UNRECOVERABLE_IF(!gmmLib);
|
||||
if (gmmLib->isLoaded()) {
|
||||
auto openGmmFunc = reinterpret_cast<decltype(&OpenGmm)>(gmmLib->getProcAddress(GMM_ENTRY_NAME));
|
||||
GmmExportEntries entries;
|
||||
auto status = openGmmFunc(&entries);
|
||||
if (status == GMM_SUCCESS) {
|
||||
myPfnCreateSingletonContext = entries.pfnCreateSingletonContext;
|
||||
Gmm::destroyGlobalContextFunc = entries.pfnDestroySingletonContext;
|
||||
Gmm::createClientContextFunc = entries.pfnCreateClientContext;
|
||||
Gmm::deleteClientContextFunc = entries.pfnDeleteClientContext;
|
||||
isLoaded = myPfnCreateSingletonContext && Gmm::destroyGlobalContextFunc && Gmm::createClientContextFunc && Gmm::deleteClientContextFunc;
|
||||
}
|
||||
}
|
||||
UNRECOVERABLE_IF(!isLoaded);
|
||||
}
|
||||
}
|
||||
58
runtime/os_interface/windows/gmm_interface_static_win.cpp
Normal file
58
runtime/os_interface/windows/gmm_interface_static_win.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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"
|
||||
|
||||
namespace OCLRT {
|
||||
|
||||
decltype(Gmm::initGlobalContextFunc) Gmm::initGlobalContextFunc = nullptr;
|
||||
decltype(Gmm::destroyGlobalContextFunc) Gmm::destroyGlobalContextFunc = nullptr;
|
||||
decltype(Gmm::createClientContextFunc) Gmm::createClientContextFunc = nullptr;
|
||||
decltype(Gmm::deleteClientContextFunc) Gmm::deleteClientContextFunc = nullptr;
|
||||
|
||||
void Gmm::loadLib() {
|
||||
Gmm::initGlobalContextFunc = GmmInitGlobalContext;
|
||||
Gmm::destroyGlobalContextFunc = GmmDestroyGlobalContext;
|
||||
Gmm::createClientContextFunc = GmmCreateClientContext;
|
||||
Gmm::deleteClientContextFunc = GmmDeleteClientContext;
|
||||
isLoaded = true;
|
||||
}
|
||||
}
|
||||
extern "C" {
|
||||
void GMMDebugBreak(const char *file, const char *function, const int line) {
|
||||
}
|
||||
|
||||
void GMMPrintMessage(uint32_t debugLevel, const char *debugMessageFmt, ...) {
|
||||
}
|
||||
typedef struct GfxDebugControlRec {
|
||||
uint32_t Version;
|
||||
uint32_t Size;
|
||||
uint32_t AssertEnableMask;
|
||||
uint32_t EnableDebugFileDump;
|
||||
uint32_t DebugEnableMask;
|
||||
uint32_t RingBufDbgMask;
|
||||
uint32_t ReportAssertEnable;
|
||||
uint32_t AssertBreakDisable;
|
||||
|
||||
} GFX_DEBUG_CONTROL, *PGFX_DEBUG_CONTROL;
|
||||
PGFX_DEBUG_CONTROL pDebugControl;
|
||||
}
|
||||
@@ -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"),
|
||||
|
||||
@@ -176,27 +176,27 @@ bool WddmCommandStreamReceiver<GfxFamily>::waitForFlushStamp(FlushStamp &flushSt
|
||||
|
||||
template <typename GfxFamily>
|
||||
GmmPageTableMngr *WddmCommandStreamReceiver<GfxFamily>::createPageTableManager() {
|
||||
GMM_DEVICE_CALLBACKS deviceCallbacks = {};
|
||||
GMM_DEVICE_CALLBACKS_INT deviceCallbacks = {};
|
||||
GMM_TRANSLATIONTABLE_CALLBACKS ttCallbacks = {};
|
||||
auto gdi = wddm->getGdi();
|
||||
|
||||
// clang-format off
|
||||
deviceCallbacks.Adapter = wddm->getAdapter();
|
||||
deviceCallbacks.hDevice = wddm->getDevice();
|
||||
deviceCallbacks.Adapter.KmtHandle = wddm->getAdapter();
|
||||
deviceCallbacks.hDevice.KmtHandle = wddm->getDevice();
|
||||
deviceCallbacks.PagingQueue = wddm->getPagingQueue();
|
||||
deviceCallbacks.PagingFence = wddm->getPagingQueueSyncObject();
|
||||
|
||||
deviceCallbacks.pfnAllocate = gdi->createAllocation;
|
||||
deviceCallbacks.pfnDeallocate = gdi->destroyAllocation;
|
||||
deviceCallbacks.pfnMapGPUVA = gdi->mapGpuVirtualAddress;
|
||||
deviceCallbacks.pfnMakeResident = gdi->makeResident;
|
||||
deviceCallbacks.pfnEvict = gdi->evict;
|
||||
deviceCallbacks.pfnReserveGPUVA = gdi->reserveGpuVirtualAddress;
|
||||
deviceCallbacks.pfnUpdateGPUVA = gdi->updateGpuVirtualAddress;
|
||||
deviceCallbacks.pfnWaitFromCpu = gdi->waitForSynchronizationObjectFromCpu;
|
||||
deviceCallbacks.pfnLock = gdi->lock2;
|
||||
deviceCallbacks.pfnUnLock = gdi->unlock2;
|
||||
deviceCallbacks.pfnEscape = gdi->escape;
|
||||
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnAllocate = gdi->createAllocation;
|
||||
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnDeallocate = gdi->destroyAllocation;
|
||||
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnMapGPUVA = gdi->mapGpuVirtualAddress;
|
||||
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnMakeResident = gdi->makeResident;
|
||||
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnEvict = gdi->evict;
|
||||
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnReserveGPUVA = gdi->reserveGpuVirtualAddress;
|
||||
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnUpdateGPUVA = gdi->updateGpuVirtualAddress;
|
||||
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnWaitFromCpu = gdi->waitForSynchronizationObjectFromCpu;
|
||||
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnLock = gdi->lock2;
|
||||
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnUnLock = gdi->unlock2;
|
||||
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnEscape = gdi->escape;
|
||||
|
||||
ttCallbacks.pfWriteL3Adr = TTCallbacks<GfxFamily>::writeL3Address;
|
||||
// clang-format on
|
||||
|
||||
Reference in New Issue
Block a user