@@ -139,18 +139,30 @@ INSTANTIATE_TEST_SUITE_P(
139139
140140struct 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+ 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+
154166INSTANTIATE_TEST_SUITE_P (
155167 GetDevices,
156168 TestGetNumDevicesForDTy,
@@ -162,22 +174,33 @@ INSTANTIATE_TEST_SUITE_P(
162174
163175struct TestGetNumDevicesForBTy : public ::testing::TestWithParam<int >
164176{
165- size_t nDevices = 0 ;
177+ int param;
178+ sycl::backend sycl_bty;
166179 TestGetNumDevicesForBTy ()
167180 {
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;
177199 }
178200 }
179201 }
180- };
202+ EXPECT_TRUE (nDevices == DPCTLDeviceMgr_GetNumDevices (param));
203+ }
181204
182205INSTANTIATE_TEST_SUITE_P (
183206 GetDevices,
0 commit comments