Cherry pick 5c6b85 from KhronosGroup/OpenCL-CLHPP
Updates cl2.hpp and cl.hpp to handle case of platform with zero devices without error. Change-Id: I6190c65ebf894b3a26579c54e96881c334346358
This commit is contained in:
committed by
Vladislav Sytchenko
orang tua
17d5d73ff2
melakukan
0779b034c4
@@ -2240,17 +2240,22 @@ public:
|
||||
return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
|
||||
}
|
||||
cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
|
||||
if (err != CL_SUCCESS) {
|
||||
if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {
|
||||
return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
|
||||
}
|
||||
|
||||
cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id));
|
||||
err = ::clGetDeviceIDs(object_, type, n, ids, NULL);
|
||||
if (err != CL_SUCCESS) {
|
||||
return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
|
||||
if (n > 0) {
|
||||
cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id));
|
||||
err = ::clGetDeviceIDs(object_, type, n, ids, NULL);
|
||||
if (err != CL_SUCCESS) {
|
||||
return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
|
||||
}
|
||||
|
||||
devices->assign(&ids[0], &ids[n]);
|
||||
} else {
|
||||
devices->clear();
|
||||
}
|
||||
|
||||
devices->assign(&ids[0], &ids[n]);
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -2349,14 +2349,16 @@ public:
|
||||
return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
|
||||
}
|
||||
cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
|
||||
if (err != CL_SUCCESS) {
|
||||
if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {
|
||||
return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
|
||||
}
|
||||
|
||||
vector<cl_device_id> ids(n);
|
||||
err = ::clGetDeviceIDs(object_, type, n, ids.data(), NULL);
|
||||
if (err != CL_SUCCESS) {
|
||||
return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
|
||||
if (n>0) {
|
||||
err = ::clGetDeviceIDs(object_, type, n, ids.data(), NULL);
|
||||
if (err != CL_SUCCESS) {
|
||||
return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
// Cannot trivially assign because we need to capture intermediates
|
||||
|
||||
Reference in New Issue
Block a user