Skip to content

Commit d16f1a5

Browse files
authored
Add Tests: (1/N) zeCommandListImmediateAppendCommandListsExp (#111)
* added CTS for zeCommandListImmediateAppendCommandListsExp Signed-off-by: Chandio, Bibrak Qamar <bibrak.qamar.chandio@intel.com> * added CTS for zeCommandListImmediateAppendCommandListsExp Signed-off-by: Chandio, Bibrak Qamar <bibrak.qamar.chandio@intel.com> * added CTS for zeCommandListImmediateAppendCommandListsExp Signed-off-by: Chandio, Bibrak Qamar <bibrak.qamar.chandio@intel.com> * added CTS for zeCommandListImmediateAppendCommandListsExp Signed-off-by: Chandio, Bibrak Qamar <bibrak.qamar.chandio@intel.com> * added CTS for zeCommandListImmediateAppendCommandListsExp Signed-off-by: Chandio, Bibrak Qamar <bibrak.qamar.chandio@intel.com> * added CTS for zeCommandListImmediateAppendCommandListsExp Signed-off-by: Chandio, Bibrak Qamar <bibrak.qamar.chandio@intel.com> --------- Signed-off-by: Chandio, Bibrak Qamar <bibrak.qamar.chandio@intel.com>
1 parent 3bd5926 commit d16f1a5

File tree

6 files changed

+193
-3
lines changed

6 files changed

+193
-3
lines changed

conformance_tests/core/test_cmdqueue/src/test_cmdqueue.cpp

Lines changed: 117 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2019-2023 Intel Corporation
3+
* Copyright (C) 2019-2024 Intel Corporation
44
*
55
* SPDX-License-Identifier: MIT
66
*
@@ -235,6 +235,117 @@ TEST_P(
235235
}
236236
}
237237

