1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-23 04:54:26 +00:00

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.
This commit is contained in:
Rusty Russell 2011-07-06 16:47:29 +09:30
parent 8b68dc44d4
commit efebee5ab8
2 changed files with 6 additions and 2 deletions

3
main.c
View File

@ -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
View File

@ -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)