Skip to content

Commit c6f452a

Browse files
committed
Add zeCommandListImmediateAppendCommandListsExp test cases
Signed-off-by: Oskar Hubert Weber <oskar.hubert.weber@intel.com>
1 parent ed16a93 commit c6f452a

File tree

4 files changed

+274
-69
lines changed

4 files changed

+274
-69
lines changed

conformance_tests/core/test_barrier/src/test_barrier.cpp

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ namespace {
1919

2020
using lzt::to_u32;
2121

22+
enum class zeCmdListMode { Regular = 0, Immediate, ImmediateAppendRegular };
23+
2224
class zeCommandListAppendBarrierTests : public ::testing::Test {
2325
public:
2426
void run(bool isImmediate) {
@@ -533,9 +535,9 @@ enum BarrierType {
533535
BT_EVENTS_BARRIER
534536
};
535537

536-
class zeBarrierKernelTests
537-
: public lzt::zeEventPoolTests,
538-
public ::testing::WithParamInterface<std::tuple<enum BarrierType, bool>> {
538+
class zeBarrierKernelTests : public lzt::zeEventPoolTests,
539+
public ::testing::WithParamInterface<
540+
std::tuple<enum BarrierType, zeCmdListMode>> {
539541
};
540542

541543
LZT_TEST_P(
@@ -544,10 +546,17 @@ LZT_TEST_P(
544546
const ze_device_handle_t device = lzt::zeDevice::get_instance()->get_device();
545547
ze_context_handle_t context = lzt::create_context();
546548

547-
const bool isImmediate = std::get<1>(GetParam());
548-
auto bundle = lzt::create_command_bundle(
549-
context, device, 0, ZE_COMMAND_QUEUE_MODE_DEFAULT,
550-
ZE_COMMAND_QUEUE_PRIORITY_NORMAL, 0, 0, 0, isImmediate);
549+
const auto cmd_list_mode = std::get<1>(GetParam());
550+
const bool is_immediate =
551+
(cmd_list_mode == zeCmdListMode::Immediate ||
552+
cmd_list_mode == zeCmdListMode::ImmediateAppendRegular);
553+
auto bundle = lzt::create_command_bundle(context, device, is_immediate);
554+
ze_command_list_handle_t append_list = nullptr;
555+
if (cmd_list_mode == zeCmdListMode::ImmediateAppendRegular) {
556+
append_list = lzt::create_command_list(context, device);
557+
} else {
558+
append_list = bundle.list;
559+
}
551560
uint32_t num_int = 1000;
552561
void *dev_buff = lzt::allocate_device_memory((num_int * sizeof(int)), 1, 0, 0,
553562
device, context);
@@ -611,36 +620,45 @@ LZT_TEST_P(
611620
tg.groupCountY = 1;
612621
tg.groupCountZ = 1;
613622

614-
lzt::append_memory_copy(bundle.list, dev_buff, host_buff,
623+
lzt::append_memory_copy(append_list, dev_buff, host_buff,
615624
num_int * sizeof(int), signal_event_copy);
616625
// Memory barrier to ensure memory coherency after copy to device memory
617626
if (barrier_type == BT_MEMORY_RANGES_BARRIER) {
618627
const std::vector<size_t> range_sizes{num_int * sizeof(int),
619628
num_int * sizeof(int)};
620629
std::vector<const void *> ranges{dev_buff, host_buff};
621-
lzt::append_memory_ranges_barrier(bundle.list, to_u32(ranges.size()),
630+
lzt::append_memory_ranges_barrier(append_list, to_u32(ranges.size()),
622631
range_sizes.data(), ranges.data(),
623632
nullptr, 0, nullptr);
624633
} else if (barrier_type == BT_GLOBAL_BARRIER) {
625-
lzt::append_barrier(bundle.list, nullptr, 0, nullptr);
634+
lzt::append_barrier(append_list, nullptr, 0, nullptr);
626635
}
627-
lzt::append_launch_function(bundle.list, function_1, &tg, signal_event_func1,
636+
lzt::append_launch_function(append_list, function_1, &tg, signal_event_func1,
628637
num_wait, p_wait_event_func1);
629638
// Execution barrier to ensure function_1 completes before function_2 starts
630639
if (barrier_type != BT_EVENTS_BARRIER) {
631-
lzt::append_barrier(bundle.list, nullptr, 0, nullptr);
640+
lzt::append_barrier(append_list, nullptr, 0, nullptr);
632641
}
633642
ze_kernel_handle_t function_2 =
634643
lzt::create_function(module, "barrier_add_two_arrays");
635644
lzt::set_group_size(function_2, 1, 1, 1);
636645

637646
lzt::set_argument_value(function_2, 0, sizeof(p_host), &p_host);
638647
lzt::set_argument_value(function_2, 1, sizeof(p_dev), &p_dev);
639-
lzt::append_launch_function(bundle.list, function_2, &tg, nullptr, num_wait,
648+
lzt::append_launch_function(append_list, function_2, &tg, nullptr, num_wait,
640649
p_wait_event_func2);
641650

642-
lzt::close_command_list(bundle.list);
651+
if (cmd_list_mode == zeCmdListMode::Regular ||
652+
cmd_list_mode == zeCmdListMode::ImmediateAppendRegular) {
653+
lzt::close_command_list(append_list);
654+
}
655+
656+
if (cmd_list_mode == zeCmdListMode::ImmediateAppendRegular) {
657+
lzt::append_command_lists_immediate_exp(bundle.list, 1, &append_list);
658+
}
659+
643660
lzt::execute_and_sync_command_bundle(bundle, UINT64_MAX);
661+
644662
val = (2 * val_1) + addval_2;
645663
for (uint32_t i = 0; i < num_int; i++) {
646664
EXPECT_EQ(p_host[i], val);
@@ -650,6 +668,9 @@ LZT_TEST_P(
650668
lzt::destroy_function(function_2);
651669
lzt::destroy_function(function_1);
652670
lzt::destroy_module(module);
671+
if (cmd_list_mode == zeCmdListMode::ImmediateAppendRegular) {
672+
lzt::destroy_command_list(append_list);
673+
}
653674
lzt::destroy_command_bundle(bundle);
654675
lzt::free_memory(context, host_buff);
655676
lzt::free_memory(context, dev_buff);
@@ -659,9 +680,9 @@ LZT_TEST_P(
659680

660681
INSTANTIATE_TEST_SUITE_P(
661682
TestKernelWithBarrierAndMemoryRangesBarrier, zeBarrierKernelTests,
662-
::testing::Combine(::testing::Values(BT_GLOBAL_BARRIER,
663-
BT_MEMORY_RANGES_BARRIER,
664-
BT_EVENTS_BARRIER),
665-
::testing::Bool()));
666-
683+
::testing::Combine(
684+
::testing::Values(BT_GLOBAL_BARRIER, BT_MEMORY_RANGES_BARRIER,
685+
BT_EVENTS_BARRIER),
686+
::testing::Values(zeCmdListMode::Regular, zeCmdListMode::Immediate,
687+
zeCmdListMode::ImmediateAppendRegular)));
667688
} // namespace

conformance_tests/core/test_cmdqueue/src/test_cmdqueue.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,56 @@ INSTANTIATE_TEST_SUITE_P(
376376
zeCommandListImmediateAppendCommandListsExpTestsHostSynchronize,
377377
testing::ValuesIn(synchronize_test_input));
378378

379+
class zeCommandListImmediateAppendCommandListsExpTestsEventSynchronize
380+
: public zeImmediateCommandListAppendCommandListsExpTests {};
381+
382+
LZT_TEST_P(
383+
zeCommandListImmediateAppendCommandListsExpTestsEventSynchronize,
384+
GivenCommandListImmediateAppendCommandListsExpAndSyncUsingEventHostSynchronizeThenCallSucceeds) {
385+
lzt::zeEventPool ep;
386+
ze_event_handle_t hSignalEvent;
387+
388+
ep.create_event(hSignalEvent, ZE_EVENT_SCOPE_FLAG_HOST, 0);
389+
390+
EXPECT_EQ(ZE_RESULT_NOT_READY, zeEventHostSynchronize(hSignalEvent, 0));
391+
392+
lzt::append_command_lists_immediate_exp(
393+
command_list_immediate, params.num_command_lists,
394+
list_of_command_lists.data(), hSignalEvent);
395+
396+
lzt::event_host_synchronize(hSignalEvent, params.sync_timeout);
397+
}
398+
399+
LZT_TEST_P(
400+
zeCommandListImmediateAppendCommandListsExpTestsEventSynchronize,
401+
GivenCommandListImmediateAppendCommandListsExpWithWaitAndSignalEventsThenVerifyBuffersValid) {
402+
lzt::zeEventPool ep;
403+
ze_event_handle_t hSignalEvent;
404+
405+
ep.create_event(hSignalEvent, ZE_EVENT_SCOPE_FLAG_HOST, 0);
406+
407+
EXPECT_EQ(ZE_RESULT_NOT_READY, zeEventHostSynchronize(hSignalEvent, 0));
408+
409+
lzt::append_command_lists_immediate_exp(
410+
command_list_immediate, params.num_command_lists / 2,
411+
list_of_command_lists.data(), hSignalEvent);
412+
lzt::append_command_lists_immediate_exp(
413+
command_list_immediate, params.num_command_lists / 2,
414+
list_of_command_lists.data() + (params.num_command_lists / 2), nullptr, 1,
415+
&hSignalEvent);
416+
417+
lzt::synchronize_command_list_host(command_list_immediate, UINT64_MAX);
418+
}
419+
420+
CustomExecuteParams event_test_input[] = {
421+
{2, UINT64_MAX}, {4, UINT64_MAX}, {8, UINT64_MAX}, {16, UINT64_MAX},
422+
{32, UINT64_MAX}, {64, UINT64_MAX}, {100, UINT64_MAX}};
423+
424+
INSTANTIATE_TEST_SUITE_P(
425+
TestIncreasingNumberCommandListImmediateAppendCommandListsExpWithEventSynchronize,
426+
zeCommandListImmediateAppendCommandListsExpTestsEventSynchronize,
427+
testing::ValuesIn(event_test_input));
428+
379429
class zeCommandQueueExecuteCommandListTestsFence
380430
: public zeCommandQueueExecuteCommandListTests {};
381431

0 commit comments

Comments
 (0)