Skip to content

Commit 47b7c6c

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 b7185e3 commit 47b7c6c

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
@@ -22,33 +22,6 @@ using namespace level_zero_tests;
2222

2323
namespace {
2424

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

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

244233
// Copies proceeds as follows:
245234
// png -> source_buff -> image -> dest_buff ->png
@@ -578,6 +567,42 @@ LZT_TEST_F(
578567
lzt::free_memory(buff_out_top);
579568
}
580569

570+
LZT_TEST_F(
571+
zeCommandListAppendImageCopyTests,
572+
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingCopyEngineAndHostMemoryWithNonNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
573+
if (!(lzt::image_support())) {
574+
GTEST_SKIP();
575+
}
576+
void *buff_in_top = lzt::allocate_host_memory(image_size);
577+
void *buff_out_bot = lzt::allocate_host_memory(image_size);
578+
void *buff_in_bot = lzt::allocate_host_memory(image_size);
579+
void *buff_out_top = lzt::allocate_host_memory(image_size);
580+
test_image_mem_copy_use_regions(buff_in_bot, buff_in_top, buff_out_bot,
581+
buff_out_top, false, true);
582+
lzt::free_memory(buff_in_bot);
583+
lzt::free_memory(buff_in_top);
584+
lzt::free_memory(buff_out_bot);
585+
lzt::free_memory(buff_out_top);
586+
}
587+
588+
LZT_TEST_F(
589+
zeCommandListAppendImageCopyTests,
590+
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryToImmediateCmdListUsingCopyEngineAndHostMemoryWithNonNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
591+
if (!(lzt::image_support())) {
592+
GTEST_SKIP();
593+
}
594+
void *buff_in_top = lzt::allocate_host_memory(image_size);
595+
void *buff_out_bot = lzt::allocate_host_memory(image_size);
596+
void *buff_in_bot = lzt::allocate_host_memory(image_size);
597+
void *buff_out_top = lzt::allocate_host_memory(image_size);
598+
test_image_mem_copy_use_regions(buff_in_bot, buff_in_top, buff_out_bot,
599+
buff_out_top, true, true);
600+
lzt::free_memory(buff_in_bot);
601+
lzt::free_memory(buff_in_top);
602+
lzt::free_memory(buff_out_bot);
603+
lzt::free_memory(buff_out_top);
604+
}
605+
581606
LZT_TEST_F(
582607
zeCommandListAppendImageCopyTests,
583608
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingHostMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
@@ -586,7 +611,7 @@ LZT_TEST_F(
586611
}
587612
void *buff_in = lzt::allocate_host_memory(image_size);
588613
void *buff_out = lzt::allocate_host_memory(image_size);
589-
test_image_mem_copy_no_regions(buff_in, buff_out, false);
614+
test_image_mem_copy_no_regions(buff_in, buff_out, false, false);
590615
lzt::free_memory(buff_in);
591616
lzt::free_memory(buff_out);
592617
}
@@ -599,7 +624,33 @@ LZT_TEST_F(
599624
}
600625
void *buff_in = lzt::allocate_host_memory(image_size);
601626
void *buff_out = lzt::allocate_host_memory(image_size);
602-
test_image_mem_copy_no_regions(buff_in, buff_out, true);
627+
test_image_mem_copy_no_regions(buff_in, buff_out, true, false);
628+
lzt::free_memory(buff_in);
629+
lzt::free_memory(buff_out);
630+
}
631+
632+
LZT_TEST_F(
633+
zeCommandListAppendImageCopyTests,
634+
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingCopyEngineAndHostMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
635+
if (!(lzt::image_support())) {
636+
GTEST_SKIP();
637+
}
638+
void *buff_in = lzt::allocate_host_memory(image_size);
639+
void *buff_out = lzt::allocate_host_memory(image_size);
640+
test_image_mem_copy_no_regions(buff_in, buff_out, false, true);
641+
lzt::free_memory(buff_in);
642+
lzt::free_memory(buff_out);
643+
}
644+
645+
LZT_TEST_F(
646+
zeCommandListAppendImageCopyTests,
647+
GivenDeviceImageAndHostImageWhenAppendingImageCopyToImmediateCmdListFromMemoryUsingCopyEngineAndHostMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
648+
if (!(lzt::image_support())) {
649+
GTEST_SKIP();
650+
}
651+
void *buff_in = lzt::allocate_host_memory(image_size);
652+
void *buff_out = lzt::allocate_host_memory(image_size);
653+
test_image_mem_copy_no_regions(buff_in, buff_out, true, true);
603654
lzt::free_memory(buff_in);
604655
lzt::free_memory(buff_out);
605656
}
@@ -648,7 +699,7 @@ LZT_TEST_F(
648699
}
649700
void *buff_in = lzt::allocate_device_memory(image_size);
650701
void *buff_out = lzt::allocate_device_memory(image_size);
651-
test_image_mem_copy_no_regions(buff_in, buff_out, false);
702+
test_image_mem_copy_no_regions(buff_in, buff_out, false, false);
652703
lzt::free_memory(buff_in);
653704
lzt::free_memory(buff_out);
654705
}
@@ -661,7 +712,7 @@ LZT_TEST_F(
661712
}
662713
void *buff_in = lzt::allocate_device_memory(image_size);
663714
void *buff_out = lzt::allocate_device_memory(image_size);
664-
test_image_mem_copy_no_regions(buff_in, buff_out, true);
715+
test_image_mem_copy_no_regions(buff_in, buff_out, true, false);
665716
lzt::free_memory(buff_in);
666717
lzt::free_memory(buff_out);
667718
}
@@ -710,7 +761,7 @@ LZT_TEST_F(
710761
}
711762
void *buff_in = lzt::allocate_shared_memory(image_size);
712763
void *buff_out = lzt::allocate_shared_memory(image_size);
713-
test_image_mem_copy_no_regions(buff_in, buff_out, false);
764+
test_image_mem_copy_no_regions(buff_in, buff_out, false, false);
714765
lzt::free_memory(buff_in);
715766
lzt::free_memory(buff_out);
716767
}
@@ -723,7 +774,7 @@ LZT_TEST_F(
723774
}
724775
void *buff_in = lzt::allocate_shared_memory(image_size);
725776
void *buff_out = lzt::allocate_shared_memory(image_size);
726-
test_image_mem_copy_no_regions(buff_in, buff_out, true);
777+
test_image_mem_copy_no_regions(buff_in, buff_out, true, false);
727778
lzt::free_memory(buff_in);
728779
lzt::free_memory(buff_out);
729780
}
@@ -766,6 +817,8 @@ LZT_TEST_F(
766817
lzt::aligned_free(buff_out_top);
767818
}
768819

