Skip to content

Commit 3f70663

Browse files
Add scenarios using BCS to image SVM tests
- Added new scenarios - Refactored code for choosing queue ordinals Signed-off-by: Misiak, Konstanty <[email protected]>
1 parent 4928f54 commit 3f70663

File tree

3 files changed

+122
-43
lines changed

3 files changed

+122
-43
lines changed

conformance_tests/core/test_copy/src/test_copy_image.cpp

Lines changed: 118 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,6 @@ using namespace level_zero_tests;
2323

2424
namespace {
2525

26-
/*void get_copy_and_compute_ordinals(
27-
const std::vector<ze_command_queue_group_properties_t>
28-
&cmd_queue_group_props,
29-
int &compute_ordinal, int &copy_ordinal) {
30-
compute_ordinal = -1;
31-
copy_ordinal = -1;
32-
for (uint32_t i = 0; i < cmd_queue_group_props.size(); i++) {
33-
if (cmd_queue_group_props[i].flags &
34-
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE &&
35-
cmd_queue_group_props[i].flags &
36-
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS &&
37-
compute_ordinal < 0) {
38-
compute_ordinal = i;
39-
}
40-
if (cmd_queue_group_props[i].flags &
41-
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY &&
42-
!(cmd_queue_group_props[i].flags &
43-
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE) &&
44-
copy_ordinal < 0) {
45-
copy_ordinal = i;
46-
}
47-
if (compute_ordinal >= 0 && copy_ordinal >= 0) {
48-
break;
49-
}
50-
}
51-
}*/
52-
5326
class zeCommandListAppendImageCopyTests : public ::testing::Test {
5427
public:
5528
zeCommandListAppendImageCopyTests() {
@@ -239,8 +212,24 @@ class zeCommandListAppendImageCopyTests : public ::testing::Test {
239212
}
240213

241214
void test_image_mem_copy_no_regions(void *source_buff, void *dest_buff,
242-
bool is_immediate) {
243-
auto cmd_bundle = lzt::create_command_bundle(is_immediate);
215+
bool is_immediate, bool use_copy_engine) {
216+
auto cmd_queue_group_props = get_command_queue_group_properties(
217+
zeDevice::get_instance()->get_device());
218+
219+
auto compute_ordinal = lzt::get_queue_ordinal(
220+
cmd_queue_group_props,
221+
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE |
222+
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS,
223+
0);
224+
auto copy_ordinal = lzt::get_queue_ordinal(
225+
cmd_queue_group_props, ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY,
226+
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE);
227+
ASSERT_TRUE((use_copy_engine && copy_ordinal) ||
228+
(!use_copy_engine && compute_ordinal));
229+
230+
auto cmd_bundle = lzt::create_command_bundle(
231+
lzt::get_default_context(), zeDevice::get_instance()->get_device(), 0,
232+
use_copy_engine ? *copy_ordinal : *compute_ordinal, is_immediate);
244233

245234
// Copies proceeds as follows:
246235
// png -> source_buff -> image -> dest_buff ->png
@@ -579,6 +568,42 @@ LZT_TEST_F(
579568
lzt::free_memory(buff_out_top);
580569
}
581570

571+
LZT_TEST_F(
572+
zeCommandListAppendImageCopyTests,
573+
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingCopyEngineAndHostMemoryWithNonNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
574+
if (!(lzt::image_support())) {
575+
GTEST_SKIP();
576+
}
577+
void *buff_in_top = lzt::allocate_host_memory(image_size);
578+
void *buff_out_bot = lzt::allocate_host_memory(image_size);
579+
void *buff_in_bot = lzt::allocate_host_memory(image_size);
580+
void *buff_out_top = lzt::allocate_host_memory(image_size);
581+
test_image_mem_copy_use_regions(buff_in_bot, buff_in_top, buff_out_bot,
582+
buff_out_top, false, true);
583+
lzt::free_memory(buff_in_bot);
584+
lzt::free_memory(buff_in_top);
585+
lzt::free_memory(buff_out_bot);
586+
lzt::free_memory(buff_out_top);
587+
}
588+
589+
LZT_TEST_F(
590+
zeCommandListAppendImageCopyTests,
591+
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryToImmediateCmdListUsingCopyEngineAndHostMemoryWithNonNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
592+
if (!(lzt::image_support())) {
593+
GTEST_SKIP();
594+
}
595+
void *buff_in_top = lzt::allocate_host_memory(image_size);
596+
void *buff_out_bot = lzt::allocate_host_memory(image_size);
597+
void *buff_in_bot = lzt::allocate_host_memory(image_size);
598+
void *buff_out_top = lzt::allocate_host_memory(image_size);
599+
test_image_mem_copy_use_regions(buff_in_bot, buff_in_top, buff_out_bot,
600+
buff_out_top, true, true);
601+
lzt::free_memory(buff_in_bot);
602+
lzt::free_memory(buff_in_top);
603+
lzt::free_memory(buff_out_bot);
604+
lzt::free_memory(buff_out_top);
605+
}
606+
582607
LZT_TEST_F(
583608
zeCommandListAppendImageCopyTests,
584609
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingHostMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
@@ -587,7 +612,7 @@ LZT_TEST_F(
587612
}
588613
void *buff_in = lzt::allocate_host_memory(image_size);
589614
void *buff_out = lzt::allocate_host_memory(image_size);
590-
test_image_mem_copy_no_regions(buff_in, buff_out, false);
615+
test_image_mem_copy_no_regions(buff_in, buff_out, false, false);
591616
lzt::free_memory(buff_in);
592617
lzt::free_memory(buff_out);
593618
}
@@ -600,7 +625,33 @@ LZT_TEST_F(
600625
}
601626
void *buff_in = lzt::allocate_host_memory(image_size);
602627
void *buff_out = lzt::allocate_host_memory(image_size);
603-
test_image_mem_copy_no_regions(buff_in, buff_out, true);
628+
test_image_mem_copy_no_regions(buff_in, buff_out, true, false);
629+
lzt::free_memory(buff_in);
630+
lzt::free_memory(buff_out);
631+
}
632+
633+
LZT_TEST_F(
634+
zeCommandListAppendImageCopyTests,
635+
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingCopyEngineAndHostMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
636+
if (!(lzt::image_support())) {
637+
GTEST_SKIP();
638+
}
639+
void *buff_in = lzt::allocate_host_memory(image_size);
640+
void *buff_out = lzt::allocate_host_memory(image_size);
641+
test_image_mem_copy_no_regions(buff_in, buff_out, false, true);
642+
lzt::free_memory(buff_in);
643+
lzt::free_memory(buff_out);
644+
}
645+
646+
LZT_TEST_F(
647+
zeCommandListAppendImageCopyTests,
648+
GivenDeviceImageAndHostImageWhenAppendingImageCopyToImmediateCmdListFromMemoryUsingCopyEngineAndHostMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
649+
if (!(lzt::image_support())) {
650+
GTEST_SKIP();
651+
}
652+
void *buff_in = lzt::allocate_host_memory(image_size);
653+
void *buff_out = lzt::allocate_host_memory(image_size);
654+
test_image_mem_copy_no_regions(buff_in, buff_out, true, true);
604655
lzt::free_memory(buff_in);
605656
lzt::free_memory(buff_out);
606657
}
@@ -649,7 +700,7 @@ LZT_TEST_F(
649700
}
650701
void *buff_in = lzt::allocate_device_memory(image_size);
651702
void *buff_out = lzt::allocate_device_memory(image_size);
652-
test_image_mem_copy_no_regions(buff_in, buff_out, false);
703+
test_image_mem_copy_no_regions(buff_in, buff_out, false, false);
653704
lzt::free_memory(buff_in);
654705
lzt::free_memory(buff_out);
655706
}
@@ -662,7 +713,7 @@ LZT_TEST_F(
662713
}
663714
void *buff_in = lzt::allocate_device_memory(image_size);
664715
void *buff_out = lzt::allocate_device_memory(image_size);
665-
test_image_mem_copy_no_regions(buff_in, buff_out, true);
716+
test_image_mem_copy_no_regions(buff_in, buff_out, true, false);
666717
lzt::free_memory(buff_in);
667718
lzt::free_memory(buff_out);
668719
}
@@ -711,7 +762,7 @@ LZT_TEST_F(
711762
}
712763
void *buff_in = lzt::allocate_shared_memory(image_size);
713764
void *buff_out = lzt::allocate_shared_memory(image_size);
714-
test_image_mem_copy_no_regions(buff_in, buff_out, false);
765+
test_image_mem_copy_no_regions(buff_in, buff_out, false, false);
715766
lzt::free_memory(buff_in);
716767
lzt::free_memory(buff_out);
717768
}
@@ -724,7 +775,7 @@ LZT_TEST_F(
724775
}
725776
void *buff_in = lzt::allocate_shared_memory(image_size);
726777
void *buff_out = lzt::allocate_shared_memory(image_size);
727-
test_image_mem_copy_no_regions(buff_in, buff_out, true);
778+
test_image_mem_copy_no_regions(buff_in, buff_out, true, false);
728779
lzt::free_memory(buff_in);
729780
lzt::free_memory(buff_out);
730781
}
@@ -767,6 +818,8 @@ LZT_TEST_F(
767818
lzt::aligned_free(buff_out_top);
768819
}
769820

