Skip to content

Commit

Permalink
Add Tests: (1/N) zeCommandListImmediateAppendCommandListsExp (#111)
Browse files Browse the repository at this point in the history
* added CTS for zeCommandListImmediateAppendCommandListsExp

Signed-off-by: Chandio, Bibrak Qamar <[email protected]>

* added CTS for zeCommandListImmediateAppendCommandListsExp

Signed-off-by: Chandio, Bibrak Qamar <[email protected]>

* added CTS for zeCommandListImmediateAppendCommandListsExp

Signed-off-by: Chandio, Bibrak Qamar <[email protected]>

* added CTS for zeCommandListImmediateAppendCommandListsExp

Signed-off-by: Chandio, Bibrak Qamar <[email protected]>

* added CTS for zeCommandListImmediateAppendCommandListsExp

Signed-off-by: Chandio, Bibrak Qamar <[email protected]>

* added CTS for zeCommandListImmediateAppendCommandListsExp

Signed-off-by: Chandio, Bibrak Qamar <[email protected]>

---------

Signed-off-by: Chandio, Bibrak Qamar <[email protected]>
  • Loading branch information
bibrak authored Dec 6, 2024
1 parent 3bd5926 commit d16f1a5
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 3 deletions.
118 changes: 117 additions & 1 deletion conformance_tests/core/test_cmdqueue/src/test_cmdqueue.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2019-2023 Intel Corporation
* Copyright (C) 2019-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -235,6 +235,117 @@ TEST_P(
}
}

class zeImmediateCommandListAppendCommandListsExpTests
: public ::testing::Test,
public ::testing::WithParamInterface<CustomExecuteParams> {
protected:
void SetUp() override {

const ze_driver_handle_t driver = lzt::get_default_driver();
const ze_context_handle_t context = lzt::get_default_context();
EXPECT_GT(params.num_command_lists, 0);

print_cmdqueue_exec(params.num_command_lists, params.sync_timeout);

ze_device_handle_t device = lzt::zeDevice::get_instance()->get_device();
auto ordinal = lzt::get_compute_queue_group_ordinals(device)[0];

command_list_immediate = lzt::create_immediate_command_list(
device, ZE_COMMAND_QUEUE_FLAG_IN_ORDER,
ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, ZE_COMMAND_QUEUE_PRIORITY_NORMAL,
ordinal);

command_queue = lzt::create_command_queue(
context, device, ZE_COMMAND_QUEUE_FLAG_IN_ORDER,
ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, ZE_COMMAND_QUEUE_PRIORITY_NORMAL,
ordinal);

for (uint32_t i = 0; i < buff_size_bytes; i++) {
verification_buffer[i] = lzt::generate_value<uint8_t>(0, 255, 0);
}

for (uint32_t i = 0; i < params.num_command_lists; i++) {

void *host_buffer =
lzt::allocate_host_memory(buff_size_bytes, 1, context);

uint8_t *char_input = static_cast<uint8_t *>(host_buffer);
for (uint32_t j = 0; j < buff_size_bytes; j++) {
char_input[j] = verification_buffer[j];
}

host_buffers.push_back(static_cast<uint8_t *>(host_buffer));

void *device_buffer =
lzt::allocate_device_memory(buff_size_bytes, buff_size_bytes, 0,
nullptr, ordinal, device, context);

device_buffers.push_back(static_cast<uint8_t *>(device_buffer));

ze_command_list_handle_t command_list_regular =
lzt::create_command_list(context, device, 0, ordinal);

// Copy from host-allocated to device-allocated memory
lzt::append_memory_copy(command_list_regular, device_buffer, host_buffer,
buff_size_bytes, nullptr);

lzt::append_barrier(command_list_regular, nullptr, 0, nullptr);

// Copy from device-allocated memory back to host-allocated memory
lzt::append_memory_copy(command_list_regular, host_buffer, device_buffer,
buff_size_bytes, nullptr);

lzt::close_command_list(command_list_regular);
list_of_command_lists.push_back(command_list_regular);
}
}

void TearDown() override {
for (uint32_t i = 0; i < params.num_command_lists; i++) {

EXPECT_EQ(
0, memcmp(host_buffers.at(i), verification_buffer, buff_size_bytes));

lzt::destroy_command_list(list_of_command_lists.at(i));
lzt::free_memory(host_buffers.at(i));
lzt::free_memory(device_buffers.at(i));
}
lzt::destroy_command_queue(command_queue);
}

static const uint32_t buff_size_bytes = 12;
uint8_t verification_buffer[buff_size_bytes];
CustomExecuteParams params = GetParam();

ze_command_queue_handle_t command_queue = nullptr;
std::vector<ze_command_list_handle_t> list_of_command_lists;

std::vector<uint8_t *> host_buffers;
std::vector<uint8_t *> device_buffers;

ze_command_list_handle_t command_list_immediate;
};

