Explicitly check for nvidia in opencl platform strings as well.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
diff --git a/ocl.c b/ocl.c
index cebc3bd..525cf98 100644
--- a/ocl.c
+++ b/ocl.c
@@ -69,10 +69,11 @@ char *file_contents(const char *filename, int *length)
}
int clDevicesNum() {
- cl_int status = 0;
-
+ cl_int status;
+ cl_uint numDevices;
cl_uint numPlatforms;
cl_platform_id platform = NULL;
+
status = clGetPlatformIDs(0, NULL, &numPlatforms);
/* If this fails, assume no GPUs. */
if (status != CL_SUCCESS) {
@@ -82,28 +83,27 @@ int clDevicesNum() {
if (numPlatforms > 0) {
cl_platform_id* platforms = (cl_platform_id *)malloc(numPlatforms*sizeof(cl_platform_id));
+ unsigned int i;
+
status = clGetPlatformIDs(numPlatforms, platforms, NULL);
- if (status != CL_SUCCESS)
- {
+ if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error: Getting Platform Ids. (clGetPlatformsIDs)");
return -1;
}
- unsigned int i;
for (i = 0; i < numPlatforms; ++i) {
- char pbuff[100];
+ char pbuff[256];
+
status = clGetPlatformInfo( platforms[i], CL_PLATFORM_VENDOR, sizeof(pbuff), pbuff, NULL);
- if (status != CL_SUCCESS)
- {
+ if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error: Getting Platform Info. (clGetPlatformInfo)");
free(platforms);
return -1;
}
platform = platforms[i];
- if (!strcmp(pbuff, "Advanced Micro Devices, Inc."))
- {
+ if (!strcmp(pbuff, "Advanced Micro Devices, Inc.") ||
+ !strcmp(pbuff, "NVIDIA Corporation"))
break;
- }
}
free(platforms);
}
@@ -113,7 +113,6 @@ int clDevicesNum() {
return -1;
}
- cl_uint numDevices;
status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, NULL, &numDevices);
if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error: Getting Device IDs (num)");
@@ -185,14 +184,15 @@ void patch_opcodes(char *w, unsigned remaining)
_clState *initCl(unsigned int gpu, char *name, size_t nameSize)
{
+ _clState *clState = calloc(1, sizeof(_clState));
bool patchbfi = false, prog_built = false;
- cl_int status = 0;
+ cl_platform_id platform = NULL;
+ cl_device_id *devices;
+ cl_uint numPlatforms;
+ cl_uint numDevices;
unsigned int i;
+ cl_int status;
- _clState *clState = calloc(1, sizeof(_clState));
-
- cl_uint numPlatforms;
- cl_platform_id platform = NULL;
status = clGetPlatformIDs(0, NULL, &numPlatforms);
if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error: Getting Platforms. (clGetPlatformsIDs)");
@@ -201,27 +201,26 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
if (numPlatforms > 0) {
cl_platform_id* platforms = (cl_platform_id *)malloc(numPlatforms*sizeof(cl_platform_id));
+
status = clGetPlatformIDs(numPlatforms, platforms, NULL);
- if (status != CL_SUCCESS)
- {
+ if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error: Getting Platform Ids. (clGetPlatformsIDs)");
return NULL;
}
for(i = 0; i < numPlatforms; ++i) {
char pbuff[100];
+
status = clGetPlatformInfo( platforms[i], CL_PLATFORM_VENDOR, sizeof(pbuff), pbuff, NULL);
- if (status != CL_SUCCESS)
- {
+ if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error: Getting Platform Info. (clGetPlatformInfo)");
free(platforms);
return NULL;
}
platform = platforms[i];
- if (!strcmp(pbuff, "Advanced Micro Devices, Inc."))
- {
+ if (!strcmp(pbuff, "Advanced Micro Devices, Inc.") ||
+ !strcmp(pbuff, "NVIDIA Corporation"))
break;
- }
}
free(platforms);
}
@@ -231,14 +230,12 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
return NULL;
}
- cl_uint numDevices;
status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, NULL, &numDevices);
if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error: Getting Device IDs (num)");
return NULL;
}
- cl_device_id *devices;
if (numDevices > 0 ) {
devices = (cl_device_id *)malloc(numDevices*sizeof(cl_device_id));