Skip to content

Commit

Permalink
Fix issue with platforms with no devices
Browse files Browse the repository at this point in the history
The documentation for clGetDeviceIDs states that if the "devices"
pointer is not NULL, then "num_entries" must be greater than zero. In
platforms with no devices this would be the case, but the code in the
C++ bindings wasn't handling the case correctly.

Signed-off-by: Rodrigo Tobar <[email protected]>
  • Loading branch information
rtobar committed Jul 10, 2024
1 parent e08bed4 commit f4e7ca8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/profit/cl/cl2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2347,6 +2347,10 @@ class Platform : public detail::Wrapper<cl_platform_id>
if (err != CL_SUCCESS) {
return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
}
if (n == 0) {
devices->clear();
return CL_SUCCESS;
}

vector<cl_device_id> ids(n);
err = ::clGetDeviceIDs(object_, type, n, ids.data(), NULL);
Expand Down

0 comments on commit f4e7ca8

Please sign in to comment.