From 5e5ff5f08d4a810ea1b8f690d0af7c1afbfc9d4b Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Mon, 21 Apr 2014 13:52:09 -0500 Subject: [PATCH] Make get_devices() return an empty list instead of erroring out (reported by Tomasz Rybak) --- src/wrapper/wrap_cl.hpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/wrapper/wrap_cl.hpp b/src/wrapper/wrap_cl.hpp index 0ec76c30..02ba206d 100644 --- a/src/wrapper/wrap_cl.hpp +++ b/src/wrapper/wrap_cl.hpp @@ -848,8 +848,16 @@ namespace pyopencl inline py::list 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); + } + if (num_devices == 0) return py::list(); -- GitLab