11/*
22 *
3- * Copyright (C) 2019-2023 Intel Corporation
3+ * Copyright (C) 2019-2025 Intel Corporation
44 *
55 * SPDX-License-Identifier: MIT
66 *
@@ -19,6 +19,8 @@ namespace {
1919
2020using lzt::to_u32;
2121
22+ enum class zeCmdListMode { Regular = 0 , Immediate, ImmediateAppendRegular };
23+
2224class zeCommandListAppendBarrierTests : public ::testing::Test {
2325public:
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
541543LZT_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
660681INSTANTIATE_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
0 commit comments