|
25 | 25 | //===----------------------------------------------------------------------===//
|
26 | 26 |
|
27 | 27 | #include "dpctl_sycl_context_interface.h"
|
| 28 | +#include "dpctl_sycl_device_interface.h" |
28 | 29 | #include "dpctl_sycl_device_selector_interface.h"
|
29 | 30 | #include "dpctl_sycl_platform_interface.h"
|
30 | 31 | #include "dpctl_sycl_platform_manager.h"
|
@@ -92,6 +93,26 @@ void check_platform_default_context(
|
92 | 93 | EXPECT_NO_FATAL_FAILURE(DPCTLContext_Delete(CRef));
|
93 | 94 | }
|
94 | 95 |
|
| 96 | +void check_platform_get_devices(__dpctl_keep const DPCTLSyclPlatformRef PRef) |
| 97 | +{ |
| 98 | + DPCTLDeviceVectorRef DVRef = nullptr; |
| 99 | + size_t nDevices = 0; |
| 100 | + |
| 101 | + DPCTLSyclDeviceType defDTy = DPCTLSyclDeviceType::DPCTL_ALL; |
| 102 | + EXPECT_NO_FATAL_FAILURE(DVRef = DPCTLPlatform_GetDevices(PRef, defDTy)); |
| 103 | + EXPECT_TRUE(DVRef != nullptr); |
| 104 | + EXPECT_NO_FATAL_FAILURE(nDevices = DPCTLDeviceVector_Size(DVRef)); |
| 105 | + for (auto i = 0ul; i < nDevices; ++i) { |
| 106 | + DPCTLSyclDeviceRef DRef = nullptr; |
| 107 | + EXPECT_NO_FATAL_FAILURE(DRef = DPCTLDeviceVector_GetAt(DVRef, i)); |
| 108 | + ASSERT_TRUE(DRef != nullptr); |
| 109 | + EXPECT_NO_FATAL_FAILURE(DPCTLDevice_Delete(DRef)); |
| 110 | + } |
| 111 | + |
| 112 | + EXPECT_NO_FATAL_FAILURE(DPCTLDeviceVector_Clear(DVRef)); |
| 113 | + EXPECT_NO_FATAL_FAILURE(DPCTLDeviceVector_Delete(DVRef)); |
| 114 | +} |
| 115 | + |
95 | 116 | } // namespace
|
96 | 117 |
|
97 | 118 | struct TestDPCTLSyclPlatformInterface
|
@@ -282,6 +303,11 @@ TEST_P(TestDPCTLSyclPlatformInterface, ChkAreEqNullArg)
|
282 | 303 | ASSERT_TRUE(DPCTLPlatform_Hash(Null_PRef) == 0);
|
283 | 304 | }
|
284 | 305 |
|
| 306 | +TEST_P(TestDPCTLSyclPlatformInterface, ChkGetDevices) |
| 307 | +{ |
| 308 | + check_platform_get_devices(PRef); |
| 309 | +} |
| 310 | + |
285 | 311 | TEST_F(TestDPCTLSyclDefaultPlatform, ChkGetName) { check_platform_name(PRef); }
|
286 | 312 |
|
287 | 313 | TEST_F(TestDPCTLSyclDefaultPlatform, ChkGetVendor)
|
|
0 commit comments