Skip to content

Commit 78cfe5f

Browse files
TEST was using struct meant for parameterized fixture and were not picked up by GTEST.
This change introduces boiler-plate fixture TestQueueMgrFeatrues and groups tests that used to be called with TEST in it. It also adds two tests that queue manager can work with sub-devices. One test for a single device context, and another for multi-device context.
1 parent 4f4adf5 commit 78cfe5f

File tree

1 file changed

+102
-7
lines changed

1 file changed

+102
-7
lines changed

dpctl-capi/tests/test_sycl_queue_manager.cpp

Lines changed: 102 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,19 @@ TEST_P(TestDPCTLSyclQueueManager, CheckIsCurrentQueue)
127127
DPCTLQueue_Delete(Q0);
128128
}
129129

130-
TEST(TestDPCTLSyclQueueManager, CheckGetNumActivatedQueues)
130+
INSTANTIATE_TEST_SUITE_P(QueueMgrFunctions,
131+
TestDPCTLSyclQueueManager,
132+
::testing::Values("opencl:gpu:0",
133+
"opencl:cpu:0",
134+
"level_zero:gpu:0"));
135+
136+
struct TestDPCTLQueueMgrFeatures : public ::testing::Test
137+
{
138+
TestDPCTLQueueMgrFeatures() {}
139+
~TestDPCTLQueueMgrFeatures() {}
140+
};
141+
142+
TEST_F(TestDPCTLQueueMgrFeatures, CheckGetNumActivatedQueues)
131143
{
132144
size_t num0, num1, num2, num4;
133145
DPCTLSyclDeviceSelectorRef CPU_DSRef = nullptr, GPU_DSRef = nullptr;
@@ -177,7 +189,7 @@ TEST(TestDPCTLSyclQueueManager, CheckGetNumActivatedQueues)
177189
}
178190
}
179191

180-
TEST(TestDPCTLSyclQueueManager, CheckIsCurrentQueue2)
192+
TEST_F(TestDPCTLQueueMgrFeatures, CheckIsCurrentQueue2)
181193
{
182194
DPCTLSyclDeviceSelectorRef DS1 = nullptr, DS2 = nullptr;
183195
DPCTLSyclDeviceRef D1 = nullptr, D2 = nullptr;
@@ -214,8 +226,91 @@ TEST(TestDPCTLSyclQueueManager, CheckIsCurrentQueue2)
214226
DPCTLDevice_Delete(D2);
215227
}
216228

