@@ -776,12 +776,12 @@ LZT_TEST_F(
776776class zeCommandListAppendMemoryBackToBackTests
777777 : public ::testing::Test,
778778 public ::testing::WithParamInterface<
779- std::tuple<bool , bool , bool , bool , size_t >> {
779+ std::tuple<bool , bool , bool , bool , bool , size_t >> {
780780
781781protected:
782782 void RunGivenCopyBetweenUsmAndSharedSystemUsmAndVerifyCorrect (
783783 bool is_src_shared_system, bool is_dst_shared_system, bool is_immediate,
784- bool isCopyOnly , size_t size) {
784+ bool is_copy_only, bool use_madvise , size_t size) {
785785 const uint8_t value = to_u8 (rand ()) & 0xFF ;
786786 const uint8_t init = (value + 0x22 ) & 0xFF ;
787787
@@ -791,26 +791,40 @@ class zeCommandListAppendMemoryBackToBackTests
791791 size, is_dst_shared_system);
792792
793793 uint32_t ordinal = 0 ;
794- if (isCopyOnly ) {
794+ if (is_copy_only ) {
795795 ordinal = 1 ;
796796 }
797797
798798 const char *src_memory_type = is_src_shared_system ? " SVM" : " USM" ;
799799 const char *dst_memory_type = is_dst_shared_system ? " SVM" : " USM" ;
800800
801- printf (" src_memory (%s)= %p dst_memory (%s)= %p immediate = %d isCopyOnly "
802- " = %d size = %zu\n " ,
803- src_memory_type, src_memory, dst_memory_type, dst_memory,
804- is_immediate, isCopyOnly, size);
801+ LOG_INFO << " src_memory (" << src_memory_type << " )= " << src_memory
802+ << " dst_memory (" << dst_memory_type << " )= " << dst_memory
803+ << " immediate = " << is_immediate
804+ << " is_copy_only = " << is_copy_only
805+ << " use_madvise = " << use_madvise << " size = " << size;
805806
806807 memset (src_memory, value, size);
807808 memset (dst_memory, init, size);
808809
810+ auto device = zeDevice::get_instance ()->get_device ();
809811 auto cmd_bundle = lzt::create_command_bundle (
810- lzt::get_default_context (), zeDevice::get_instance ()-> get_device () , 0 ,
812+ lzt::get_default_context (), device , 0 ,
811813 ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, 0 ,
812814 ordinal, 0 , is_immediate);
813815
816+ if (is_src_shared_system && use_madvise) {
817+ lzt::append_memory_advise (
818+ cmd_bundle.list , device, src_memory, size,
819+ ZE_MEMORY_ADVICE_SET_SYSTEM_MEMORY_PREFERRED_LOCATION);
820+ }
821+
822+ if (is_dst_shared_system && use_madvise) {
823+ lzt::append_memory_advise (
824+ cmd_bundle.list , device, dst_memory, size,
825+ ZE_MEMORY_ADVICE_SET_SYSTEM_MEMORY_PREFERRED_LOCATION);
826+ }
827+
814828 lzt::append_memory_copy (cmd_bundle.list , static_cast <void *>(dst_memory),
815829 static_cast <void *>(src_memory), size);
816830
@@ -827,15 +841,21 @@ LZT_TEST_P(
827841 zeCommandListAppendMemoryBackToBackTests,
828842 GivenAllUsmAndSvmPermutationsConfirmSuccessfulExecutionBackToBackWithSharedSystemAllocator) {
829843 SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED ();
844+ bool is_src_shared_system = std::get<0 >(GetParam ());
845+ bool is_dst_shared_system = std::get<1 >(GetParam ());
846+ bool use_madvise = std::get<4 >(GetParam ());
847+ if (use_madvise && !is_src_shared_system && !is_dst_shared_system) {
848+ GTEST_SKIP () << " Skipping redundant case." ;
849+ }
830850 RunGivenCopyBetweenUsmAndSharedSystemUsmAndVerifyCorrect (
831- std::get< 0 >( GetParam ()), std::get< 1 >( GetParam ()) , std::get<2 >(GetParam ()),
832- std::get<3 >(GetParam ()), std::get<4 >(GetParam ()));
851+ is_src_shared_system, is_dst_shared_system , std::get<2 >(GetParam ()),
852+ std::get<3 >(GetParam ()), use_madvise, std::get<5 >(GetParam ()));
833853}
834854
835855INSTANTIATE_TEST_SUITE_P (
836856 ParameterizedTests, zeCommandListAppendMemoryBackToBackTests,
837857 ::testing::Combine (::testing::Bool(), ::testing::Bool(), ::testing::Bool(),
838- ::testing::Bool(),
858+ ::testing::Bool(), ::testing::Bool(),
839859 ::testing::Values(10 , 10 * 1024 , 32 * 1024 * 1024 )));
840860
841861class zeCommandListAppendMemoryCopyFromContextWithDataVerificationTests
0 commit comments