Browse Source

Fix the case where there are no GPUs, and exit if they give errors.

If there are no GPUs, set nDevs to 0 not -1 (status is set to an
unhelpful -1001 here on my laptop, so we can't rely on a particular
status value).

Also, if nDevs is -1, exit rather than screwing up later.
nfactor-troky
Rusty Russell 14 years ago
parent
commit
efebee5ab8
  1. 3
      main.c
  2. 5
      ocl.c

3
main.c

@ -1458,6 +1458,9 @@ int main (int argc, char *argv[])
#ifdef HAVE_OPENCL #ifdef HAVE_OPENCL
nDevs = clDevicesNum(); nDevs = clDevicesNum();
if (nDevs < 0)
return 1;
#endif #endif
if (nDevs) if (nDevs)
opt_n_threads = 0; opt_n_threads = 0;

5
ocl.c

@ -58,10 +58,11 @@ int clDevicesNum() {
cl_uint numPlatforms; cl_uint numPlatforms;
cl_platform_id platform = NULL; cl_platform_id platform = NULL;
status = clGetPlatformIDs(0, NULL, &numPlatforms); status = clGetPlatformIDs(0, NULL, &numPlatforms);
/* If this fails, assume no GPUs. */
if (status != CL_SUCCESS) if (status != CL_SUCCESS)
{ {
applog(LOG_ERR, "Error: Getting Platforms. (clGetPlatformsIDs)"); applog(LOG_INFO, "clGetPlatformsIDs failed (no GPU?)");
return -1; return 0;
} }
if (numPlatforms > 0) if (numPlatforms > 0)

Loading…
Cancel
Save