238+
class zeImmediateCommandListAppendCommandListsExpTests
239+
: public ::testing::Test,
240+
public ::testing::WithParamInterface<CustomExecuteParams> {
241+
protected:
242+
void SetUp() override {
243+
244+
const ze_driver_handle_t driver = lzt::get_default_driver();
245+
const ze_context_handle_t context = lzt::get_default_context();
246+
EXPECT_GT(params.num_command_lists, 0);
247+
248+
print_cmdqueue_exec(params.num_command_lists, params.sync_timeout);
249+
250+
ze_device_handle_t device = lzt::zeDevice::get_instance()->get_device();
251+
auto ordinal = lzt::get_compute_queue_group_ordinals(device)[0];
252+
253+
command_list_immediate = lzt::create_immediate_command_list(
254+
device, ZE_COMMAND_QUEUE_FLAG_IN_ORDER,
255+
ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, ZE_COMMAND_QUEUE_PRIORITY_NORMAL,
256+
ordinal);
257+
258+
command_queue = lzt::create_command_queue(
259+
context, device, ZE_COMMAND_QUEUE_FLAG_IN_ORDER,
260+
ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, ZE_COMMAND_QUEUE_PRIORITY_NORMAL,
261+
ordinal);
262+
263+
for (uint32_t i = 0; i < buff_size_bytes; i++) {
264+
verification_buffer[i] = lzt::generate_value<uint8_t>(0, 255, 0);
265+
}
266+
267+
for (uint32_t i = 0; i < params.num_command_lists; i++) {
268+
269+
void *host_buffer =
270+
lzt::allocate_host_memory(buff_size_bytes, 1, context);
271+
272+
uint8_t *char_input = static_cast<uint8_t *>(host_buffer);
273+
for (uint32_t j = 0; j < buff_size_bytes; j++) {
274+
char_input[j] = verification_buffer[j];
275+
}
276+
277+
host_buffers.push_back(static_cast<uint8_t *>(host_buffer));
278+
279+
void *device_buffer =
280+
lzt::allocate_device_memory(buff_size_bytes, buff_size_bytes, 0,
281+
nullptr, ordinal, device, context);
282+
283+
device_buffers.push_back(static_cast<uint8_t *>(device_buffer));
284+
285+
ze_command_list_handle_t command_list_regular =
286+
lzt::create_command_list(context, device, 0, ordinal);
287+
288+
// Copy from host-allocated to device-allocated memory
289+
lzt::append_memory_copy(command_list_regular, device_buffer, host_buffer,
290+
buff_size_bytes, nullptr);
291+
292+
lzt::append_barrier(command_list_regular, nullptr, 0, nullptr);
293+
294+
// Copy from device-allocated memory back to host-allocated memory
295+
lzt::append_memory_copy(command_list_regular, host_buffer, device_buffer,
296+
buff_size_bytes, nullptr);
297+
298+
lzt::close_command_list(command_list_regular);
299+
list_of_command_lists.push_back(command_list_regular);
300+
}
301+
}
302+
303+
void TearDown() override {
304+
for (uint32_t i = 0; i < params.num_command_lists; i++) {
305+
306+
EXPECT_EQ(
307+
0, memcmp(host_buffers.at(i), verification_buffer, buff_size_bytes));
308+
309+
lzt::destroy_command_list(list_of_command_lists.at(i));
310+
lzt::free_memory(host_buffers.at(i));
311+
lzt::free_memory(device_buffers.at(i));
312+
}
313+
lzt::destroy_command_queue(command_queue);
314+
}
315+
316+
static const uint32_t buff_size_bytes = 12;
317+
uint8_t verification_buffer[buff_size_bytes];
318+
CustomExecuteParams params = GetParam();
319+
320+
ze_command_queue_handle_t command_queue = nullptr;
321+
std::vector<ze_command_list_handle_t> list_of_command_lists;
322+
323+
std::vector<uint8_t *> host_buffers;
324+
std::vector<uint8_t *> device_buffers;
325+
326+
ze_command_list_handle_t command_list_immediate;
327+
};
328+
329+
class zeCommandListImmediateAppendCommandListsExpTestsHostSynchronize
330+
: public zeImmediateCommandListAppendCommandListsExpTests {};
331+
332+
TEST_P(
333+
zeCommandListImmediateAppendCommandListsExpTestsHostSynchronize,
334+
GivenCommandListImmediateAppendCommandListsExpAndSyncUsingCommandListHostSynchronizeThenCallSucceeds) {
335+
336+
lzt::append_command_lists_immediate_exp(command_list_immediate,
337+
params.num_command_lists,
338+
list_of_command_lists.data());
339+
340+
ze_result_t sync_status = ZE_RESULT_NOT_READY;
341+
while (sync_status != ZE_RESULT_SUCCESS) {
342+
EXPECT_EQ(sync_status, ZE_RESULT_NOT_READY);
343+
sync_status = zeCommandListHostSynchronize(command_list_immediate,
344+
params.sync_timeout);
345+
std::this_thread::yield();
346+
}
347+
}
348+
238349
CustomExecuteParams synchronize_test_input[] = {{1, 0},
239350
{2, UINT32_MAX >> 30},
240351
{3, UINT32_MAX >> 28},
@@ -254,6 +365,11 @@ INSTANTIATE_TEST_SUITE_P(TestIncreasingNumberCommandListsWithSynchronize,
254365
zeCommandQueueExecuteCommandListTestsSynchronize,
255366
testing::ValuesIn(synchronize_test_input));
256367

368+
INSTANTIATE_TEST_SUITE_P(
369+
TestIncreasingNumberCommandListImmediateAppendCommandListsExpWithSynchronize,
370+
zeCommandListImmediateAppendCommandListsExpTestsHostSynchronize,
371+
testing::ValuesIn(synchronize_test_input));
372+
257373
class zeCommandQueueExecuteCommandListTestsFence
258374
: public zeCommandQueueExecuteCommandListTests {};
259375

scripts/level_zero_report_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def assign_test_feature_tag(test_feature: str, test_name: str, test_section: str
6565
(re.search('L0_CTS_ContextStatusTest_GivenContextCreateWhenUsingValidHandleThenContextGetStatusReturnsSuccess', test_name, re.IGNORECASE)) or \
6666
(re.search('L0_CTS_TimestampsTest_GivenExecutedKernelWhenGettingGlobalTimestampsThenDeviceAndHostTimestampDurationsAreClose', test_name, re.IGNORECASE)) or \
6767
(re.search('L0_CTS_TimestampsTest_GivenExecutedKernelWhenGettingGlobalTimestampsOnImmediateCmdListThenDeviceAndHostTimestampDurationsAreClose', test_name, re.IGNORECASE)) or \
68+
(re.search('L0_CTS_TestIncreasingNumberCommandListImmediateAppendCommandListsExpWithSynchronize_zeCommandListImmediateAppendCommandListsExpTestsHostSynchronize_GivenCommandListImmediateAppendCommandListsExpAndSyncUsingCommandListHostSynchronizeThenCallSucceeds', test_name, re.IGNORECASE)) or \
6869
(re.search('L0_CTS_zeCommandListAppendMemoryCopyTest_GivenCommandListWithMultipleAppendMemoryCopiesFollowedByResetInLoopThenSuccessIsReturned', test_name, re.IGNORECASE)) or \
6970
(re.search('L0_CTS_zeCommandListAppendMemoryCopyTest_GivenTwoCommandQueuesHavingCommandListsWithScratchSpaceThenSuccessIsReturned', test_name, re.IGNORECASE)) or \
7071
(re.search('L0_CTS_zeCommandListAppendMemoryFillVerificationTests_GivenHostMemoryWhenExecutingAMemoryFillOnImmediateCmdListThenMemoryIsSetCorrectly', test_name, re.IGNORECASE)) or \

utils/test_harness/include/test_harness/test_harness_cmdlist.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ ze_command_list_handle_t create_immediate_command_list(
4848

4949
ze_command_list_handle_t create_immediate_command_list();
5050

51+
void append_command_lists_immediate_exp(
52+
ze_command_list_handle_t hCommandList, uint32_t numCommandLists,
53+
ze_command_list_handle_t *phCommandLists, ze_event_handle_t hSignalEvent);
54+
void append_command_lists_immediate_exp(
55+
ze_command_list_handle_t hCommandList, uint32_t numCommandLists,
56+
ze_command_list_handle_t *phCommandLists);
57+
void append_command_lists_immediate_exp(
58+
ze_command_list_handle_t hCommandList, uint32_t numCommandLists,
59+
ze_command_list_handle_t *phCommandLists, ze_event_handle_t hSignalEvent,
60+
uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents);
61+
5162
zeCommandBundle create_command_bundle(bool isImmediate);
5263
zeCommandBundle create_command_bundle(ze_device_handle_t device,
5364
bool isImmediate);

utils/test_harness/include/test_harness/test_harness_cmdqueue.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2019 Intel Corporation
3+
* Copyright (C) 2019-2024 Intel Corporation
44
*
55
* SPDX-License-Identifier: MIT
66
*
@@ -28,6 +28,7 @@ class zeCommandQueueTests : public ::testing::Test {
2828
zeCommandQueue cq;
2929
};
3030

31+
std::vector<uint32_t> get_compute_queue_group_ordinals(ze_device_handle_t device);
3132
ze_command_queue_handle_t create_command_queue();
3233
ze_command_queue_handle_t create_command_queue(ze_device_handle_t device);
3334
ze_command_queue_handle_t create_command_queue(ze_context_handle_t context,

utils/test_harness/src/test_harness_cmdlist.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,46 @@ ze_command_list_handle_t create_immediate_command_list(
103103
return command_list;
104104
}
105105

106+
void append_command_lists_immediate_exp(
107+
ze_command_list_handle_t hCommandList, uint32_t numCommandLists,
108+
ze_command_list_handle_t *phCommandLists, ze_event_handle_t hSignalEvent) {
109+
append_command_lists_immediate_exp(hCommandList, numCommandLists,
110+
phCommandLists, hSignalEvent, 0, nullptr);
111+
}
112+
113+
void append_command_lists_immediate_exp(
114+
ze_command_list_handle_t hCommandList, uint32_t numCommandLists,
115+
ze_command_list_handle_t *phCommandLists) {
116+
append_command_lists_immediate_exp(hCommandList, numCommandLists,
117+
phCommandLists, nullptr, 0, nullptr);
118+
}
119+
120+
void append_command_lists_immediate_exp(
121+
ze_command_list_handle_t hCommandList, uint32_t numCommandLists,
122+
ze_command_list_handle_t *phCommandLists, ze_event_handle_t hSignalEvent,
123+
uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents) {
124+
auto command_list_initial = hCommandList;
125+
std::vector<ze_command_list_handle_t> command_lists_initial(numCommandLists);
126+
std::memcpy(command_lists_initial.data(), phCommandLists,
127+
sizeof(ze_command_list_handle_t) * numCommandLists);
128+
auto signal_event_initial = hSignalEvent;
129+
std::vector<ze_event_handle_t> wait_events_initial(numWaitEvents);
130+
std::memcpy(wait_events_initial.data(), phWaitEvents,
131+
sizeof(ze_event_handle_t) * numWaitEvents);
132+
EXPECT_EQ(ZE_RESULT_SUCCESS,
133+
zeCommandListImmediateAppendCommandListsExp(
134+
hCommandList, numCommandLists, phCommandLists, hSignalEvent,
135+
numWaitEvents, phWaitEvents));
136+
EXPECT_EQ(hCommandList, command_list_initial);
137+
EXPECT_EQ(hSignalEvent, signal_event_initial);
138+
for (int i = 0; i < numCommandLists; i++) {
139+
EXPECT_EQ(phCommandLists[i], command_lists_initial[i]);
140+
}
141+
for (int i = 0; i < numWaitEvents; i++) {
142+
EXPECT_EQ(phWaitEvents[i], wait_events_initial[i]);
143+
}
144+
}
145+
106146
zeCommandBundle create_command_bundle(bool isImmediate) {
107147
return create_command_bundle(zeDevice::get_instance()->get_device(),
108148
isImmediate);

utils/test_harness/src/test_harness_cmdqueue.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2019 Intel Corporation
3+
* Copyright (C) 2019-2024 Intel Corporation
44
*
55
* SPDX-License-Identifier: MIT
66
*
@@ -14,6 +14,27 @@ namespace lzt = level_zero_tests;
1414

1515
namespace level_zero_tests {
1616

17+
std::vector<uint32_t> get_compute_queue_group_ordinals(ze_device_handle_t device) {
18+
uint32_t num_queue_groups = 0;
19+
EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGetCommandQueueGroupProperties(
20+
device, &num_queue_groups, nullptr));
21+
EXPECT_GT(num_queue_groups, 0) << "No queue groups found!";
22+
std::vector<ze_command_queue_group_properties_t> queue_properties(
23+
num_queue_groups);
24+
EXPECT_EQ(ZE_RESULT_SUCCESS,
25+
zeDeviceGetCommandQueueGroupProperties(device, &num_queue_groups,
26+
queue_properties.data()));
27+
std::vector<uint32_t> compute_queue_group_ordinals = {};
28+
for (uint32_t i = 0; i < num_queue_groups; i++) {
29+
if (queue_properties[i].flags &
30+
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE) {
31+
compute_queue_group_ordinals.push_back(i);
32+
break;
33+
}
34+
}
35+
return compute_queue_group_ordinals;
36+
}
37+
1738
ze_command_queue_handle_t create_command_queue() {
1839
return create_command_queue(zeDevice::get_instance()->get_device());
1940
}

0 commit comments

Comments
 (0)