Skip to content

Commit

Permalink
Make get_devices() return an empty list instead of erroring out (repo…
Browse files Browse the repository at this point in the history
…rted by Tomasz Rybak)
  • Loading branch information
inducer committed Apr 21, 2014
1 parent 89282bb commit 5e5ff5f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/wrapper/wrap_cl.hpp
Expand Up @@ -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();

Expand Down

0 comments on commit 5e5ff5f

Please sign in to comment.