Skip to content

Commit

Permalink
Fix logic for finding suitable opencl device
Browse files Browse the repository at this point in the history
  • Loading branch information
Beanavil committed Oct 3, 2024
1 parent 56cdc27 commit 294d0bc
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions samples/extensions/khr/externalmemory/vulkan_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@
#include <stdlib.h>
#include <string.h>

// Check if
#define CL_CHECK_NO_DEVICE(func, err, label) \
do \
{ \
err = func; \
if (err != CL_SUCCESS) goto label; \
} while (0)


// Check if the provided Vulkan error code is \p VK_SUCCESS. If not, prints an
// error message to the standard error output and terminates the program with an
// error code.
Expand Down Expand Up @@ -241,10 +250,14 @@ find_suitable_device(VkInstance instance,
++platform_id)
{
cl_uint cl_platform_devices_count = 0;
OCLERROR_RET(clGetDeviceIDs(platforms[platform_id],
CL_DEVICE_TYPE_ALL, 0, NULL,
&cl_platform_devices_count),
error, platforms);
error = clGetDeviceIDs(platforms[platform_id], CL_DEVICE_TYPE_ALL, 0,
NULL, &cl_platform_devices_count);
// Some platforms may not have any suitable device. Allow the CL_DEVICE_NOT_FOUND
// error so that other platforms can be checked.
if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND)
{
goto platforms;
}
for (cl_uint device_id = 0; device_id < cl_platform_devices_count;
++device_id)
{
Expand Down

0 comments on commit 294d0bc

Please sign in to comment.