@@ -22,33 +22,6 @@ using namespace level_zero_tests;
22
22
23
23
namespace {
24
24
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 ©_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
-
52
25
class zeCommandListAppendImageCopyTests : public ::testing::Test {
53
26
public:
54
27
zeCommandListAppendImageCopyTests () {
@@ -238,8 +211,24 @@ class zeCommandListAppendImageCopyTests : public ::testing::Test {
238
211
}
239
212
240
213
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);
243
232
244
233
// Copies proceeds as follows:
245
234
// png -> source_buff -> image -> dest_buff ->png
@@ -578,6 +567,42 @@ LZT_TEST_F(
578
567
lzt::free_memory (buff_out_top);
579
568
}
580
569
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
+
581
606
LZT_TEST_F (
582
607
zeCommandListAppendImageCopyTests,
583
608
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryUsingHostMemoryWithNullRegionsThenImageIsCorrectAndSuccessIsReturned) {
@@ -586,7 +611,7 @@ LZT_TEST_F(
586
611
}
587
612
void *buff_in = lzt::allocate_host_memory (image_size);
588
613
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 );
590
615
lzt::free_memory (buff_in);
591
616
lzt::free_memory (buff_out);
592
617
}
@@ -599,7 +624,33 @@ LZT_TEST_F(
599
624
}
600
625
void *buff_in = lzt::allocate_host_memory (image_size);
601
626
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 );
603
654
lzt::free_memory (buff_in);
604
655
lzt::free_memory (buff_out);
605
656
}
@@ -648,7 +699,7 @@ LZT_TEST_F(
648
699
}
649
700
void *buff_in = lzt::allocate_device_memory (image_size);
650
701
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 );
652
703
lzt::free_memory (buff_in);
653
704
lzt::free_memory (buff_out);
654
705
}
@@ -661,7 +712,7 @@ LZT_TEST_F(
661
712
}
662
713
void *buff_in = lzt::allocate_device_memory (image_size);
663
714
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 );
665
716
lzt::free_memory (buff_in);
666
717
lzt::free_memory (buff_out);
667
718
}
@@ -710,7 +761,7 @@ LZT_TEST_F(
710
761
}
711
762
void *buff_in = lzt::allocate_shared_memory (image_size);
712
763
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 );
714
765
lzt::free_memory (buff_in);
715
766
lzt::free_memory (buff_out);
716
767
}
@@ -723,7 +774,7 @@ LZT_TEST_F(
723
774
}
724
775
void *buff_in = lzt::allocate_shared_memory (image_size);
725
776
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 );
727
778
lzt::free_memory (buff_in);
728
779
lzt::free_memory (buff_out);
729
780
}
@@ -766,6 +817,8 @@ LZT_TEST_F(
766
817
lzt::aligned_free (buff_out_top);
767
818
}
768
819
820
+
821
+
769
822
LZT_TEST_F (
770
823
zeCommandListAppendImageCopyTests,
771
824
GivenDeviceImageAndHostImageWhenAppendingImageCopyFromMemoryToImmediateCmdListUsingSharedSystemMemoryWithNonNullRegionsThenImageIsCorrectAndSuccessIsReturnedWithSharedSystemAllocator) {
@@ -813,7 +866,7 @@ LZT_TEST_F(
813
866
}
814
867
void *buff_in = lzt::aligned_malloc (image_size, 1 );
815
868
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 );
817
870
lzt::aligned_free (buff_in);
818
871
lzt::aligned_free (buff_out);
819
872
}
@@ -827,7 +880,35 @@ LZT_TEST_F(
827
880
}
828
881
void *buff_in = lzt::aligned_malloc (image_size, 1 );
829
882
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 );
831
912
lzt::aligned_free (buff_in);
832
913
lzt::aligned_free (buff_out);
833
914
}
0 commit comments