Skip to content

Commit 865e92d

Browse files
committed
added CTS for zeCommandListImmediateAppendCommandListsExp
Signed-off-by: Chandio, Bibrak Qamar <bibrak.qamar.chandio@intel.com>
1 parent 8cd2578 commit 865e92d

File tree

3 files changed

+180
-3
lines changed

3 files changed

+180
-3
lines changed

conformance_tests/core/test_cmdqueue/src/test_cmdqueue.cpp

Lines changed: 156 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,155 @@ TEST_P(
235235
}
236236
}
237237

238+
class zeImmediateCommandListAppendCommandListsExpTests
239+
: public ::testing::Test,
240+
public ::testing::WithParamInterface<CustomExecuteParams> {
241+
protected:
242+
void SetUp() override {
243+
ze_device_handle_t device = lzt::zeDevice::get_instance()->get_device();
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_command_queue_desc_t cmdQueueDesc = {
251+
ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC};
252+
ze_command_list_desc_t cmdListDesc = {ZE_STRUCTURE_TYPE_COMMAND_LIST_DESC};
253+
254+
cmdQueueDesc.ordinal = lzt::getComputeQueueGroupOrdinal(device);
255+
256+
cmdQueueDesc.index = 0;
257+
cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
258+
259+
EXPECT_EQ(ZE_RESULT_SUCCESS,
260+
zeCommandListCreateImmediate(context, device, &cmdQueueDesc,
261+
&command_list_immediate));
262+
EXPECT_NE(nullptr, command_list_immediate);
263+
264+
EXPECT_EQ(
265+
ZE_RESULT_SUCCESS,
266+
zeCommandQueueCreate(context, device, &cmdQueueDesc, &command_queue));
267+
EXPECT_NE(nullptr, command_queue);
268+
269+
for (uint32_t i = 0; i < buff_size_bytes; i++) {
270+
verification_buffer[i] = lzt::generate_value<uint8_t>(0, 255, 0);
271+
}
272+
273+
for (uint32_t i = 0; i < params.num_command_lists; i++) {
274+
275+
void *host_buffer = nullptr;
276+
ze_host_mem_alloc_desc_t hostDesc = {};
277+
hostDesc.stype = ZE_STRUCTURE_TYPE_HOST_MEM_ALLOC_DESC;
278+
hostDesc.pNext = nullptr;
279+
hostDesc.flags = 0;
280+
EXPECT_EQ(ZE_RESULT_SUCCESS,
281+
zeMemAllocHost(context, &hostDesc, buff_size_bytes, 1,
282+
(void **)(&host_buffer)));
283+
EXPECT_NE(nullptr, host_buffer);
284+
285+
uint8_t *char_input = static_cast<uint8_t *>(host_buffer);
286+
for (uint32_t j = 0; j < buff_size_bytes; j++) {
287+
char_input[j] = verification_buffer[j];
288+
}
289+
290+
host_buffers.push_back(static_cast<uint8_t *>(host_buffer));
291+
292+
void *deive_buffer = nullptr;
293+
ze_device_mem_alloc_desc_t deviceDesc = {};
294+
deviceDesc.stype = ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC;
295+
deviceDesc.ordinal = 0;
296+
deviceDesc.flags = 0;
297+
deviceDesc.pNext = nullptr;
298+
299+
EXPECT_EQ(ZE_RESULT_SUCCESS,
300+
zeMemAllocDevice(context, &deviceDesc, buff_size_bytes,
301+
buff_size_bytes, device, &deive_buffer));
302+
device_buffers.push_back(static_cast<uint8_t *>(deive_buffer));
303+
304+
ze_command_list_handle_t command_list_regular;
305+
cmdListDesc.commandQueueGroupOrdinal =
306+
lzt::getComputeQueueGroupOrdinal(device);
307+
cmdListDesc.flags = 0;
308+
EXPECT_EQ(ZE_RESULT_SUCCESS,
309+
zeCommandListCreate(context, device, &cmdListDesc,
310+
&command_list_regular));
311+
EXPECT_NE(nullptr, command_list_regular);
312+
313+
// Copy from host-allocated to device-allocated memory
314+
EXPECT_EQ(ZE_RESULT_SUCCESS,
315+
zeCommandListAppendMemoryCopy(
316+
command_list_regular, deive_buffer, host_buffer,
317+
buff_size_bytes, nullptr, 0, nullptr));
318+
319+
EXPECT_EQ(ZE_RESULT_SUCCESS,
320+
zeCommandListAppendBarrier(command_list_regular, nullptr, 0,
321+
nullptr));
322+
323+
// Copy from device-allocated memory back to host-allocated memory
324+
EXPECT_EQ(ZE_RESULT_SUCCESS,
325+
zeCommandListAppendMemoryCopy(command_list_regular, host_buffer,
326+
deive_buffer, buff_size_bytes,
327+
nullptr, 0, nullptr));
328+
329+
EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandListClose(command_list_regular));
330+
list_of_command_lists.push_back(command_list_regular);
331+
}
332+
}
333+
334+
void TearDown() override {
335+
for (uint32_t i = 0; i < params.num_command_lists; i++) {
336+
337+
EXPECT_EQ(
338+
0, memcmp(host_buffers.at(i), verification_buffer, buff_size_bytes));
339+
340+
EXPECT_EQ(ZE_RESULT_SUCCESS,
341+
zeCommandListDestroy(list_of_command_lists.at(i)));
342+
lzt::free_memory(host_buffers.at(i));
343+
lzt::free_memory(device_buffers.at(i));
344+
}
345+
lzt::destroy_command_queue(command_queue);
346+
}
347+
348+
static const uint32_t buff_size_bytes = 12;
349+
uint8_t verification_buffer[buff_size_bytes];
350+
CustomExecuteParams params = GetParam();
351+
352+
ze_command_queue_handle_t command_queue = nullptr;
353+
std::vector<ze_command_list_handle_t> list_of_command_lists;
354+
355+
std::vector<uint8_t *> host_buffers;
356+
std::vector<uint8_t *> device_buffers;
357+
358+
ze_command_list_handle_t command_list_immediate;
359+
};
360+
361+
class zeCommandListImmediateAppendCommandListsExpTestsHostSynchronize
362+
: public zeImmediateCommandListAppendCommandListsExpTests {};
363+
364+
TEST_P(
365+
zeCommandListImmediateAppendCommandListsExpTestsHostSynchronize,
366+
GivenCommandListImmediateAppendCommandListsExpAndSyncUsingCommandListHostSynchronizeThenCallSucceeds) {
367+
368+
auto command_lists_initial = list_of_command_lists;
369+
EXPECT_EQ(ZE_RESULT_SUCCESS,
370+
zeCommandListImmediateAppendCommandListsExp(
371+
command_list_immediate, params.num_command_lists,
372+
list_of_command_lists.data(), nullptr, 0, nullptr));
373+
374+
for (int i = 0; i < list_of_command_lists.size(); i++) {
375+
ASSERT_EQ(list_of_command_lists[i], command_lists_initial[i]);
376+
}
377+
378+
ze_result_t sync_status = ZE_RESULT_NOT_READY;
379+
while (sync_status != ZE_RESULT_SUCCESS) {
380+
EXPECT_EQ(sync_status, ZE_RESULT_NOT_READY);
381+
sync_status = zeCommandListHostSynchronize(command_list_immediate,
382+
params.sync_timeout);
383+
std::this_thread::yield();
384+
}
385+
}
386+
238387
CustomExecuteParams synchronize_test_input[] = {{1, 0},
239388
{2, UINT32_MAX >> 30},
240389
{3, UINT32_MAX >> 28},
@@ -254,6 +403,12 @@ INSTANTIATE_TEST_SUITE_P(TestIncreasingNumberCommandListsWithSynchronize,
254403
zeCommandQueueExecuteCommandListTestsSynchronize,
255404
testing::ValuesIn(synchronize_test_input));
256405

406+
INSTANTIATE_TEST_SUITE_P(
407+
TestIncreasingNumberCommandListImmediateAppendCommandListsExpWithSynchronize,
408+
zeCommandListImmediateAppendCommandListsExpTestsHostSynchronize,
409+
testing::ValuesIn(synchronize_test_input));
410+
411+
257412
class zeCommandQueueExecuteCommandListTestsFence
258413
: public zeCommandQueueExecuteCommandListTests {};
259414

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+
uint32_t getComputeQueueGroupOrdinal(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_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+
uint32_t getComputeQueueGroupOrdinal(ze_device_handle_t device) {
18+
uint32_t numQueueGroups = 0;
19+
EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGetCommandQueueGroupProperties(
20+
device, &numQueueGroups, nullptr));
21+
EXPECT_GT(numQueueGroups, 0) << "No queue groups found!";
22+
std::vector<ze_command_queue_group_properties_t> queueProperties(
23+
numQueueGroups);
24+
EXPECT_EQ(ZE_RESULT_SUCCESS,
25+
zeDeviceGetCommandQueueGroupProperties(device, &numQueueGroups,
26+
queueProperties.data()));
27+
uint32_t computeQueueGroupOrdinal = numQueueGroups;
28+
for (uint32_t i = 0; i < numQueueGroups; i++) {
29+
if (queueProperties[i].flags &
30+
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE) {
31+
computeQueueGroupOrdinal = i;
32+
break;
33+
}
34+
}
35+
return computeQueueGroupOrdinal;
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)