Skip to content

Commit 780296c

Browse files
committed
Fix logic for finding suitable opencl device
1 parent 32163b9 commit 780296c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

samples/extensions/khr/externalmemory/vulkan_utils.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,14 @@ find_suitable_device(VkInstance instance,
241241
++platform_id)
242242
{
243243
cl_uint cl_platform_devices_count = 0;
244-
OCLERROR_RET(clGetDeviceIDs(platforms[platform_id],
245-
CL_DEVICE_TYPE_ALL, 0, NULL,
246-
&cl_platform_devices_count),
247-
error, platforms);
244+
error = clGetDeviceIDs(platforms[platform_id], CL_DEVICE_TYPE_ALL, 0,
245+
NULL, &cl_platform_devices_count);
246+
// Some platforms may not have any suitable device. Allow the CL_DEVICE_NOT_FOUND
247+
// error so that other platforms can be checked.
248+
if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND)
249+
{
250+
goto platforms;
251+
}
248252
for (cl_uint device_id = 0; device_id < cl_platform_devices_count;
249253
++device_id)
250254
{

0 commit comments

Comments
 (0)