@@ -37,9 +37,6 @@ using namespace cl::sycl;
3737
3838namespace
3939{
40- DEFINE_SIMPLE_CONVERSION_FUNCTIONS (sycl::device, DPCTLSyclDeviceRef);
41- DEFINE_SIMPLE_CONVERSION_FUNCTIONS (std::vector<DPCTLSyclDeviceRef>,
42- DPCTLDeviceVectorRef)
4340} // namespace
4441
4542struct 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));
0 commit comments