217-
INSTANTIATE_TEST_SUITE_P(QueueMgrFunctions,
218-
TestDPCTLSyclQueueManager,
219-
::testing::Values("opencl:gpu:0",
220-
"opencl:cpu:0",
221-
"level_zero:gpu:0"));
229+
TEST_F(TestDPCTLQueueMgrFeatures, CheckSetGlobalQueueForSubDevices)
230+
{
231+
DPCTLSyclDeviceSelectorRef DS = nullptr;
232+
DPCTLSyclDeviceRef RootCpu_DRef = nullptr;
233+
size_t max_eu_count = 0;
234+
DPCTLSyclDeviceRef SubDev0_DRef = nullptr;
235+
DPCTLSyclDeviceRef SubDev1_DRef = nullptr;
236+
DPCTLSyclQueueRef QRef = nullptr;
237+
238+
EXPECT_NO_FATAL_FAILURE(DS = DPCTLFilterSelector_Create("opencl:cpu"));
239+
EXPECT_NO_FATAL_FAILURE(RootCpu_DRef = DPCTLDevice_CreateFromSelector(DS));
240+
DPCTLDeviceSelector_Delete(DS);
241+
EXPECT_TRUE(RootCpu_DRef);
242+
EXPECT_NO_FATAL_FAILURE(max_eu_count =
243+
DPCTLDevice_GetMaxComputeUnits(RootCpu_DRef));
244+
size_t n1 = max_eu_count / 2;
245+
size_t n2 = max_eu_count - n1;
246+
247+
if (n1 > 0 && n2 > 0) {
248+
size_t counts[2] = {n1, n2};
249+
DPCTLDeviceVectorRef DVRef = nullptr;
250+
EXPECT_NO_FATAL_FAILURE(DVRef = DPCTLDevice_CreateSubDevicesByCounts(
251+
RootCpu_DRef, counts, 2));
252+
EXPECT_NO_FATAL_FAILURE(SubDev0_DRef =
253+
DPCTLDeviceVector_GetAt(DVRef, 0));
254+
EXPECT_NO_FATAL_FAILURE(SubDev1_DRef =
255+
DPCTLDeviceVector_GetAt(DVRef, 1));
256+
EXPECT_NO_FATAL_FAILURE(
257+
QRef = DPCTLQueue_CreateForDevice(SubDev0_DRef, nullptr,
258+
DPCTL_DEFAULT_PROPERTY));
259+
EXPECT_NO_FATAL_FAILURE(DPCTLDevice_Delete(SubDev1_DRef));
260+
EXPECT_NO_FATAL_FAILURE(DPCTLDevice_Delete(SubDev0_DRef));
261+
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceVector_Delete(DVRef));
262+
EXPECT_NO_FATAL_FAILURE(DPCTLQueueMgr_SetGlobalQueue(QRef));
263+
EXPECT_NO_FATAL_FAILURE(DPCTLQueue_Delete(QRef));
264+
}
265+
else {
266+
DPCTLDevice_Delete(RootCpu_DRef);
267+
GTEST_SKIP_("OpenCL CPU devices are needed, but were not found.");
268+
}
269+
}
270+
271+
TEST_F(TestDPCTLQueueMgrFeatures,
272+
CheckSetGlobalQueueForSubDevicesMultiDeviceContext)
273+
{
274+
DPCTLSyclDeviceSelectorRef DS = nullptr;
275+
DPCTLSyclDeviceRef RootCpu_DRef = nullptr;
276+
size_t max_eu_count = 0;
277+
DPCTLSyclDeviceRef SubDev0_DRef = nullptr;
278+
DPCTLSyclDeviceRef SubDev1_DRef = nullptr;
279+
DPCTLSyclQueueRef QRef = nullptr;
280+
DPCTLSyclContextRef CRef = nullptr;
281+
282+
EXPECT_NO_FATAL_FAILURE(DS = DPCTLFilterSelector_Create("opencl:cpu"));
283+
EXPECT_NO_FATAL_FAILURE(RootCpu_DRef = DPCTLDevice_CreateFromSelector(DS));
284+
DPCTLDeviceSelector_Delete(DS);
285+
EXPECT_TRUE(RootCpu_DRef);
286+
EXPECT_NO_FATAL_FAILURE(max_eu_count =
287+
DPCTLDevice_GetMaxComputeUnits(RootCpu_DRef));
288+
size_t n1 = max_eu_count / 2;
289+
size_t n2 = max_eu_count - n1;
290+
291+
if (n1 > 0 && n2 > 0) {
292+
size_t counts[2] = {n1, n2};
293+
DPCTLDeviceVectorRef DVRef = nullptr;
294+
EXPECT_NO_FATAL_FAILURE(DVRef = DPCTLDevice_CreateSubDevicesByCounts(
295+
RootCpu_DRef, counts, 2));
296+
EXPECT_NO_FATAL_FAILURE(SubDev0_DRef =
297+
DPCTLDeviceVector_GetAt(DVRef, 0));
298+
EXPECT_NO_FATAL_FAILURE(SubDev1_DRef =
299+
DPCTLDeviceVector_GetAt(DVRef, 1));
300+
EXPECT_NO_FATAL_FAILURE(CRef = DPCTLContext_CreateFromDevices(
301+
DVRef, nullptr, DPCTL_DEFAULT_PROPERTY));
302+
EXPECT_NO_FATAL_FAILURE(
303+
QRef = DPCTLQueue_Create(CRef, SubDev0_DRef, nullptr,
304+
DPCTL_DEFAULT_PROPERTY));
305+
EXPECT_NO_FATAL_FAILURE(DPCTLDevice_Delete(SubDev1_DRef));
306+
EXPECT_NO_FATAL_FAILURE(DPCTLDevice_Delete(SubDev0_DRef));
307+
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceVector_Delete(DVRef));
308+
EXPECT_NO_FATAL_FAILURE(DPCTLQueueMgr_SetGlobalQueue(QRef));
309+
EXPECT_NO_FATAL_FAILURE(DPCTLQueue_Delete(QRef));
310+
EXPECT_NO_FATAL_FAILURE(DPCTLContext_Delete(CRef));
311+
}
312+
else {
313+
DPCTLDevice_Delete(RootCpu_DRef);
314+
GTEST_SKIP_("OpenCL CPU devices are needed, but were not found.");
315+
}
316+
}

0 commit comments

Comments
 (0)