API: return CL_INVALID_DEVICE from boinc_get_opencl_ids() if init_data.xml passes a value for gpu_opencl_dev_index which does not correspond to an OpenCL capable device.

This commit is contained in:
Charlie Fenton 2014-05-01 02:16:28 -07:00
parent 3752906ba8
commit c42457f305
1 changed files with 15 additions and 11 deletions

View File

@ -110,24 +110,28 @@ int boinc_get_opencl_ids_aux(
// Use gpu_opencl_dev_index if available
if (opencl_device_index >= 0) {
if (opencl_device_index < (int)num_devices) {
device_id = devices[opencl_device_index];
retval = get_vendor(device_id, vendor, sizeof(vendor));
if (retval != CL_SUCCESS) continue;
if (!strcmp(vendor, type)) {
*device = device_id;
*platform = platforms[platform_index];
return 0;
}
if (opencl_device_index >= (int)num_devices) {
fprintf(stderr, "Invalid OpenCL GPU index: %d \n", opencl_device_index);
return CL_INVALID_DEVICE;
}
device_id = devices[opencl_device_index];
retval = get_vendor(device_id, vendor, sizeof(vendor));
if (retval != CL_SUCCESS) continue;
if (!strcmp(vendor, type)) {
*device = device_id;
*platform = platforms[platform_index];
return 0;
}
}
continue;
}
// Older versions of init_data.xml don't have gpu_opencl_dev_index field
// NOTE: This may return the wrong device on older versions of BOINC if
// OpenCL does not recognize all GPU models detected by CUDA
// OpenCL does not recognize all GPU models detected by CUDA or CAL
for (device_index=0; device_index<(int)num_devices; ++device_index) {
device_id = devices[device_index];