Skip to content

Commit 43b1f76

Browse files
Remove unused declaration of data conversions
Remove all uses of type conversions of Vector and underlyng C++ classes Used DPCTLDevice_CreateSubDevicesEqually instead of building the vector explicitly and casting it to DPCTLDeviceVectorRef.
1 parent ef8b198 commit 43b1f76

File tree

3 files changed

+18
-45
lines changed

3 files changed

+18
-45
lines changed

dpctl-capi/tests/test_sycl_context_interface.cpp

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ using namespace cl::sycl;
3737

3838
namespace
3939
{
40-
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(sycl::device, DPCTLSyclDeviceRef);
41-
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(std::vector<DPCTLSyclDeviceRef>,
42-
DPCTLDeviceVectorRef)
4340
} // namespace
4441

4542
struct TestDPCTLContextInterface : public ::testing::TestWithParam<const char *>
@@ -84,25 +81,16 @@ TEST_P(TestDPCTLContextInterface, ChkCreateWithDevices)
8481
DPCTLSyclContextRef CRef = nullptr;
8582
DPCTLDeviceVectorRef DVRef = nullptr;
8683

87-
/* TODO: Once we have wrappers for sub-device creation let us use those
88-
* functions.
89-
*/
9084
EXPECT_NO_FATAL_FAILURE(nCUs = DPCTLDevice_GetMaxComputeUnits(DRef));
91-
if (nCUs) {
92-
auto D = unwrap(DRef);
93-
try {
94-
auto subDevices = D->create_sub_devices<
95-
info::partition_property::partition_equally>(nCUs / 2);
96-
EXPECT_NO_FATAL_FAILURE(DVRef = DPCTLDeviceVector_Create());
97-
for (auto &sd : subDevices) {
98-
unwrap(DVRef)->emplace_back(wrap(new device(sd)));
99-
}
100-
EXPECT_NO_FATAL_FAILURE(
101-
CRef = DPCTLContext_CreateFromDevices(DVRef, nullptr, 0));
102-
ASSERT_TRUE(CRef);
103-
} catch (feature_not_supported const &fnse) {
85+
if (nCUs > 1) {
86+
EXPECT_NO_FATAL_FAILURE(
87+
DVRef = DPCTLDevice_CreateSubDevicesEqually(DRef, nCUs / 2));
88+
if (!DVRef) {
10489
GTEST_SKIP_("Skipping creating context for sub-devices");
10590
}
91+
EXPECT_NO_FATAL_FAILURE(
92+
CRef = DPCTLContext_CreateFromDevices(DVRef, nullptr, 0));
93+
ASSERT_TRUE(CRef);
10694
}
10795
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceVector_Delete(DVRef));
10896
EXPECT_NO_FATAL_FAILURE(DPCTLContext_Delete(CRef));
@@ -119,28 +107,19 @@ TEST_P(TestDPCTLContextInterface, ChkCreateWithDevicesGetDevices)
119107
* functions.
120108
*/
121109
EXPECT_NO_FATAL_FAILURE(nCUs = DPCTLDevice_GetMaxComputeUnits(DRef));
122-
if (nCUs) {
123-
auto D = unwrap(DRef);
124-
try {
125-
auto subDevices = D->create_sub_devices<
126-
info::partition_property::partition_equally>(nCUs / 2);
127-
const size_t len = subDevices.size();
128-
auto ar = new DPCTLSyclDeviceRef[len];
129-
for (size_t i = 0; i < len; ++i) {
130-
ar[i] = wrap(&subDevices.at(i));
131-
}
132-
EXPECT_NO_FATAL_FAILURE(
133-
DVRef = DPCTLDeviceVector_CreateFromArray(len, ar));
134-
EXPECT_NO_FATAL_FAILURE(
135-
CRef = DPCTLContext_CreateFromDevices(DVRef, nullptr, 0));
136-
ASSERT_TRUE(CRef);
137-
ASSERT_TRUE(DPCTLContext_DeviceCount(CRef) == len);
138-
EXPECT_NO_FATAL_FAILURE(Res_DVRef = DPCTLContext_GetDevices(CRef));
139-
ASSERT_TRUE(DPCTLDeviceVector_Size(Res_DVRef) == len);
140-
delete[] ar;
141-
} catch (feature_not_supported const &fnse) {
110+
if (nCUs > 1) {
111+
EXPECT_NO_FATAL_FAILURE(
112+
DVRef = DPCTLDevice_CreateSubDevicesEqually(DRef, nCUs / 2));
113+
if (!DVRef) {
142114
GTEST_SKIP_("Skipping creating context for sub-devices");
143115
}
116+
EXPECT_NO_FATAL_FAILURE(
117+
CRef = DPCTLContext_CreateFromDevices(DVRef, nullptr, 0));
118+
ASSERT_TRUE(CRef);
119+
const size_t len = DPCTLDeviceVector_Size(DVRef);
120+
ASSERT_TRUE(DPCTLContext_DeviceCount(CRef) == len);
121+
EXPECT_NO_FATAL_FAILURE(Res_DVRef = DPCTLContext_GetDevices(CRef));
122+
ASSERT_TRUE(DPCTLDeviceVector_Size(Res_DVRef) == len);
144123
}
145124
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceVector_Delete(DVRef));
146125
EXPECT_NO_FATAL_FAILURE(DPCTLContext_Delete(CRef));

dpctl-capi/tests/test_sycl_event_interface.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ using namespace cl::sycl;
3535

3636
namespace
3737
{
38-
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(event, DPCTLSyclEventRef);
39-
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(std::vector<DPCTLSyclEventRef>,
40-
DPCTLEventVectorRef);
41-
4238
#ifndef DPCTL_COVERAGE
4339
sycl::event produce_event(sycl::queue &Q, sycl::buffer<int> &data)
4440
{

dpctl-capi/tests/test_sycl_platform_interface.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ using namespace cl::sycl;
3737

3838
namespace
3939
{
40-
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(std::vector<DPCTLSyclPlatformRef>,
41-
DPCTLPlatformVectorRef);
4240

4341
void check_platform_name(__dpctl_keep const DPCTLSyclPlatformRef PRef)
4442
{

0 commit comments

Comments
 (0)