Browse Source

Cope with the highest opencl platform not having usable devices.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
87b62bde43
  1. 7
      ocl.c

7
ocl.c

@ -78,9 +78,10 @@ int clDevicesNum(void) {
char pbuff[256]; char pbuff[256];
cl_uint numDevices; cl_uint numDevices;
cl_uint numPlatforms; cl_uint numPlatforms;
int most_devices = -1;
cl_platform_id *platforms; cl_platform_id *platforms;
cl_platform_id platform = NULL; cl_platform_id platform = NULL;
unsigned int most_devices = 0, i, mdplatform = 0; unsigned int i, mdplatform = 0;
status = clGetPlatformIDs(0, NULL, &numPlatforms); status = clGetPlatformIDs(0, NULL, &numPlatforms);
/* If this fails, assume no GPUs. */ /* If this fails, assume no GPUs. */
@ -118,12 +119,10 @@ int clDevicesNum(void) {
status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, NULL, &numDevices); status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, NULL, &numDevices);
if (status != CL_SUCCESS) { if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error %d: Getting Device IDs (num)", status); applog(LOG_ERR, "Error %d: Getting Device IDs (num)", status);
if (i < numPlatforms - 1)
continue; continue;
return -1;
} }
applog(LOG_INFO, "Platform %d devices: %d", i, numDevices); applog(LOG_INFO, "Platform %d devices: %d", i, numDevices);
if (numDevices > most_devices) { if ((int)numDevices > most_devices) {
most_devices = numDevices; most_devices = numDevices;
mdplatform = i; mdplatform = i;
} }

Loading…
Cancel
Save