820+
821+
769822
LZT_TEST_F(
770823
zeCommandListAppendImageCopyTests,
771824
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryToImmediateCmdListUsingSharedSystemMemoryWithNonNullRegionsThenImageIsCorrectAndSuccessIsReturnedWithSharedSystemAllocator) {
@@ -813,7 +866,7 @@ LZT_TEST_F(
813866
}
814867
void *buff_in = lzt::aligned_malloc(image_size, 1);
815868
void *buff_out = lzt::aligned_malloc(image_size, 1);
816-
test_image_mem_copy_no_regions(buff_in, buff_out, false);
869+
test_image_mem_copy_no_regions(buff_in, buff_out, false, false);
817870
lzt::aligned_free(buff_in);
818871
lzt::aligned_free(buff_out);
819872
}
@@ -827,7 +880,35 @@ LZT_TEST_F(
827880
}
828881
void *buff_in = lzt::aligned_malloc(image_size, 1);
829882
void *buff_out = lzt::aligned_malloc(image_size, 1);
830-
test_image_mem_copy_no_regions(buff_in, buff_out, true);
883+
test_image_mem_copy_no_regions(buff_in, buff_out, true, false);
884+
lzt::aligned_free(buff_in);
885+
lzt::aligned_free(buff_out);
886+
}
887+
888+
LZT_TEST_F(
889+
zeCommandListAppendImageCopyTests,
890+
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingCopyEngineAndSharedSystemMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturnedWithSharedSystemAllocator) {
891+
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
892+
if (!(lzt::image_support())) {
893+
GTEST_SKIP();
894+
}
895+
void *buff_in = lzt::aligned_malloc(image_size, 1);
896+
void *buff_out = lzt::aligned_malloc(image_size, 1);
897+
test_image_mem_copy_no_regions(buff_in, buff_out, false, true);
898+
lzt::aligned_free(buff_in);
899+
lzt::aligned_free(buff_out);
900+
}
901+
902+
LZT_TEST_F(
903+
zeCommandListAppendImageCopyTests,
904+
GivenDeviceImageAndHostImageWhenAppendingImageCopyToImmediateCmdListFromMemoryUsingCopyEngineAndSharedSystemMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturnedWithSharedSystemAllocator) {
905+
SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED();
906+
if (!(lzt::image_support())) {
907+
GTEST_SKIP();
908+
}
909+
void *buff_in = lzt::aligned_malloc(image_size, 1);
910+
void *buff_out = lzt::aligned_malloc(image_size, 1);
911+
test_image_mem_copy_no_regions(buff_in, buff_out, true, true);
831912
lzt::aligned_free(buff_in);
832913
lzt::aligned_free(buff_out);
833914
}

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
template <typename T> inline constexpr uint8_t to_u8(T val) {
@@ -94,8 +92,8 @@ uint32_t get_driver_handle_count();
9492
uint32_t get_sub_device_count(ze_device_handle_t device);
9593

9694
std::optional<uint32_t>
97-
get_queue_ordinal(boost::span<const ze_command_queue_group_properties_t>
98-
cmd_queue_group_props,
95+
get_queue_ordinal(const std::vector<ze_command_queue_group_properties_t>
96+
&cmd_queue_group_props,
9997
ze_command_queue_group_property_flags_t include_flags,
10098
ze_command_queue_group_property_flags_t exclude_flags);
10199

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)