@@ -23,33 +23,6 @@ using namespace level_zero_tests;
23
23
24
24
namespace {
25
25
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 ©_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
-
53
26
class zeCommandListAppendImageCopyTests : public ::testing::Test {
54
27
public:
55
28
zeCommandListAppendImageCopyTests () {
@@ -239,8 +212,24 @@ class zeCommandListAppendImageCopyTests : public ::testing::Test {
239
212
}
240
213
241
214
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);
244
233
245
234
// Copies proceeds as follows:
246
235
// png -> source_buff -> image -> dest_buff ->png
@@ -579,6 +568,42 @@ LZT_TEST_F(
579
568
lzt::free_memory (buff_out_top);
580
569
}
581
570
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
+
582
607
LZT_TEST_F (
583
608
zeCommandListAppendImageCopyTests,
584
609
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingHostMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
@@ -587,7 +612,7 @@ LZT_TEST_F(
587
612
}
588
613
void *buff_in = lzt::allocate_host_memory (image_size);
589
614
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 );
591
616
lzt::free_memory (buff_in);
592
617
lzt::free_memory (buff_out);
593
618
}
@@ -600,7 +625,33 @@ LZT_TEST_F(
600
625
}
601
626
void *buff_in = lzt::allocate_host_memory (image_size);
602
627
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 );
604
655
lzt::free_memory (buff_in);
605
656
lzt::free_memory (buff_out);
606
657
}
@@ -649,7 +700,7 @@ LZT_TEST_F(
649
700
}
650
701
void *buff_in = lzt::allocate_device_memory (image_size);
651
702
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 );
653
704
lzt::free_memory (buff_in);
654
705
lzt::free_memory (buff_out);
655
706
}
@@ -662,7 +713,7 @@ LZT_TEST_F(
662
713
}
663
714
void *buff_in = lzt::allocate_device_memory (image_size);
664
715
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 );
666
717
lzt::free_memory (buff_in);
667
718
lzt::free_memory (buff_out);
668
719
}
@@ -711,7 +762,7 @@ LZT_TEST_F(
711
762
}
712
763
void *buff_in = lzt::allocate_shared_memory (image_size);
713
764
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 );
715
766
lzt::free_memory (buff_in);
716
767
lzt::free_memory (buff_out);
717
768
}
@@ -724,7 +775,7 @@ LZT_TEST_F(
724
775
}
725
776
void *buff_in = lzt::allocate_shared_memory (image_size);
726
777
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 );
728
779
lzt::free_memory (buff_in);
729
780
lzt::free_memory (buff_out);
730
781
}
@@ -767,6 +818,8 @@ LZT_TEST_F(
767
818
lzt::aligned_free (buff_out_top);
768
819
}
769
820
821
+
822
+
770
823
LZT_TEST_F (
771
824
zeCommandListAppendImageCopyTests,
772
825
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryToImmediateCmdListUsingSharedSystemMemoryWithNonNullRegionsThenImageIsCorrectAndSuccessIsReturnedWithSharedSystemAllocator) {
@@ -814,7 +867,7 @@ LZT_TEST_F(
814
867
}
815
868
void *buff_in = lzt::aligned_malloc (image_size, 1 );
816
869
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 );
818
871
lzt::aligned_free (buff_in);
819
872
lzt::aligned_free (buff_out);
820
873
}
@@ -828,7 +881,35 @@ LZT_TEST_F(
828
881
}
829
882
void *buff_in = lzt::aligned_malloc (image_size, 1 );
830
883
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 );
832
913
lzt::aligned_free (buff_in);
833
914
lzt::aligned_free (buff_out);
834
915
}
0 commit comments