From 8618ed31ca486da20dc777eca50ecd70352ba31e Mon Sep 17 00:00:00 2001 From: foreman Date: Fri, 20 Jan 2017 19:20:32 -0500 Subject: [PATCH] P4 to Git Change 1364611 by asalmanp@asalmanp-opencl-stg on 2017/01/20 19:12:14 SWDEV-111478 - [Vega] Clinfo doesn't report the CPU as a CL device. amdocl12cl64.dll is not loaded in Windows 10 (RS1) because the driverstore path wasn't searched to load for this module. Added the path to fix this issue. ReviewBoardURL = http://ocltc.amd.com/reviews/r/12211/ Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#563 edit ... //depot/stg/opencl/drivers/opencl/runtime/os/os.cpp#6 edit --- rocclr/runtime/device/gpu/gpudevice.cpp | 2 -- rocclr/runtime/os/os.cpp | 26 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/rocclr/runtime/device/gpu/gpudevice.cpp b/rocclr/runtime/device/gpu/gpudevice.cpp index 440c31db8a..d98e3464b2 100644 --- a/rocclr/runtime/device/gpu/gpudevice.cpp +++ b/rocclr/runtime/device/gpu/gpudevice.cpp @@ -183,7 +183,6 @@ NullDevice::create(CALtarget target) if (NULL == compiler_) { #if !defined(ATI_OS_LINUX) char CompilerLibrary[220] = ""; - strcpy_s(CompilerLibrary, calAttr.driverStore); strcat_s(CompilerLibrary, "amdocl12cl" LP64_SWITCH("", "64") ".dll"); #endif const char *library = getenv("COMPILER_LIBRARY"); @@ -969,7 +968,6 @@ Device::create(CALuint ordinal, CALuint numOfDevices) if (NULL == compiler_) { #if !defined(ATI_OS_LINUX) char CompilerLibrary[220] = ""; - strcpy_s(CompilerLibrary, getAttribs().driverStore); strcat_s(CompilerLibrary, "amdocl12cl" LP64_SWITCH("", "64") ".dll"); #endif diff --git a/rocclr/runtime/os/os.cpp b/rocclr/runtime/os/os.cpp index 0f01f31902..c9a28aa458 100644 --- a/rocclr/runtime/os/os.cpp +++ b/rocclr/runtime/os/os.cpp @@ -59,6 +59,32 @@ Os::loadLibrary(const char* libraryname) return handle; } +#if defined(ATI_OS_WIN) + // Try with the DriverStore path + HMODULE hm = NULL; + if (!GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS + | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (LPCSTR)&loadLibrary, &hm)) return NULL; + + char cszDllPath[1024] = { 0 }; + if (!GetModuleFileNameA(hm, cszDllPath, sizeof(cszDllPath))) + return NULL; + + LPSTR cszFileName; + char buffer[1024] = { 0 }; + if (!GetFullPathNameA(cszDllPath, sizeof(buffer), buffer, &cszFileName)) + return NULL; + + std::string newPath; + newPath = cszDllPath; + newPath.replace(newPath.find(cszFileName), strlen(libraryname), libraryname); + + handle = Os::loadLibrary_(newPath.c_str()); + if (handle != NULL) { + return handle; + } +#endif + // Try to find the lib in the current directory. return Os::loadLibrary((std::string(".") + fileSeparator() + std::string(libraryname)).c_str());