Skip to content

Commit 9e883cc

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

File tree

4 files changed

+221
-68
lines changed

4 files changed

+221
-68
lines changed

conformance_tests/core/test_barrier/src/test_barrier.cpp

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -535,19 +535,26 @@ enum BarrierType {
535535

536536
class zeBarrierKernelTests
537537
: public lzt::zeEventPoolTests,
538-
public ::testing::WithParamInterface<std::tuple<enum BarrierType, bool>> {
539-
};
538+
public ::testing::WithParamInterface<
539+
std::tuple<enum BarrierType, lzt::zeCmdListMode>> {};
540540

541541
LZT_TEST_P(
542542
zeBarrierKernelTests,
543543
GivenKernelFunctionsAndMemoryCopyWhenBarrierInsertedThenExecutionCompletesSuccesfully) {
544544
const ze_device_handle_t device = lzt::zeDevice::get_instance()->get_device();
545545
ze_context_handle_t context = lzt::create_context();
546546

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);
547+
const auto cmd_list_mode = std::get<1>(GetParam());
548+
const bool is_immediate =
549+
(cmd_list_mode == lzt::zeCmdListMode::Immediate ||
550+
cmd_list_mode == lzt::zeCmdListMode::ImmediateAppendRegular);
551+
auto bundle = lzt::create_command_bundle(context, device, is_immediate);
552+
ze_command_list_handle_t append_list = nullptr;
553+
if (cmd_list_mode == lzt::zeCmdListMode::ImmediateAppendRegular) {
554+
append_list = lzt::create_command_list(context, device);
555+
} else {
556+
append_list = bundle.list;
557+
}
551558
uint32_t num_int = 1000;
552559
void *dev_buff = lzt::allocate_device_memory((num_int * sizeof(int)), 1, 0, 0,
553560
device, context);
@@ -611,36 +618,45 @@ LZT_TEST_P(
611618
tg.groupCountY = 1;
612619
tg.groupCountZ = 1;
613620

614-
lzt::append_memory_copy(bundle.list, dev_buff, host_buff,
621+
lzt::append_memory_copy(append_list, dev_buff, host_buff,
615622
num_int * sizeof(int), signal_event_copy);
616623
// Memory barrier to ensure memory coherency after copy to device memory
617624
if (barrier_type == BT_MEMORY_RANGES_BARRIER) {
618625
const std::vector<size_t> range_sizes{num_int * sizeof(int),
619626
num_int * sizeof(int)};
620627
std::vector<const void *> ranges{dev_buff, host_buff};
621-
lzt::append_memory_ranges_barrier(bundle.list, to_u32(ranges.size()),
628+
lzt::append_memory_ranges_barrier(append_list, to_u32(ranges.size()),
622629
range_sizes.data(), ranges.data(),
623630
nullptr, 0, nullptr);
624631
} else if (barrier_type == BT_GLOBAL_BARRIER) {
625-
lzt::append_barrier(bundle.list, nullptr, 0, nullptr);
632+
lzt::append_barrier(append_list, nullptr, 0, nullptr);
626633
}
627-
lzt::append_launch_function(bundle.list, function_1, &tg, signal_event_func1,
634+
lzt::append_launch_function(append_list, function_1, &tg, signal_event_func1,
628635
num_wait, p_wait_event_func1);
629636
// Execution barrier to ensure function_1 completes before function_2 starts
630637
if (barrier_type != BT_EVENTS_BARRIER) {
631-
lzt::append_barrier(bundle.list, nullptr, 0, nullptr);
638+
lzt::append_barrier(append_list, nullptr, 0, nullptr);
632639
}
633640
ze_kernel_handle_t function_2 =
634641
lzt::create_function(module, "barrier_add_two_arrays");
635642
lzt::set_group_size(function_2, 1, 1, 1);
636643

637644
lzt::set_argument_value(function_2, 0, sizeof(p_host), &p_host);
638645
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,
646+
lzt::append_launch_function(append_list, function_2, &tg, nullptr, num_wait,
640647
p_wait_event_func2);
641648

642-
lzt::close_command_list(bundle.list);
649+
if (cmd_list_mode == lzt::zeCmdListMode::Regular ||
650+
cmd_list_mode == lzt::zeCmdListMode::ImmediateAppendRegular) {
651+
lzt::close_command_list(append_list);
652+
}
653+
654+
if (cmd_list_mode == lzt::zeCmdListMode::ImmediateAppendRegular) {
655+
lzt::append_command_lists_immediate_exp(bundle.list, 1, &append_list);
656+
}
657+
643658
lzt::execute_and_sync_command_bundle(bundle, UINT64_MAX);
659+
644660
val = (2 * val_1) + addval_2;
645661
for (uint32_t i = 0; i < num_int; i++) {
646662
EXPECT_EQ(p_host[i], val);
@@ -650,6 +666,9 @@ LZT_TEST_P(
650666
lzt::destroy_function(function_2);
651667
lzt::destroy_function(function_1);
652668
lzt::destroy_module(module);
669+
if (cmd_list_mode == lzt::zeCmdListMode::ImmediateAppendRegular) {
670+
lzt::destroy_command_list(append_list);
671+
}
653672
lzt::destroy_command_bundle(bundle);
654673
lzt::free_memory(context, host_buff);
655674
lzt::free_memory(context, dev_buff);
@@ -659,9 +678,10 @@ LZT_TEST_P(
659678

660679
INSTANTIATE_TEST_SUITE_P(
661680
TestKernelWithBarrierAndMemoryRangesBarrier, zeBarrierKernelTests,
662-
::testing::Combine(::testing::Values(BT_GLOBAL_BARRIER,
663-
BT_MEMORY_RANGES_BARRIER,
664-
BT_EVENTS_BARRIER),
665-
::testing::Bool()));
666-
681+
::testing::Combine(
682+
::testing::Values(BT_GLOBAL_BARRIER, BT_MEMORY_RANGES_BARRIER,
683+
BT_EVENTS_BARRIER),
684+
::testing::Values(lzt::zeCmdListMode::Regular,
685+
lzt::zeCmdListMode::Immediate,
686+
lzt::zeCmdListMode::ImmediateAppendRegular)));
667687
} // namespace

conformance_tests/core/test_copy/src/test_copy_events.cpp

Lines changed: 105 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -892,11 +892,20 @@ LZT_TEST_F(
892892
}
893893

894894
void RunGivenImageCopyThatWaitsOnEventWhenExecutingCommandListTest(
895-
zeCommandListEventTests &test, bool is_immediate) {
895+
zeCommandListEventTests &test, lzt::zeCmdListMode cmd_list_mode) {
896896
if (!(lzt::image_support())) {
897897
GTEST_SKIP() << "device does not support images, cannot run test";
898898
}
899+
const bool is_immediate =
900+
(cmd_list_mode == lzt::zeCmdListMode::Immediate ||
901+
cmd_list_mode == lzt::zeCmdListMode::ImmediateAppendRegular);
899902
auto cmd_bundle = lzt::create_command_bundle(is_immediate);
903+
ze_command_list_handle_t append_list = nullptr;
904+
if (cmd_list_mode == lzt::zeCmdListMode::ImmediateAppendRegular) {
905+
append_list = lzt::create_command_list();
906+
} else {
907+
append_list = cmd_bundle.list;
908+
}
900909
// create 2 images
901910
lzt::ImagePNG32Bit input("test_input.png");
902911
uint32_t width = input.width();
@@ -911,25 +920,33 @@ void RunGivenImageCopyThatWaitsOnEventWhenExecutingCommandListTest(
911920
test.ep.create_event(hEvent3, ZE_EVENT_SCOPE_FLAG_HOST, 0);
912921
test.ep.create_event(hEvent4, ZE_EVENT_SCOPE_FLAG_HOST, 0);
913922

914-
lzt::append_signal_event(cmd_bundle.list, hEvent0);
923+
lzt::append_signal_event(append_list, hEvent0);
915924

916925
// Use ImageCopyFromMemory to upload ImageA
917-
lzt::append_image_copy_from_mem(cmd_bundle.list, input_xeimage,
918-
input.raw_data(), hEvent1, 1, &hEvent0);
926+
lzt::append_image_copy_from_mem(append_list, input_xeimage, input.raw_data(),
927+
hEvent1, 1, &hEvent0);
919928
// use ImageCopy to copy A -> B
920-
lzt::append_image_copy(cmd_bundle.list, output_xeimage, input_xeimage,
921-
hEvent2, 1, &hEvent1);
929+
lzt::append_image_copy(append_list, output_xeimage, input_xeimage, hEvent2, 1,
930+
&hEvent1);
922931
// use ImageCopyRegion to copy part of A -> B
923932
ze_image_region_t sr = {0, 0, 0, 1, 1, 1};
924933
ze_image_region_t dr = {0, 0, 0, 1, 1, 1};
925-
lzt::append_image_copy_region(cmd_bundle.list, output_xeimage, input_xeimage,
926-
&dr, &sr, hEvent3, 1, &hEvent2);
934+
lzt::append_image_copy_region(append_list, output_xeimage, input_xeimage, &dr,
935+
&sr, hEvent3, 1, &hEvent2);
927936
// use ImageCopyToMemory to dowload ImageB
928-
lzt::append_image_copy_to_mem(cmd_bundle.list, output.raw_data(),
929-
output_xeimage, hEvent4, 1, &hEvent3);
930-
lzt::append_wait_on_events(cmd_bundle.list, 1, &hEvent4);
937+
lzt::append_image_copy_to_mem(append_list, output.raw_data(), output_xeimage,
938+
hEvent4, 1, &hEvent3);
939+
lzt::append_wait_on_events(append_list, 1, &hEvent4);
931940
// execute commands
932-
lzt::close_command_list(cmd_bundle.list);
941+
if (cmd_list_mode == lzt::zeCmdListMode::Regular ||
942+
cmd_list_mode == lzt::zeCmdListMode::ImmediateAppendRegular) {
943+
lzt::close_command_list(append_list);
944+
}
945+
946+
if (cmd_list_mode == lzt::zeCmdListMode::ImmediateAppendRegular) {
947+
lzt::append_command_lists_immediate_exp(cmd_bundle.list, 1, &append_list);
948+
}
949+
933950
if (!is_immediate) {
934951
lzt::execute_command_lists(cmd_bundle.queue, 1, &cmd_bundle.list, nullptr);
935952
}
@@ -958,24 +975,39 @@ void RunGivenImageCopyThatWaitsOnEventWhenExecutingCommandListTest(
958975
test.ep.destroy_event(hEvent4);
959976
lzt::destroy_ze_image(input_xeimage);
960977
lzt::destroy_ze_image(output_xeimage);
978+
if (cmd_list_mode == lzt::zeCmdListMode::ImmediateAppendRegular) {
979+
lzt::destroy_command_list(append_list);
980+
}
961981
lzt::destroy_command_bundle(cmd_bundle);
962982
}
963983

964984
LZT_TEST_F(
965985
zeCommandListEventTests,
966986
GivenImageCopyThatWaitsOnEventWhenExecutingCommandListThenCommandWaitsAndCompletesSuccessfully) {
967-
RunGivenImageCopyThatWaitsOnEventWhenExecutingCommandListTest(*this, false);
987+
RunGivenImageCopyThatWaitsOnEventWhenExecutingCommandListTest(
988+
*this, lzt::zeCmdListMode::Regular);
968989
}
969990

970991
LZT_TEST_F(
971992
zeCommandListEventTests,
972993
GivenImageCopyThatWaitsOnEventWhenExecutingImmediateCommandListThenCommandWaitsAndCompletesSuccessfully) {
973-
RunGivenImageCopyThatWaitsOnEventWhenExecutingCommandListTest(*this, true);
994+
RunGivenImageCopyThatWaitsOnEventWhenExecutingCommandListTest(
995+
*this, lzt::zeCmdListMode::Immediate);
996+
}
997+
998+
LZT_TEST_F(
999+
zeCommandListEventTests,
1000+
GivenImageCopyThatWaitsOnEventWhenExecutingImmediateCommandListAppendCmdListsThenCommandWaitsAndCompletesSuccessfully) {
1001+
RunGivenImageCopyThatWaitsOnEventWhenExecutingCommandListTest(
1002+
*this, lzt::zeCmdListMode::ImmediateAppendRegular);
9741003
}
9751004

9761005
void RunGivenSuccessiveMemoryCopiesWithEventWhenExecutingOnDifferentQueuesTest(
977-
bool is_immediate, bool is_shared_system_src, bool is_shared_system_temp,
978-
bool is_shared_system_dst) {
1006+
lzt::zeCmdListMode cmd_list_mode, bool is_shared_system_src,
1007+
bool is_shared_system_temp, bool is_shared_system_dst) {
1008+
const bool is_immediate =
1009+
(cmd_list_mode == lzt::zeCmdListMode::Immediate ||
1010+
cmd_list_mode == lzt::zeCmdListMode::ImmediateAppendRegular);
9791011
const size_t size = 1024;
9801012
auto driver = lzt::get_default_driver();
9811013
auto context = lzt::create_context(driver);
@@ -1003,9 +1035,23 @@ void RunGivenSuccessiveMemoryCopiesWithEventWhenExecutingOnDifferentQueuesTest(
10031035
auto cmd_bundle_0 = lzt::create_command_bundle(
10041036
context, device, 0, ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS,
10051037
ZE_COMMAND_QUEUE_PRIORITY_NORMAL, 0, copy_ordinals[0], 0, is_immediate);
1038+
ze_command_list_handle_t append_list_0 = nullptr;
1039+
if (cmd_list_mode == lzt::zeCmdListMode::ImmediateAppendRegular) {
1040+
append_list_0 =
1041+
lzt::create_command_list(context, device, 0, copy_ordinals[0]);
1042+
} else {
1043+
append_list_0 = cmd_bundle_0.list;
1044+
}
10061045
auto cmd_bundle_1 = lzt::create_command_bundle(
10071046
context, device, 0, ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS,
10081047
ZE_COMMAND_QUEUE_PRIORITY_NORMAL, 0, copy_ordinals[1], 0, is_immediate);
1048+
ze_command_list_handle_t append_list_1 = nullptr;
1049+
if (cmd_list_mode == lzt::zeCmdListMode::ImmediateAppendRegular) {
1050+
append_list_1 =
1051+
lzt::create_command_list(context, device, 0, copy_ordinals[1]);
1052+
} else {
1053+
append_list_1 = cmd_bundle_1.list;
1054+
}
10091055

10101056
ze_event_pool_desc_t event_pool_desc = {};
10111057
event_pool_desc.stype = ZE_STRUCTURE_TYPE_EVENT_POOL_DESC;
@@ -1029,13 +1075,24 @@ void RunGivenSuccessiveMemoryCopiesWithEventWhenExecutingOnDifferentQueuesTest(
10291075
memset(dst_buffer, 0x0, size);
10301076

10311077
// Execute and verify GPU reads event
1032-
lzt::append_memory_copy(cmd_bundle_0.list, temp_buffer, src_buffer, size,
1033-
event, 0, nullptr);
1034-
lzt::append_memory_copy(cmd_bundle_1.list, dst_buffer, temp_buffer, size,
1078+
lzt::append_memory_copy(append_list_0, temp_buffer, src_buffer, size, event,
1079+
0, nullptr);
1080+
lzt::append_memory_copy(append_list_1, dst_buffer, temp_buffer, size,
10351081
nullptr, 1, &event);
10361082

1037-
lzt::close_command_list(cmd_bundle_0.list);
1038-
lzt::close_command_list(cmd_bundle_1.list);
1083+
if (cmd_list_mode == lzt::zeCmdListMode::Regular ||
1084+
cmd_list_mode == lzt::zeCmdListMode::ImmediateAppendRegular) {
1085+
lzt::close_command_list(append_list_0);
1086+
lzt::close_command_list(append_list_1);
1087+
}
1088+
1089+
if (cmd_list_mode == lzt::zeCmdListMode::ImmediateAppendRegular) {
1090+
lzt::append_command_lists_immediate_exp(cmd_bundle_0.list, 1,
1091+
&append_list_0);
1092+
lzt::append_command_lists_immediate_exp(cmd_bundle_1.list, 1,
1093+
&append_list_1);
1094+
}
1095+
10391096
if (is_immediate) {
10401097
lzt::synchronize_command_list_host(cmd_bundle_0.list, UINT64_MAX);
10411098
lzt::synchronize_command_list_host(cmd_bundle_1.list, UINT64_MAX);
@@ -1061,28 +1118,39 @@ void RunGivenSuccessiveMemoryCopiesWithEventWhenExecutingOnDifferentQueuesTest(
10611118
is_shared_system_dst);
10621119
lzt::destroy_event(event);
10631120
lzt::destroy_event_pool(event_pool);
1121+
if (cmd_list_mode == lzt::zeCmdListMode::ImmediateAppendRegular) {
1122+
lzt::destroy_command_list(append_list_0);
1123+
lzt::destroy_command_list(append_list_1);
1124+
}
10641125
lzt::destroy_command_bundle(cmd_bundle_0);
10651126
lzt::destroy_command_bundle(cmd_bundle_1);
10661127
}
10671128
lzt::destroy_context(context);
10681129

10691130
if (!test_run) {
1070-
LOG_WARNING << "Less than 2 engines that support copy, test not run";
1131+
GTEST_SKIP() << "Less than 2 engines that support copy, test not run";
10711132
}
10721133
}
10731134

10741135
LZT_TEST(
10751136
zeCommandListCopyEventTest,
10761137
GivenSuccessiveMemoryCopiesWithEventWhenExecutingOnDifferentQueuesThenCopiesCompleteSuccessfully) {
10771138
RunGivenSuccessiveMemoryCopiesWithEventWhenExecutingOnDifferentQueuesTest(
1078-
false, false, false, false);
1139+
lzt::zeCmdListMode::Regular, false, false, false);
10791140
}
10801141

10811142
LZT_TEST(
10821143
zeCommandListCopyEventTest,
10831144
GivenSuccessiveMemoryCopiesWithEventWhenExecutingOnDifferentQueuesOnImmediateCmdListsThenCopiesCompleteSuccessfully) {
10841145
RunGivenSuccessiveMemoryCopiesWithEventWhenExecutingOnDifferentQueuesTest(
1085-
true, false, false, false);
1146+
lzt::zeCmdListMode::Immediate, false, false, false);
1147+
}
1148+
1149+
LZT_TEST(
1150+
zeCommandListCopyEventTest,
1151+
GivenSuccessiveMemoryCopiesWithEventWhenExecutingOnDifferentQueuesOnImmediateCmdListsAppendCmdListsThenCopiesCompleteSuccessfully) {
1152+
RunGivenSuccessiveMemoryCopiesWithEventWhenExecutingOnDifferentQueuesTest(
1153+
lzt::zeCmdListMode::ImmediateAppendRegular, false, false, false);
10861154
}
10871155

10881156
LZT_TEST(
@@ -1092,7 +1160,7 @@ LZT_TEST(
10921160
for (uint32_t i = 1; i < 8; ++i) {
10931161
std::bitset<3> bits(i);
10941162
RunGivenSuccessiveMemoryCopiesWithEventWhenExecutingOnDifferentQueuesTest(
1095-
false, bits[2], bits[1], bits[0]);
1163+
lzt::zeCmdListMode::Regular, bits[2], bits[1], bits[0]);
10961164
}
10971165
}
10981166

@@ -1103,7 +1171,18 @@ LZT_TEST(
11031171
for (uint32_t i = 1; i < 8; ++i) {
11041172
std::bitset<3> bits(i);
11051173
RunGivenSuccessiveMemoryCopiesWithEventWhenExecutingOnDifferentQueuesTest(
1106-
true, bits[2], bits[1], bits[0]);
1174+
lzt::zeCmdListMode::Immediate, bits[2], bits[1], bits[0]);
1175+
}
1176+
}
1177+
1178+
LZT_TEST(
1179+
zeCommandListCopyEventTest,
1180+
GivenSuccessiveMemoryCopiesWithEventWhenExecutingOnDifferentQueuesOnImmediateCmdListsAppendCmdListsThenCopiesCompleteSuccessfullyWithSharedSystemAllocator) {
1181+
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
1182+
for (uint32_t i = 1; i < 8; ++i) {
1183+
std::bitset<3> bits(i);
1184+
RunGivenSuccessiveMemoryCopiesWithEventWhenExecutingOnDifferentQueuesTest(
1185+
lzt::zeCmdListMode::ImmediateAppendRegular, bits[2], bits[1], bits[0]);
11071186
}
11081187
}
11091188

0 commit comments

Comments
 (0)