Skip to content

Commit e46d919

Browse files
jbrodmanbader
authored andcommitted
Eliminate foundDevice var.
Signed-off-by: James Brodman <james.brodman@intel.com>
1 parent c68a611 commit e46d919

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

sycl/test/usm/findplatforms.hpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@ bool findPlatformAndDevice(cl_device_type deviceType,
99
cl_platform_id &platformOut, cl_device_id &deviceOut) {
1010
cl_uint numPlatforms;
1111
cl_int errorCode;
12-
bool foundDevice = false;
1312

1413
errorCode = clGetPlatformIDs(0, nullptr, &numPlatforms);
14+
if (errorCode != CL_SUCCESS) return false;
15+
1516
std::vector<cl_platform_id> platforms(numPlatforms);
1617
errorCode = clGetPlatformIDs(numPlatforms, platforms.data(), nullptr);
18+
if (errorCode != CL_SUCCESS) return false;
1719

1820
for (auto platform : platforms) {
19-
if (!foundDevice) {
20-
cl_uint numDevices = 0;
21-
errorCode =
22-
clGetDeviceIDs(platform, deviceType, 0, nullptr, &numDevices);
23-
if (errorCode != CL_SUCCESS) return false;
21+
cl_uint numDevices = 0;
22+
errorCode =
23+
clGetDeviceIDs(platform, deviceType, 0, nullptr, &numDevices);
24+
if (errorCode != CL_SUCCESS) return false;
2425

25-
std::vector<cl_device_id> devices(numDevices);
26-
errorCode = clGetDeviceIDs(platform, deviceType, numDevices,
27-
devices.data(), nullptr);
28-
if (errorCode != CL_SUCCESS) return false;
26+
std::vector<cl_device_id> devices(numDevices);
27+
errorCode = clGetDeviceIDs(platform, deviceType, numDevices,
28+
devices.data(), nullptr);
29+
if (errorCode != CL_SUCCESS) return false;
2930

30-
if (numDevices) {
31-
platformOut = platform;
32-
deviceOut = devices[0];
33-
foundDevice = true;
34-
}
31+
if (numDevices) {
32+
platformOut = platform;
33+
deviceOut = devices[0];
34+
return true;
3535
}
3636
}
3737

38-
return foundDevice;
38+
return false;
3939
}

0 commit comments

Comments
 (0)