Skip to content

Commit 7ea744b

Browse files
committed
Adds C-API tests for composite devices
1 parent 5487223 commit 7ea744b

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed

libsyclinterface/tests/test_sycl_device_aspects.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ auto build_params()
127127
std::make_pair("usm_atomic_shared_allocations",
128128
sycl::aspect::usm_atomic_shared_allocations),
129129
std::make_pair("host_debuggable", sycl::aspect::host_debuggable),
130-
std::make_pair("emulated", sycl::aspect::emulated));
130+
std::make_pair("emulated", sycl::aspect::emulated),
131+
std::make_pair("is_component",
132+
sycl::aspect::ext_oneapi_is_composite),
133+
std::make_pair("is_composite",
134+
sycl::aspect::ext_oneapi_is_component));
131135

132136
auto pairs =
133137
build_param_pairs<const char *, std::pair<const char *, sycl::aspect>,

libsyclinterface/tests/test_sycl_device_manager.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,71 @@ TEST_F(TestDPCTLDeviceMgrNullReference, ChkGetPositionInDevices)
316316
EXPECT_NO_FATAL_FAILURE(
317317
DPCTLDeviceMgr_GetPositionInDevices(nullDRef, mask));
318318
}
319+
320+
struct TestDPCTLGetCompositeDevices : public ::testing::Test
321+
{
322+
DPCTLDeviceVectorRef DV = nullptr;
323+
size_t nDevices = 0;
324+
325+
TestDPCTLGetCompositeDevices()
326+
{
327+
EXPECT_NO_FATAL_FAILURE(DV = DPCTLDeviceMgr_GetCompositeDevices());
328+
EXPECT_TRUE(DV != nullptr);
329+
EXPECT_NO_FATAL_FAILURE(nDevices = DPCTLDeviceVector_Size(DV));
330+
}
331+
332+
void SetUp()
333+
{
334+
if (!nDevices) {
335+
GTEST_SKIP_("Skipping as no composite devices available");
336+
}
337+
}
338+
339+
~TestDPCTLGetCompositeDevices()
340+
{
341+
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceVector_Clear(DV));
342+
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceVector_Delete(DV));
343+
}
344+
};
345+
346+
TEST_F(TestDPCTLGetCompositeDevices, ChkGetAt)
347+
{
348+
for (auto i = 0ul; i < nDevices; ++i) {
349+
DPCTLSyclDeviceRef DRef = nullptr;
350+
EXPECT_NO_FATAL_FAILURE(DRef = DPCTLDeviceVector_GetAt(DV, i));
351+
ASSERT_TRUE(DRef != nullptr);
352+
}
353+
}
354+
355+
TEST_F(TestDPCTLGetCompositeDevices, ChkCompositeAspect)
356+
{
357+
for (auto i = 0ul; i < nDevices; ++i) {
358+
DPCTLSyclDeviceRef DRef = nullptr;
359+
EXPECT_NO_FATAL_FAILURE(DRef = DPCTLDeviceVector_GetAt(DV, i));
360+
ASSERT_TRUE(DRef != nullptr);
361+
ASSERT_TRUE(
362+
DPCTLDevice_HasAspect(DRef, DPCTLSyclAspectType::is_composite));
363+
}
364+
}
365+
366+
TEST_F(TestDPCTLGetCompositeDevices, ChkComponentDevices)
367+
{
368+
for (auto i = 0ul; i < nDevices; ++i) {
369+
DPCTLSyclDeviceRef DRef = nullptr;
370+
EXPECT_NO_FATAL_FAILURE(DRef = DPCTLDeviceVector_GetAt(DV, i));
371+
ASSERT_TRUE(DRef != nullptr);
372+
DPCTLDeviceVectorRef CDV = nullptr;
373+
size_t nComponents = 0;
374+
EXPECT_NO_FATAL_FAILURE(CDV = DPCTLDevice_GetComponentDevices(DRef));
375+
EXPECT_NO_FATAL_FAILURE(nComponents = DPCTLDeviceVector_Size(CDV));
376+
for (auto j = 0ul; j < nComponents; ++j) {
377+
DPCTLSyclDeviceRef CDRef = nullptr;
378+
EXPECT_NO_FATAL_FAILURE(CDRef = DPCTLDeviceVector_GetAt(CDV, j));
379+
ASSERT_TRUE(CDRef != nullptr);
380+
ASSERT_TRUE(DPCTLDevice_HasAspect(
381+
CDRef, DPCTLSyclAspectType::is_component));
382+
}
383+
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceVector_Clear(CDV));
384+
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceVector_Delete(CDV));
385+
}
386+
}

0 commit comments

Comments
 (0)