From e34c9738c8823baf772f2d05367e96e8a2aa0fdc Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Sat, 10 May 2014 19:28:36 -0500 Subject: [PATCH] Make get_devices() return an empty list instead of erroring out (reported by Tomasz Rybak on the master branch) --- src/c_wrapper/wrap_cl.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/c_wrapper/wrap_cl.cpp b/src/c_wrapper/wrap_cl.cpp index 02c2526e..1c89e94c 100644 --- a/src/c_wrapper/wrap_cl.cpp +++ b/src/c_wrapper/wrap_cl.cpp @@ -463,8 +463,15 @@ namespace pyopencl inline std::vector<cl_device_id> platform::get_devices(cl_device_type devtype) { cl_uint num_devices = 0; - PYOPENCL_CALL_GUARDED(clGetDeviceIDs, - (m_platform, devtype, 0, 0, &num_devices)); + PYOPENCL_PRINT_CALL_TRACE("clGetDeviceIDs"); + { + cl_int status_code; + status_code = clGetDeviceIDs(m_platform, devtype, 0, 0, &num_devices); + if (status_code == CL_DEVICE_NOT_FOUND) + num_devices = 0; + else if (status_code != CL_SUCCESS) \ + throw pyopencl::error("clGetDeviceIDs", status_code); + } std::vector<cl_device_id> devices(num_devices); if (num_devices == 0) -- GitLab