Skip to content

Commit db6839d

Browse files
Fixed GetNumDevices tests, added support for conversion of DPCTL_ALL_BACKENDS to sycl
1 parent caa5e5a commit db6839d

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

libsyclinterface/helper/source/dpctl_utils_helper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ backend DPCTL_DPCTLBackendTypeToSyclBackend(DPCTLSyclBackendType BeTy)
9696
return backend::level_zero;
9797
case DPCTLSyclBackendType::DPCTL_OPENCL:
9898
return backend::opencl;
99+
case DPCTLSyclBackendType::DPCTL_ALL_BACKENDS:
100+
return backend::all;
99101
default:
100102
throw std::runtime_error("Unsupported backend type");
101103
}

libsyclinterface/tests/test_sycl_device_manager.cpp

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,23 @@ INSTANTIATE_TEST_SUITE_P(
139139

140140
struct TestGetNumDevicesForDTy : public ::testing::TestWithParam<int>
141141
{
142-
size_t nDevices = 0;
142+
int param;
143+
sycl::info::device_type sycl_dty;
144+
143145
TestGetNumDevicesForDTy()
144146
{
145-
cl::sycl::info::device_type sycl_dty =
146-
DPCTL_DPCTLDeviceTypeToSyclDeviceType(
147-
DPCTLSyclDeviceType(GetParam()));
148-
149-
auto devices = cl::sycl::device::get_devices(sycl_dty);
150-
EXPECT_TRUE(devices.size() == DPCTLDeviceMgr_GetNumDevices(GetParam()));
147+
param = GetParam();
148+
DPCTLSyclDeviceType DTy = DPCTLSyclDeviceType(param);
149+
sycl_dty = DPCTL_DPCTLDeviceTypeToSyclDeviceType(DTy);
151150
}
152151
};
153152

153+
TEST_P(TestGetNumDevicesForDTy, ChkGetNumDevices)
154+
{
155+
auto devices = sycl::device::get_devices(sycl_dty);
156+
EXPECT_TRUE(devices.size() == DPCTLDeviceMgr_GetNumDevices(param));
157+
}
158+
154159
INSTANTIATE_TEST_SUITE_P(
155160
GetDevices,
156161
TestGetNumDevicesForDTy,
@@ -162,23 +167,29 @@ INSTANTIATE_TEST_SUITE_P(
162167

163168
struct TestGetNumDevicesForBTy : public ::testing::TestWithParam<int>
164169
{
165-
size_t nDevices = 0;
170+
int param;
171+
sycl::backend sycl_bty;
166172
TestGetNumDevicesForBTy()
167173
{
168-
cl::sycl::backend sycl_bty = DPCTL_DPCTLBackendTypeToSyclBackend(
169-
DPCTLSyclBackendType(GetParam()));
170-
171-
auto platforms = cl::sycl::platform::get_platforms();
172-
for (const auto &P : platforms) {
173-
if (P.get_backend() == sycl_bty) {
174-
auto devices = P.get_devices();
175-
EXPECT_TRUE(devices.size() ==
176-
DPCTLDeviceMgr_GetNumDevices(GetParam()));
177-
}
178-
}
174+
param = GetParam();
175+
sycl_bty =
176+
DPCTL_DPCTLBackendTypeToSyclBackend(DPCTLSyclBackendType(param));
179177
}
180178
};
181179

180+
TEST_P(TestGetNumDevicesForBTy, ChkGetNumDevices)
181+
{
182+
auto platforms = cl::sycl::platform::get_platforms();
183+
size_t nDevices = 0;
184+
for (const auto &P : platforms) {
185+
if ((P.get_backend() == sycl_bty) || (sycl_bty == sycl::backend::all)) {
186+
auto devices = P.get_devices();
187+
nDevices += devices.size();
188+
}
189+
}
190+
EXPECT_TRUE(nDevices == DPCTLDeviceMgr_GetNumDevices(param));
191+
}
192+
182193
INSTANTIATE_TEST_SUITE_P(
183194
GetDevices,
184195
TestGetNumDevicesForBTy,

0 commit comments

Comments
 (0)