Skip to content

Commit b8c765f

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

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

libsyclinterface/tests/test_sycl_device_aspects.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <stddef.h>
3535

3636
#include <gtest/gtest.h>
37+
#include <iostream>
3738
#include <sycl/sycl.hpp>
3839
#include <utility>
3940

@@ -127,7 +128,11 @@ auto build_params()
127128
std::make_pair("usm_atomic_shared_allocations",
128129
sycl::aspect::usm_atomic_shared_allocations),
129130
std::make_pair("host_debuggable", sycl::aspect::host_debuggable),
130-
std::make_pair("emulated", sycl::aspect::emulated));
131+
std::make_pair("emulated", sycl::aspect::emulated),
132+
std::make_pair("is_component",
133+
sycl::aspect::ext_oneapi_is_component),
134+
std::make_pair("is_composite",
135+
sycl::aspect::ext_oneapi_is_composite));
131136

132137
auto pairs =
133138
build_param_pairs<const char *, std::pair<const char *, sycl::aspect>,
@@ -184,6 +189,7 @@ TEST_P(TestDPCTLSyclDeviceInterfaceAspects, ChkHasAspect)
184189
{
185190
bool actual = false;
186191
auto dpctlAspect = DPCTL_StrToAspectType(GetParam().second.first);
192+
std::cout << GetParam().second.first << std::endl;
187193
auto AspectTy = DPCTL_SyclAspectToDPCTLAspectType(dpctlAspect);
188194
EXPECT_NO_FATAL_FAILURE(actual = DPCTLDevice_HasAspect(DRef, AspectTy));
189195
EXPECT_TRUE(hasAspect == actual);

libsyclinterface/tests/test_sycl_device_manager.cpp

+46
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,49 @@ 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+
}

0 commit comments

Comments
 (0)