File tree Expand file tree Collapse file tree 4 files changed +27
-1
lines changed
test-e2e/syclcompat/device Expand file tree Collapse file tree 4 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -918,6 +918,12 @@ static inline void list_devices();
918
918
// Util function to select a device by its id
919
919
static inline unsigned int select_device(unsigned int id);
920
920
921
+ // Util function to get the device id from a device
922
+ static inline unsigned int get_device_id(const sycl::device &dev);
923
+
924
+ // Util function to get the number of available devices
925
+ static inline unsigned int device_count();
926
+
921
927
} // syclcompat
922
928
```
923
929
Original file line number Diff line number Diff line change @@ -938,4 +938,7 @@ static inline unsigned int get_device_id(const sycl::device &dev) {
938
938
return detail::dev_mgr::instance().get_device_id(dev);
939
939
}
940
940
941
+ static inline unsigned int device_count() {
942
+ return detail::dev_mgr::instance().device_count();
943
+ }
941
944
} // namespace syclcompat
Original file line number Diff line number Diff line change @@ -377,6 +377,21 @@ void test_list_devices() {
377
377
assert (countingBuf.get_line_count () == dtf.get_n_devices ());
378
378
}
379
379
380
+ void test_device_count () {
381
+ std::cout << __PRETTY_FUNCTION__ << std::endl;
382
+
383
+ unsigned int count = syclcompat::device_count ();
384
+ assert (count > 0 );
385
+ }
386
+
387
+ void test_get_device_id () {
388
+ std::cout << __PRETTY_FUNCTION__ << std::endl;
389
+
390
+ sycl::device dev = syclcompat::get_device (0 );
391
+ unsigned int id = syclcompat::get_device_id (dev);
392
+ assert (id == 0 );
393
+ }
394
+
380
395
int main () {
381
396
test_at_least_one_device ();
382
397
test_matches_id ();
@@ -396,6 +411,8 @@ int main() {
396
411
test_image_max_attrs ();
397
412
test_max_nd_range ();
398
413
test_list_devices ();
414
+ test_device_count ();
415
+ test_get_device_id ();
399
416
400
417
return 0 ;
401
418
}
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ class DeviceTestsFixt {
32
32
33
33
public:
34
34
DeviceTestsFixt ()
35
- : n_devices{syclcompat::detail::dev_mgr::instance (). device_count ()},
35
+ : n_devices{syclcompat::device_count ()},
36
36
def_q_{syclcompat::get_default_queue ()} {}
37
37
38
38
unsigned int get_n_devices () { return n_devices; }
You can’t perform that action at this time.
0 commit comments