class zeCommandListImmediateAppendCommandListsExpTestsHostSynchronize
: public zeImmediateCommandListAppendCommandListsExpTests {};

TEST_P(
zeCommandListImmediateAppendCommandListsExpTestsHostSynchronize,
GivenCommandListImmediateAppendCommandListsExpAndSyncUsingCommandListHostSynchronizeThenCallSucceeds) {

lzt::append_command_lists_immediate_exp(command_list_immediate,
params.num_command_lists,
list_of_command_lists.data());

ze_result_t sync_status = ZE_RESULT_NOT_READY;
while (sync_status != ZE_RESULT_SUCCESS) {
EXPECT_EQ(sync_status, ZE_RESULT_NOT_READY);
sync_status = zeCommandListHostSynchronize(command_list_immediate,
params.sync_timeout);
std::this_thread::yield();
}
}

CustomExecuteParams synchronize_test_input[] = {{1, 0},
{2, UINT32_MAX >> 30},
{3, UINT32_MAX >> 28},
Expand All @@ -254,6 +365,11 @@ INSTANTIATE_TEST_SUITE_P(TestIncreasingNumberCommandListsWithSynchronize,
zeCommandQueueExecuteCommandListTestsSynchronize,
testing::ValuesIn(synchronize_test_input));

INSTANTIATE_TEST_SUITE_P(
TestIncreasingNumberCommandListImmediateAppendCommandListsExpWithSynchronize,
zeCommandListImmediateAppendCommandListsExpTestsHostSynchronize,
testing::ValuesIn(synchronize_test_input));

class zeCommandQueueExecuteCommandListTestsFence
: public zeCommandQueueExecuteCommandListTests {};

Expand Down
1 change: 1 addition & 0 deletions scripts/level_zero_report_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def assign_test_feature_tag(test_feature: str, test_name: str, test_section: str
(re.search('L0_CTS_ContextStatusTest_GivenContextCreateWhenUsingValidHandleThenContextGetStatusReturnsSuccess', test_name, re.IGNORECASE)) or \
(re.search('L0_CTS_TimestampsTest_GivenExecutedKernelWhenGettingGlobalTimestampsThenDeviceAndHostTimestampDurationsAreClose', test_name, re.IGNORECASE)) or \
(re.search('L0_CTS_TimestampsTest_GivenExecutedKernelWhenGettingGlobalTimestampsOnImmediateCmdListThenDeviceAndHostTimestampDurationsAreClose', test_name, re.IGNORECASE)) or \
(re.search('L0_CTS_TestIncreasingNumberCommandListImmediateAppendCommandListsExpWithSynchronize_zeCommandListImmediateAppendCommandListsExpTestsHostSynchronize_GivenCommandListImmediateAppendCommandListsExpAndSyncUsingCommandListHostSynchronizeThenCallSucceeds', test_name, re.IGNORECASE)) or \
(re.search('L0_CTS_zeCommandListAppendMemoryCopyTest_GivenCommandListWithMultipleAppendMemoryCopiesFollowedByResetInLoopThenSuccessIsReturned', test_name, re.IGNORECASE)) or \
(re.search('L0_CTS_zeCommandListAppendMemoryCopyTest_GivenTwoCommandQueuesHavingCommandListsWithScratchSpaceThenSuccessIsReturned', test_name, re.IGNORECASE)) or \
(re.search('L0_CTS_zeCommandListAppendMemoryFillVerificationTests_GivenHostMemoryWhenExecutingAMemoryFillOnImmediateCmdListThenMemoryIsSetCorrectly', test_name, re.IGNORECASE)) or \
Expand Down
11 changes: 11 additions & 0 deletions utils/test_harness/include/test_harness/test_harness_cmdlist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ ze_command_list_handle_t create_immediate_command_list(

ze_command_list_handle_t create_immediate_command_list();

void append_command_lists_immediate_exp(
ze_command_list_handle_t hCommandList, uint32_t numCommandLists,
ze_command_list_handle_t *phCommandLists, ze_event_handle_t hSignalEvent);
void append_command_lists_immediate_exp(
ze_command_list_handle_t hCommandList, uint32_t numCommandLists,
ze_command_list_handle_t *phCommandLists);
void append_command_lists_immediate_exp(
ze_command_list_handle_t hCommandList, uint32_t numCommandLists,
ze_command_list_handle_t *phCommandLists, ze_event_handle_t hSignalEvent,
uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents);

zeCommandBundle create_command_bundle(bool isImmediate);
zeCommandBundle create_command_bundle(ze_device_handle_t device,
bool isImmediate);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2019 Intel Corporation
* Copyright (C) 2019-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -28,6 +28,7 @@ class zeCommandQueueTests : public ::testing::Test {
zeCommandQueue cq;
};

std::vector<uint32_t> get_compute_queue_group_ordinals(ze_device_handle_t device);
ze_command_queue_handle_t create_command_queue();
ze_command_queue_handle_t create_command_queue(ze_device_handle_t device);
ze_command_queue_handle_t create_command_queue(ze_context_handle_t context,
Expand Down
40 changes: 40 additions & 0 deletions utils/test_harness/src/test_harness_cmdlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,46 @@ ze_command_list_handle_t create_immediate_command_list(
return command_list;
}

void append_command_lists_immediate_exp(
ze_command_list_handle_t hCommandList, uint32_t numCommandLists,
ze_command_list_handle_t *phCommandLists, ze_event_handle_t hSignalEvent) {
append_command_lists_immediate_exp(hCommandList, numCommandLists,
phCommandLists, hSignalEvent, 0, nullptr);
}

void append_command_lists_immediate_exp(
ze_command_list_handle_t hCommandList, uint32_t numCommandLists,
ze_command_list_handle_t *phCommandLists) {
append_command_lists_immediate_exp(hCommandList, numCommandLists,
phCommandLists, nullptr, 0, nullptr);
}

void append_command_lists_immediate_exp(
ze_command_list_handle_t hCommandList, uint32_t numCommandLists,
ze_command_list_handle_t *phCommandLists, ze_event_handle_t hSignalEvent,
uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents) {
auto command_list_initial = hCommandList;
std::vector<ze_command_list_handle_t> command_lists_initial(numCommandLists);
std::memcpy(command_lists_initial.data(), phCommandLists,
sizeof(ze_command_list_handle_t) * numCommandLists);
auto signal_event_initial = hSignalEvent;
std::vector<ze_event_handle_t> wait_events_initial(numWaitEvents);
std::memcpy(wait_events_initial.data(), phWaitEvents,
sizeof(ze_event_handle_t) * numWaitEvents);
EXPECT_EQ(ZE_RESULT_SUCCESS,
zeCommandListImmediateAppendCommandListsExp(
hCommandList, numCommandLists, phCommandLists, hSignalEvent,
numWaitEvents, phWaitEvents));
EXPECT_EQ(hCommandList, command_list_initial);
EXPECT_EQ(hSignalEvent, signal_event_initial);
for (int i = 0; i < numCommandLists; i++) {
EXPECT_EQ(phCommandLists[i], command_lists_initial[i]);
}
for (int i = 0; i < numWaitEvents; i++) {
EXPECT_EQ(phWaitEvents[i], wait_events_initial[i]);
}
}

zeCommandBundle create_command_bundle(bool isImmediate) {
return create_command_bundle(zeDevice::get_instance()->get_device(),
isImmediate);
Expand Down
23 changes: 22 additions & 1 deletion utils/test_harness/src/test_harness_cmdqueue.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2019 Intel Corporation
* Copyright (C) 2019-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -14,6 +14,27 @@ namespace lzt = level_zero_tests;

namespace level_zero_tests {

std::vector<uint32_t> get_compute_queue_group_ordinals(ze_device_handle_t device) {
uint32_t num_queue_groups = 0;
EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGetCommandQueueGroupProperties(
device, &num_queue_groups, nullptr));
EXPECT_GT(num_queue_groups, 0) << "No queue groups found!";
std::vector<ze_command_queue_group_properties_t> queue_properties(
num_queue_groups);
EXPECT_EQ(ZE_RESULT_SUCCESS,
zeDeviceGetCommandQueueGroupProperties(device, &num_queue_groups,
queue_properties.data()));
std::vector<uint32_t> compute_queue_group_ordinals = {};
for (uint32_t i = 0; i < num_queue_groups; i++) {
if (queue_properties[i].flags &
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE) {
compute_queue_group_ordinals.push_back(i);
break;
}
}
return compute_queue_group_ordinals;
}

ze_command_queue_handle_t create_command_queue() {
return create_command_queue(zeDevice::get_instance()->get_device());
}
Expand Down

0 comments on commit d16f1a5

Please sign in to comment.