821+
822+
770823
LZT_TEST_F(
771824
zeCommandListAppendImageCopyTests,
772825
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryToImmediateCmdListUsingSharedSystemMemoryWithNonNullRegionsThenImageIsCorrectAndSuccessIsReturnedWithSharedSystemAllocator) {
@@ -814,7 +867,7 @@ LZT_TEST_F(
814867
}
815868
void *buff_in = lzt::aligned_malloc(image_size, 1);
816869
void *buff_out = lzt::aligned_malloc(image_size, 1);
817-
test_image_mem_copy_no_regions(buff_in, buff_out, false);
870+
test_image_mem_copy_no_regions(buff_in, buff_out, false, false);
818871
lzt::aligned_free(buff_in);
819872
lzt::aligned_free(buff_out);
820873
}
@@ -828,7 +881,35 @@ LZT_TEST_F(
828881
}
829882
void *buff_in = lzt::aligned_malloc(image_size, 1);
830883
void *buff_out = lzt::aligned_malloc(image_size, 1);
831-
test_image_mem_copy_no_regions(buff_in, buff_out, true);
884+
test_image_mem_copy_no_regions(buff_in, buff_out, true, false);
885+
lzt::aligned_free(buff_in);
886+
lzt::aligned_free(buff_out);
887+
}
888+
889+
LZT_TEST_F(
890+
zeCommandListAppendImageCopyTests,
891+
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingCopyEngineAndSharedSystemMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturnedWithSharedSystemAllocator) {
892+
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
893+
if (!(lzt::image_support())) {
894+
GTEST_SKIP();
895+
}
896+
void *buff_in = lzt::aligned_malloc(image_size, 1);
897+
void *buff_out = lzt::aligned_malloc(image_size, 1);
898+
test_image_mem_copy_no_regions(buff_in, buff_out, false, true);
899+
lzt::aligned_free(buff_in);
900+
lzt::aligned_free(buff_out);
901+
}
902+
903+
LZT_TEST_F(
904+
zeCommandListAppendImageCopyTests,
905+
GivenDeviceImageAndHostImageWhenAppendingImageCopyToImmediateCmdListFromMemoryUsingCopyEngineAndSharedSystemMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturnedWithSharedSystemAllocator) {
906+
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
907+
if (!(lzt::image_support())) {
908+
GTEST_SKIP();
909+
}
910+
void *buff_in = lzt::aligned_malloc(image_size, 1);
911+
void *buff_out = lzt::aligned_malloc(image_size, 1);
912+
test_image_mem_copy_no_regions(buff_in, buff_out, true, true);
832913
lzt::aligned_free(buff_in);
833914
lzt::aligned_free(buff_out);
834915
}

