@@ -37,9 +37,6 @@ using namespace cl::sycl;
37
37
38
38
namespace
39
39
{
40
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS (sycl::device, DPCTLSyclDeviceRef);
41
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS (std::vector<DPCTLSyclDeviceRef>,
42
- DPCTLDeviceVectorRef)
43
40
} // namespace
44
41
45
42
struct TestDPCTLContextInterface : public ::testing::TestWithParam<const char *>
@@ -84,25 +81,16 @@ TEST_P(TestDPCTLContextInterface, ChkCreateWithDevices)
84
81
DPCTLSyclContextRef CRef = nullptr ;
85
82
DPCTLDeviceVectorRef DVRef = nullptr ;
86
83
87
- /* TODO: Once we have wrappers for sub-device creation let us use those
88
- * functions.
89
- */
90
84
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) {
104
89
GTEST_SKIP_ (" Skipping creating context for sub-devices" );
105
90
}
91
+ EXPECT_NO_FATAL_FAILURE (
92
+ CRef = DPCTLContext_CreateFromDevices (DVRef, nullptr , 0 ));
93
+ ASSERT_TRUE (CRef);
106
94
}
107
95
EXPECT_NO_FATAL_FAILURE (DPCTLDeviceVector_Delete (DVRef));
108
96
EXPECT_NO_FATAL_FAILURE (DPCTLContext_Delete (CRef));
@@ -119,28 +107,19 @@ TEST_P(TestDPCTLContextInterface, ChkCreateWithDevicesGetDevices)
119
107
* functions.
120
108
*/
121
109
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) {
142
114
GTEST_SKIP_ (" Skipping creating context for sub-devices" );
143
115
}
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);
144
123
}
145
124
EXPECT_NO_FATAL_FAILURE (DPCTLDeviceVector_Delete (DVRef));
146
125
EXPECT_NO_FATAL_FAILURE (DPCTLContext_Delete (CRef));
0 commit comments