Cope with the highest opencl platform not having usable devices.
diff --git a/ocl.c b/ocl.c
index 018985d..dc5b9a0 100644
--- a/ocl.c
+++ b/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;
}