utils/utils/include/utils/utils.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#include "utils/utils_string.hpp"
2020
#include "utils/utils_gtest_helper.hpp"
2121

22-
#include <boost/core/span.hpp>
23-
2422
namespace level_zero_tests {
2523

2624
zes_driver_handle_t get_default_zes_driver();
@@ -49,8 +47,8 @@ uint32_t get_driver_handle_count();
4947
uint32_t get_sub_device_count(ze_device_handle_t device);
5048

5149
std::optional<uint32_t>
52-
get_queue_ordinal(boost::span<const ze_command_queue_group_properties_t>
53-
cmd_queue_group_props,
50+
get_queue_ordinal(const std::vector<ze_command_queue_group_properties_t>
51+
&cmd_queue_group_props,
5452
ze_command_queue_group_property_flags_t include_flags,
5553
ze_command_queue_group_property_flags_t exclude_flags);
5654

utils/utils/src/utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ void sort_devices(std::vector<ze_device_handle_t> &devices) {
345345
}
346346

347347
std::optional<uint32_t>
348-
get_queue_ordinal(boost::span<const ze_command_queue_group_properties_t>
349-
cmd_queue_group_props,
348+
get_queue_ordinal(const std::vector<ze_command_queue_group_properties_t>
349+
&cmd_queue_group_props,
350350
ze_command_queue_group_property_flags_t include_flags,
351351
ze_command_queue_group_property_flags_t exclude_flags) {
352352
for (uint32_t i = 0; i < cmd_queue_group_props.size(); i++) {

0 commit comments

Comments
 (0)