Skip to content

Commit c68a611

Browse files
jbrodmanbader
authored andcommitted
Simplify findplatforms logic.
Signed-off-by: James Brodman <james.brodman@intel.com>
1 parent 51595fc commit c68a611

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

sycl/test/usm/clext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int main(int argc, char** argv) {
4444
cl_platform_id platform;
4545
cl_device_id device;
4646

47-
if (!findPlatformAndDevice(deviceType, platform, device, errorCode)) {
47+
if (!findPlatformAndDevice(deviceType, platform, device)) {
4848
return 2;
4949
}
5050

sycl/test/usm/clusm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int main(int argc, char** argv) {
4646
cl_platform_id platform;
4747
cl_device_id device;
4848

49-
if (!findPlatformAndDevice(deviceType, platform, device, errorCode)) {
49+
if (!findPlatformAndDevice(deviceType, platform, device)) {
5050
return 2;
5151
}
5252

sycl/test/usm/findplatforms.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
//
77
//===----------------------------------------------------------------------===//
88
bool findPlatformAndDevice(cl_device_type deviceType,
9-
cl_platform_id &platformOut, cl_device_id &deviceOut,
10-
cl_int &errorCode) {
9+
cl_platform_id &platformOut, cl_device_id &deviceOut) {
1110
cl_uint numPlatforms;
11+
cl_int errorCode;
1212
bool foundDevice = false;
1313

1414
errorCode = clGetPlatformIDs(0, nullptr, &numPlatforms);
@@ -20,9 +20,13 @@ bool findPlatformAndDevice(cl_device_type deviceType,
2020
cl_uint numDevices = 0;
2121
errorCode =
2222
clGetDeviceIDs(platform, deviceType, 0, nullptr, &numDevices);
23+
if (errorCode != CL_SUCCESS) return false;
24+
2325
std::vector<cl_device_id> devices(numDevices);
2426
errorCode = clGetDeviceIDs(platform, deviceType, numDevices,
2527
devices.data(), nullptr);
28+
if (errorCode != CL_SUCCESS) return false;
29+
2630
if (numDevices) {
2731
platformOut = platform;
2832
deviceOut = devices[0];

0 commit comments

Comments
 (0)