client: Save all CUDA and CAL GPU info until done with OpenCL detection for use in OpenCL GPU descriptions

svn path=/trunk/boinc/; revision=25083
This commit is contained in:
Charlie Fenton 2012-01-17 14:06:27 +00:00
parent ecf6c103a3
commit 6c78358490
2 changed files with 55 additions and 37 deletions

View File

@ -629,3 +629,10 @@ Charlie 17 Jan 2012
BOINCGUIApp.cpp BOINCGUIApp.cpp
mac_installer/ mac_installer/
PosInstall.cpp PosInstall.cpp
Charlie 17 Jan 2012
- client: Save all CUDA and CAL GPU info until done with OpenCL detection
so we have available GPU RAM for all OpenCL GPU descriptions.
client/
coproc_detect.cpp

View File

@ -62,6 +62,9 @@ void segv_handler(int) {
} }
#endif #endif
vector<COPROC_ATI> ati_gpus;
vector<COPROC_NVIDIA> nvidia_gpus;
void COPROCS::get( void COPROCS::get(
bool use_all, vector<string>&descs, vector<string>&warnings, bool use_all, vector<string>&descs, vector<string>&warnings,
@ -109,6 +112,9 @@ void COPROCS::get(
} }
signal(SIGSEGV, old_sig); signal(SIGSEGV, old_sig);
#endif #endif
ati_gpus.clear();
nvidia_gpus.clear();
} }
@ -281,7 +287,6 @@ void COPROCS::get_opencl(
if (strstr(prop.vendor, GPU_TYPE_NVIDIA)) { if (strstr(prop.vendor, GPU_TYPE_NVIDIA)) {
prop.device_num = (int)(nvidia_opencls.size()); prop.device_num = (int)(nvidia_opencls.size());
prop.opencl_available_ram = prop.global_mem_size; // CUDA info may overwrite this
if (!nvidia.have_cuda) { if (!nvidia.have_cuda) {
COPROC_NVIDIA c; COPROC_NVIDIA c;
@ -289,6 +294,12 @@ void COPROCS::get_opencl(
c.set_peak_flops(); c.set_peak_flops();
prop.peak_flops = c.peak_flops; prop.peak_flops = c.peak_flops;
} }
if (nvidia_gpus.size()) {
// Assumes OpenCL and CAL return the same device with the same index
prop.opencl_available_ram = nvidia_gpus[prop.device_num].available_ram;
} else {
prop.opencl_available_ram = prop.global_mem_size;
}
nvidia_opencls.push_back(prop); nvidia_opencls.push_back(prop);
} }
if ((strstr(prop.vendor, GPU_TYPE_ATI)) || if ((strstr(prop.vendor, GPU_TYPE_ATI)) ||
@ -311,7 +322,6 @@ void COPROCS::get_opencl(
prop.global_mem_size *= 2; prop.global_mem_size *= 2;
} }
#endif #endif
prop.opencl_available_ram = prop.global_mem_size; // CAL info may overwrite this
if (!ati.have_cal) { if (!ati.have_cal) {
COPROC_ATI c; COPROC_ATI c;
@ -319,6 +329,12 @@ void COPROCS::get_opencl(
c.set_peak_flops(); c.set_peak_flops();
prop.peak_flops = c.peak_flops; prop.peak_flops = c.peak_flops;
} }
if (ati_gpus.size()) {
// Assumes OpenCL and CAL return the same device with the same index
prop.opencl_available_ram = ati_gpus[prop.device_num].available_ram;
} else {
prop.opencl_available_ram = prop.global_mem_size;
}
ati_opencls.push_back(prop); ati_opencls.push_back(prop);
} }
} }
@ -548,7 +564,6 @@ void COPROC::merge_opencl(
if (device_num == opencls[i].device_num) { if (device_num == opencls[i].device_num) {
opencl_prop = opencls[i]; opencl_prop = opencls[i];
opencl_device_ids[0] = opencls[i].device_id; opencl_device_ids[0] = opencls[i].device_id;
opencls[i].opencl_available_ram = available_ram;
have_opencl = true; have_opencl = true;
break; break;
} }
@ -556,8 +571,6 @@ void COPROC::merge_opencl(
// Fill in info for other GPUs which CAL or CUDA found equivalent to best // Fill in info for other GPUs which CAL or CUDA found equivalent to best
for (i=0; i<(unsigned int)count; ++i) { for (i=0; i<(unsigned int)count; ++i) {
opencl_device_ids[i] = opencls[device_nums[i]].device_id;
opencls[i].opencl_available_ram = available_ram;
opencls[device_nums[i]].is_used = COPROC_USED; opencls[device_nums[i]].is_used = COPROC_USED;
} }
opencl_device_count = count; opencl_device_count = count;
@ -845,7 +858,6 @@ void COPROC_NVIDIA::get(
return; return;
} }
vector<COPROC_NVIDIA> gpus;
retval = (*__cuDeviceGetCount)(&cuda_ndevs); retval = (*__cuDeviceGetCount)(&cuda_ndevs);
if (retval) { if (retval) {
sprintf(buf, "cuDeviceGetCount() returned %d", retval); sprintf(buf, "cuDeviceGetCount() returned %d", retval);
@ -908,10 +920,10 @@ void COPROC_NVIDIA::get(
cc.device_num = j; cc.device_num = j;
cc.set_peak_flops(); cc.set_peak_flops();
cc.get_available_ram(); cc.get_available_ram();
gpus.push_back(cc); nvidia_gpus.push_back(cc);
} }
if (!gpus.size()) { if (!nvidia_gpus.size()) {
warnings.push_back("No CUDA-capable NVIDIA GPUs found"); warnings.push_back("No CUDA-capable NVIDIA GPUs found");
return; return;
} }
@ -919,13 +931,13 @@ void COPROC_NVIDIA::get(
// identify the most capable non-ignored instance // identify the most capable non-ignored instance
// //
bool first = true; bool first = true;
for (i=0; i<gpus.size(); i++) { for (i=0; i<nvidia_gpus.size(); i++) {
if (in_vector(gpus[i].device_num, ignore_devs)) continue; if (in_vector(nvidia_gpus[i].device_num, ignore_devs)) continue;
if (first) { if (first) {
*this = gpus[i]; *this = nvidia_gpus[i];
first = false; first = false;
} else if (nvidia_compare(gpus[i], *this, false) > 0) { } else if (nvidia_compare(nvidia_gpus[i], *this, false) > 0) {
*this = gpus[i]; *this = nvidia_gpus[i];
} }
} }
@ -933,17 +945,17 @@ void COPROC_NVIDIA::get(
// and set the "count" and "device_nums" fields // and set the "count" and "device_nums" fields
// //
count = 0; count = 0;
for (i=0; i<gpus.size(); i++) { for (i=0; i<nvidia_gpus.size(); i++) {
char buf2[256]; char buf2[256];
gpus[i].description(buf); nvidia_gpus[i].description(buf);
if (in_vector(gpus[i].device_num, ignore_devs)) { if (in_vector(nvidia_gpus[i].device_num, ignore_devs)) {
sprintf(buf2, "NVIDIA GPU %d (ignored by config): %s", gpus[i].device_num, buf); sprintf(buf2, "NVIDIA GPU %d (ignored by config): %s", nvidia_gpus[i].device_num, buf);
} else if (use_all || !nvidia_compare(gpus[i], *this, true)) { } else if (use_all || !nvidia_compare(nvidia_gpus[i], *this, true)) {
device_nums[count] = gpus[i].device_num; device_nums[count] = nvidia_gpus[i].device_num;
count++; count++;
sprintf(buf2, "NVIDIA GPU %d: %s", gpus[i].device_num, buf); sprintf(buf2, "NVIDIA GPU %d: %s", nvidia_gpus[i].device_num, buf);
} else { } else {
sprintf(buf2, "NVIDIA GPU %d (not used): %s", gpus[i].device_num, buf); sprintf(buf2, "NVIDIA GPU %d (not used): %s", nvidia_gpus[i].device_num, buf);
} }
descs.push_back(string(buf2)); descs.push_back(string(buf2));
} }
@ -1243,7 +1255,6 @@ void COPROC_ATI::get(
COPROC_ATI cc, cc2; COPROC_ATI cc, cc2;
string s, gpu_name; string s, gpu_name;
vector<COPROC_ATI> gpus;
for (CALuint i=0; i<numDevices; i++) { for (CALuint i=0; i<numDevices; i++) {
retval = (*__calDeviceGetInfo)(&info, i); retval = (*__calDeviceGetInfo)(&info, i);
if (retval != CAL_RESULT_OK) { if (retval != CAL_RESULT_OK) {
@ -1348,14 +1359,14 @@ void COPROC_ATI::get(
cc.device_num = i; cc.device_num = i;
cc.set_peak_flops(); cc.set_peak_flops();
cc.get_available_ram(); cc.get_available_ram();
gpus.push_back(cc); ati_gpus.push_back(cc);
} }
// shut down CAL, otherwise Lenovo won't be able to switch to low-power GPU // shut down CAL, otherwise Lenovo won't be able to switch to low-power GPU
// //
retval = (*__calShutdown)(); retval = (*__calShutdown)();
if (!gpus.size()) { if (!ati_gpus.size()) {
warnings.push_back("No ATI GPUs found"); warnings.push_back("No ATI GPUs found");
return; return;
} }
@ -1364,13 +1375,13 @@ void COPROC_ATI::get(
// //
bool first = true; bool first = true;
unsigned int i; unsigned int i;
for (i=0; i<gpus.size(); i++) { for (i=0; i<ati_gpus.size(); i++) {
if (in_vector(gpus[i].device_num, ignore_devs)) continue; if (in_vector(ati_gpus[i].device_num, ignore_devs)) continue;
if (first) { if (first) {
*this = gpus[i]; *this = ati_gpus[i];
first = false; first = false;
} else if (ati_compare(gpus[i], *this, false) > 0) { } else if (ati_compare(ati_gpus[i], *this, false) > 0) {
*this = gpus[i]; *this = ati_gpus[i];
} }
} }
@ -1378,17 +1389,17 @@ void COPROC_ATI::get(
// and set the "count" and "device_nums" fields // and set the "count" and "device_nums" fields
// //
count = 0; count = 0;
for (i=0; i<gpus.size(); i++) { for (i=0; i<ati_gpus.size(); i++) {
char buf2[256]; char buf2[256];
gpus[i].description(buf); ati_gpus[i].description(buf);
if (in_vector(gpus[i].device_num, ignore_devs)) { if (in_vector(ati_gpus[i].device_num, ignore_devs)) {
sprintf(buf2, "ATI GPU %d (ignored by config): %s", gpus[i].device_num, buf); sprintf(buf2, "ATI GPU %d (ignored by config): %s", ati_gpus[i].device_num, buf);
} else if (use_all || !ati_compare(gpus[i], *this, true)) { } else if (use_all || !ati_compare(ati_gpus[i], *this, true)) {
device_nums[count] = gpus[i].device_num; device_nums[count] = ati_gpus[i].device_num;
count++; count++;
sprintf(buf2, "ATI GPU %d: %s", gpus[i].device_num, buf); sprintf(buf2, "ATI GPU %d: %s", ati_gpus[i].device_num, buf);
} else { } else {
sprintf(buf2, "ATI GPU %d: (not used) %s", gpus[i].device_num, buf); sprintf(buf2, "ATI GPU %d: (not used) %s", ati_gpus[i].device_num, buf);
} }
descs.push_back(string(buf2)); descs.push_back(string(buf2));
} }