P4 to Git Change 1395773 by gandryey@gera-w8 on 2017/04/07 14:31:02
SWDEV-118182 - OpenCL runtime picks up wrong DLL if AMD APP SDK is installed - Check the path of the base loaded dll before attempting the default location http://ocltc.amd.com/reviews/r/12572/ Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#566 edit ... //depot/stg/opencl/drivers/opencl/runtime/os/os.cpp#7 edit
Этот коммит содержится в:
@@ -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");
|
||||
@@ -978,7 +977,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
|
||||
|
||||
|
||||
@@ -24,10 +24,7 @@ namespace amd {
|
||||
void*
|
||||
Os::loadLibrary(const char* libraryname)
|
||||
{
|
||||
void* handle = Os::loadLibrary_(libraryname);
|
||||
if (handle != NULL) {
|
||||
return handle;
|
||||
}
|
||||
void* handle;
|
||||
|
||||
// Try with the system library prefix and extension instead.
|
||||
std::string str = libraryname;
|
||||
@@ -35,6 +32,39 @@ Os::loadLibrary(const char* libraryname)
|
||||
size_t namestart = str.rfind(fileSeparator());
|
||||
namestart = (namestart != std::string::npos) ? namestart + 1 : 0;
|
||||
|
||||
if (namestart == 0) {
|
||||
#if defined(ATI_OS_WIN)
|
||||
// Try with the path of the current loaded dll(OCL runtime) first
|
||||
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
|
||||
}
|
||||
|
||||
handle = Os::loadLibrary_(libraryname);
|
||||
if (handle != NULL) {
|
||||
return handle;
|
||||
}
|
||||
|
||||
const char* prefix = Os::libraryPrefix();
|
||||
if (prefix != NULL
|
||||
&& str.compare(namestart, strlen(prefix), prefix) == 0) {
|
||||
@@ -59,32 +89,6 @@ 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());
|
||||
|
||||
Ссылка в новой задаче
Block a user