Skip to content

Commit

Permalink
opencl: Fix runtime crash when no device was found
Browse files Browse the repository at this point in the history
The native CPU is always available and needs an initialized profile.

Signed-off-by: Stefan Weil <stefan.weil@bib.uni-mannheim.de>
  • Loading branch information
stweil committed Dec 12, 2016
1 parent 9234b4c commit aa964b5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions opencl/opencl_device_selection.h
Expand Up @@ -119,13 +119,13 @@ static ds_status initDSProfile(ds_profile** p, const char* version) {
clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, 0, nullptr, &num);
numDevices+=num;
}
if (numDevices == 0)
goto cleanup;

devices = (cl_device_id*)malloc(numDevices*sizeof(cl_device_id));
if (devices == nullptr) {
status = DS_MEMORY_ERROR;
goto cleanup;

if (numDevices > 0) {
devices = (cl_device_id*)malloc(numDevices*sizeof(cl_device_id));
if (devices == nullptr) {
status = DS_MEMORY_ERROR;
goto cleanup;
}
}

profile->numDevices = numDevices+1; // +1 to numDevices to include the native CPU
Expand Down

0 comments on commit aa964b5

Please sign in to comment.