Skip to content

Commit aa964b5

Browse files
committed
opencl: Fix runtime crash when no device was found
The native CPU is always available and needs an initialized profile. Signed-off-by: Stefan Weil <stefan.weil@bib.uni-mannheim.de>
1 parent 9234b4c commit aa964b5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

opencl/opencl_device_selection.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ static ds_status initDSProfile(ds_profile** p, const char* version) {
119119
clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, 0, nullptr, &num);
120120
numDevices+=num;
121121
}
122-
if (numDevices == 0)
123-
goto cleanup;
124-
125-
devices = (cl_device_id*)malloc(numDevices*sizeof(cl_device_id));
126-
if (devices == nullptr) {
127-
status = DS_MEMORY_ERROR;
128-
goto cleanup;
122+
123+
if (numDevices > 0) {
124+
devices = (cl_device_id*)malloc(numDevices*sizeof(cl_device_id));
125+
if (devices == nullptr) {
126+
status = DS_MEMORY_ERROR;
127+
goto cleanup;
128+
}
129129
}
130130

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

0 commit comments

Comments
 (0)