@@ -139,18 +139,30 @@ INSTANTIATE_TEST_SUITE_P(
139
139
140
140
struct TestGetNumDevicesForDTy : public ::testing::TestWithParam<int >
141
141
{
142
- size_t nDevices = 0 ;
142
+ int param;
143
+ sycl::info::device_type sycl_dty;
144
+
143
145
TestGetNumDevicesForDTy ()
144
146
{
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);
151
150
}
152
151
};
153
152
153
+ TEST_P (TestGetNumDevicesForDTy, ChkGetNumDevices)
154
+ {
155
+ auto devices = sycl::device::get_devices (sycl_dty);
156
+ size_t nDevices = 0 ;
157
+ sycl::default_selector mRanker ;
158
+ for (const sycl::device &d : devices) {
159
+ if (mRanker (d) < 0 )
160
+ continue ;
161
+ ++nDevices;
162
+ }
163
+ EXPECT_TRUE (nDevices == DPCTLDeviceMgr_GetNumDevices (param));
164
+ }
165
+
154
166
INSTANTIATE_TEST_SUITE_P (
155
167
GetDevices,
156
168
TestGetNumDevicesForDTy,
@@ -162,22 +174,33 @@ INSTANTIATE_TEST_SUITE_P(
162
174
163
175
struct TestGetNumDevicesForBTy : public ::testing::TestWithParam<int >
164
176
{
165
- size_t nDevices = 0 ;
177
+ int param;
178
+ sycl::backend sycl_bty;
166
179
TestGetNumDevicesForBTy ()
167
180
{
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 ()));
181
+ param = GetParam ();
182
+ sycl_bty =
183
+ DPCTL_DPCTLBackendTypeToSyclBackend (DPCTLSyclBackendType (param));
184
+ }
185
+ };
186
+
187
+ TEST_P (TestGetNumDevicesForBTy, ChkGetNumDevices)
188
+ {
189
+ auto platforms = cl::sycl::platform::get_platforms ();
190
+ size_t nDevices = 0 ;
191
+ sycl::default_selector mRanker ;
192
+ for (const auto &P : platforms) {
193
+ if ((P.get_backend () == sycl_bty) || (sycl_bty == sycl::backend::all)) {
194
+ auto devices = P.get_devices ();
195
+ for (const sycl::device &d : devices) {
196
+ if (mRanker (d) < 0 )
197
+ continue ;
198
+ ++nDevices;
177
199
}
178
200
}
179
201
}
180
- };
202
+ EXPECT_TRUE (nDevices == DPCTLDeviceMgr_GetNumDevices (param));
203
+ }
181
204
182
205
INSTANTIATE_TEST_SUITE_P (
183
206
GetDevices,
0 commit comments