@@ -137,6 +137,57 @@ INSTANTIATE_TEST_SUITE_P(
137
137
DPCTLSyclBackendType::DPCTL_OPENCL |
138
138
DPCTLSyclDeviceType::DPCTL_GPU));
139
139
140
+ struct TestGetNumDevicesForDTy : public ::testing::TestWithParam<int >
141
+ {
142
+ size_t nDevices = 0 ;
143
+ TestGetNumDevicesForDTy ()
144
+ {
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 ()));
151
+ }
152
+ };
153
+
154
+ INSTANTIATE_TEST_SUITE_P (
155
+ GetDevices,
156
+ TestGetNumDevicesForDTy,
157
+ ::testing::Values (DPCTLSyclDeviceType::DPCTL_ACCELERATOR,
158
+ DPCTLSyclDeviceType::DPCTL_ALL,
159
+ DPCTLSyclDeviceType::DPCTL_CPU,
160
+ DPCTLSyclDeviceType::DPCTL_GPU,
161
+ DPCTLSyclDeviceType::DPCTL_HOST_DEVICE));
162
+
163
+ struct TestGetNumDevicesForBTy : public ::testing::TestWithParam<int >
164
+ {
165
+ size_t nDevices = 0 ;
166
+ TestGetNumDevicesForBTy ()
167
+ {
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
+ }
179
+ }
180
+ };
181
+
182
+ INSTANTIATE_TEST_SUITE_P (
183
+ GetDevices,
184
+ TestGetNumDevicesForBTy,
185
+ ::testing::Values (DPCTLSyclBackendType::DPCTL_CUDA,
186
+ DPCTLSyclBackendType::DPCTL_ALL_BACKENDS,
187
+ DPCTLSyclBackendType::DPCTL_HOST,
188
+ DPCTLSyclBackendType::DPCTL_LEVEL_ZERO,
189
+ DPCTLSyclBackendType::DPCTL_OPENCL));
190
+
140
191
struct TestDPCTLDeviceVector : public ::testing::Test
141
192
{
142
193
};
0 commit comments