Browse Source

Cope with the highest opencl platform not having usable devices.

Con Kolivas 13 years ago
parent
commit
87b62bde43
1 changed files with 4 additions and 5 deletions
  1. 4 5
      ocl.c

+ 4 - 5
ocl.c

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