- client: fix crash bug in CUDA init

svn path=/trunk/boinc/; revision=17856
This commit is contained in:
David Anderson 2009-04-22 03:59:39 +00:00
parent 5adb25381d
commit f9e1c98921
2 changed files with 12 additions and 5 deletions

View File

@ -4076,3 +4076,9 @@ David 21 Apr 2009
app_start.cpp app_start.cpp
lib/ lib/
coproc.cpp,h coproc.cpp,h
David 21 Apr 2009
- client: fix crash bug in CUDA init
lib/
coproc.cpp

View File

@ -174,16 +174,19 @@ void COPROC_CUDA::get(COPROCS& coprocs, vector<string>& strings) {
HMODULE cudalib = LoadLibrary("cudart.dll"); HMODULE cudalib = LoadLibrary("cudart.dll");
if (!cudalib) { if (!cudalib) {
strings.push_back("Can't load library cudart.dll"); strings.push_back("Can't load library cudart.dll");
return;
} }
__cudaGetDeviceCount = (PCGDC)GetProcAddress( cudalib, "cudaGetDeviceCount" ); __cudaGetDeviceCount = (PCGDC)GetProcAddress( cudalib, "cudaGetDeviceCount" );
if (!__cudaGetDeviceCount) { if (!__cudaGetDeviceCount) {
strings.push_back("Library doesn't have cudaGetDeviceCount()"); strings.push_back("Library doesn't have cudaGetDeviceCount()");
return;
} }
__cudaGetDeviceProperties = (PCGDP)GetProcAddress( cudalib, "cudaGetDeviceProperties" ); __cudaGetDeviceProperties = (PCGDP)GetProcAddress( cudalib, "cudaGetDeviceProperties" );
if (!__cudaGetDeviceProperties) { if (!__cudaGetDeviceProperties) {
strings.push_back("Library doesn't have cudaGetDeviceProperties()"); strings.push_back("Library doesn't have cudaGetDeviceProperties()");
return;
} }
#ifndef SIM #ifndef SIM
@ -222,19 +225,17 @@ void COPROC_CUDA::get(COPROCS& coprocs, vector<string>& strings) {
#endif #endif
if (!cudalib) { if (!cudalib) {
strings.push_back("Can't load library libcudart"); strings.push_back("Can't load library libcudart");
#ifdef _USING_FCGI_ return;
FCGI::perror("dlopen");
#else
std::perror("dlopen");
#endif
} }
__cudaGetDeviceCount = (void(*)(int*)) dlsym(cudalib, "cudaGetDeviceCount"); __cudaGetDeviceCount = (void(*)(int*)) dlsym(cudalib, "cudaGetDeviceCount");
if(!__cudaGetDeviceCount) { if(!__cudaGetDeviceCount) {
strings.push_back("Library doesn't have cudaGetDeviceCount()"); strings.push_back("Library doesn't have cudaGetDeviceCount()");
return;
} }
__cudaGetDeviceProperties = (void(*)(cudaDeviceProp*, int)) dlsym( cudalib, "cudaGetDeviceProperties" ); __cudaGetDeviceProperties = (void(*)(cudaDeviceProp*, int)) dlsym( cudalib, "cudaGetDeviceProperties" );
if (!__cudaGetDeviceProperties) { if (!__cudaGetDeviceProperties) {
strings.push_back("Library doesn't have cudaGetDeviceProperties()"); strings.push_back("Library doesn't have cudaGetDeviceProperties()");
return;
} }
#endif #endif