@@ -1154,13 +1154,15 @@ class AppendMemoryCopyRegionWithSharedSystem
11541154 public ::testing::WithParamInterface<
11551155 std::tuple<size_t , size_t , size_t , bool , bool >> {
11561156protected:
1157- void RunMemoryCopyRegionTest () {
1157+ enum class MemoryAdvice { None, Source, Destination, Both };
1158+
1159+ void RunMemoryCopyRegionTest (MemoryAdvice advice) {
11581160
11591161 is_immediate = std::get<3 >(GetParam ());
11601162 use_copy_engine = std::get<4 >(GetParam ());
11611163
1162- auto cmd_queue_group_props = get_command_queue_group_properties (
1163- zeDevice::get_instance ()-> get_device () );
1164+ auto device = zeDevice::get_instance ()-> get_device ();
1165+ auto cmd_queue_group_props = get_command_queue_group_properties (device );
11641166
11651167 const ze_command_queue_group_property_flags_t queue_group_flags_set =
11661168 use_copy_engine
@@ -1175,8 +1177,7 @@ class AppendMemoryCopyRegionWithSharedSystem
11751177 ASSERT_TRUE (ordinal);
11761178
11771179 auto cmd_bundle = lzt::create_command_bundle (
1178- lzt::get_default_context (), zeDevice::get_instance ()->get_device (), 0 ,
1179- *ordinal, is_immediate);
1180+ lzt::get_default_context (), device, 0 , *ordinal, is_immediate);
11801181
11811182 // Set up memory buffers for test
11821183 // Device memory has to be copied in so
@@ -1202,6 +1203,18 @@ class AppendMemoryCopyRegionWithSharedSystem
12021203 std::array<uint32_t , 3 > depths = {1 , dpth / 2 , dpth};
12031204
12041205 for (uint32_t region = 0 ; region < 3 ; region++) {
1206+ if (advice == MemoryAdvice::Source || advice == MemoryAdvice::Both) {
1207+ lzt::append_memory_advise (
1208+ cmd_bundle.list , device, source_memory, memory_size,
1209+ ZE_MEMORY_ADVICE_SET_SYSTEM_MEMORY_PREFERRED_LOCATION);
1210+ }
1211+
1212+ if (advice == MemoryAdvice::Destination | advice == MemoryAdvice::Both) {
1213+ lzt::append_memory_advise (
1214+ cmd_bundle.list , device, destination_memory, memory_size,
1215+ ZE_MEMORY_ADVICE_SET_SYSTEM_MEMORY_PREFERRED_LOCATION);
1216+ }
1217+
12051218 // Define region to be copied from/to
12061219 uint32_t width = widths[region];
12071220 uint32_t height = heights[region];
@@ -1249,6 +1262,7 @@ class AppendMemoryCopyRegionWithSharedSystem
12491262 }
12501263 }
12511264 }
1265+
12521266 destroy_command_bundle (cmd_bundle);
12531267 free_memory (temp_src);
12541268 free_memory (temp_dest);
@@ -1278,7 +1292,22 @@ LZT_TEST_P(
12781292 memory_size = rows * columns * slices;
12791293 source_memory = lzt::aligned_malloc (memory_size, 1 );
12801294 destination_memory = lzt::allocate_host_memory (memory_size);
1281- RunMemoryCopyRegionTest ();
1295+ RunMemoryCopyRegionTest (MemoryAdvice::None);
1296+ lzt::aligned_free (source_memory);
1297+ lzt::free_memory (destination_memory);
1298+ }
1299+
1300+ LZT_TEST_P (
1301+ AppendMemoryCopyRegionWithSharedSystem,
1302+ GivenValidAdvisedSharedSystemMemoryWhenAppendingMemoryCopyWithRegionToHostMemoryThenSuccessIsReturnedAndCopyIsCorrectWithSharedSystemAllocator) {
1303+ SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED ();
1304+ rows = std::get<0 >(GetParam ());
1305+ columns = std::get<1 >(GetParam ());
1306+ slices = std::get<2 >(GetParam ());
1307+ memory_size = rows * columns * slices;
1308+ source_memory = lzt::aligned_malloc (memory_size, 1 );
1309+ destination_memory = lzt::allocate_host_memory (memory_size);
1310+ RunMemoryCopyRegionTest (MemoryAdvice::Source);
12821311 lzt::aligned_free (source_memory);
12831312 lzt::free_memory (destination_memory);
12841313}
@@ -1293,7 +1322,22 @@ LZT_TEST_P(
12931322 memory_size = rows * columns * slices;
12941323 source_memory = lzt::aligned_malloc (memory_size, 1 );
12951324 destination_memory = lzt::allocate_shared_memory (memory_size);
1296- RunMemoryCopyRegionTest ();
1325+ RunMemoryCopyRegionTest (MemoryAdvice::None);
1326+ lzt::aligned_free (source_memory);
1327+ lzt::free_memory (destination_memory);
1328+ }
1329+
1330+ LZT_TEST_P (
1331+ AppendMemoryCopyRegionWithSharedSystem,
1332+ GivenValidAdvisedSharedSystemMemoryWhenAppendingMemoryCopyWithRegionToSharedMemoryThenSuccessIsReturnedAndCopyIsCorrectWithSharedSystemAllocator) {
1333+ SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED ();
1334+ rows = std::get<0 >(GetParam ());
1335+ columns = std::get<1 >(GetParam ());
1336+ slices = std::get<2 >(GetParam ());
1337+ memory_size = rows * columns * slices;
1338+ source_memory = lzt::aligned_malloc (memory_size, 1 );
1339+ destination_memory = lzt::allocate_shared_memory (memory_size);
1340+ RunMemoryCopyRegionTest (MemoryAdvice::Source);
12971341 lzt::aligned_free (source_memory);
12981342 lzt::free_memory (destination_memory);
12991343}
@@ -1308,7 +1352,22 @@ LZT_TEST_P(
13081352 memory_size = rows * columns * slices;
13091353 source_memory = lzt::aligned_malloc (memory_size, 1 );
13101354 destination_memory = lzt::allocate_device_memory (memory_size);
1311- RunMemoryCopyRegionTest ();
1355+ RunMemoryCopyRegionTest (MemoryAdvice::None);
1356+ lzt::aligned_free (source_memory);
1357+ lzt::free_memory (destination_memory);
1358+ }
1359+
1360+ LZT_TEST_P (
1361+ AppendMemoryCopyRegionWithSharedSystem,
1362+ GivenValidAdvisedSharedSystemMemoryWhenAppendingMemoryCopyWithRegionToDeviceMemoryThenSuccessIsReturnedAndCopyIsCorrectWithSharedSystemAllocator) {
1363+ SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED ();
1364+ rows = std::get<0 >(GetParam ());
1365+ columns = std::get<1 >(GetParam ());
1366+ slices = std::get<2 >(GetParam ());
1367+ memory_size = rows * columns * slices;
1368+ source_memory = lzt::aligned_malloc (memory_size, 1 );
1369+ destination_memory = lzt::allocate_device_memory (memory_size);
1370+ RunMemoryCopyRegionTest (MemoryAdvice::Source);
13121371 lzt::aligned_free (source_memory);
13131372 lzt::free_memory (destination_memory);
13141373}
@@ -1323,7 +1382,52 @@ LZT_TEST_P(
13231382 memory_size = rows * columns * slices;
13241383 source_memory = lzt::aligned_malloc (memory_size, 1 );
13251384 destination_memory = lzt::aligned_malloc (memory_size, 1 );
1326- RunMemoryCopyRegionTest ();
1385+ RunMemoryCopyRegionTest (MemoryAdvice::None);
1386+ lzt::aligned_free (source_memory);
1387+ lzt::aligned_free (destination_memory);
1388+ }
1389+
1390+ LZT_TEST_P (
1391+ AppendMemoryCopyRegionWithSharedSystem,
1392+ GivenValidAdvisedSharedSystemMemoryWhenAppendingMemoryCopyWithRegionToSharedSystemMemoryThenSuccessIsReturnedAndCopyIsCorrectWithSharedSystemAllocator) {
1393+ SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED ();
1394+ rows = std::get<0 >(GetParam ());
1395+ columns = std::get<1 >(GetParam ());
1396+ slices = std::get<2 >(GetParam ());
1397+ memory_size = rows * columns * slices;
1398+ source_memory = lzt::aligned_malloc (memory_size, 1 );
1399+ destination_memory = lzt::aligned_malloc (memory_size, 1 );
1400+ RunMemoryCopyRegionTest (MemoryAdvice::Source);
1401+ lzt::aligned_free (source_memory);
1402+ lzt::aligned_free (destination_memory);
1403+ }
1404+
1405+ LZT_TEST_P (
1406+ AppendMemoryCopyRegionWithSharedSystem,
1407+ GivenValidSharedSystemMemoryWhenAppendingMemoryCopyWithRegionToAdvisedSharedSystemMemoryThenSuccessIsReturnedAndCopyIsCorrectWithSharedSystemAllocator) {
1408+ SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED ();
1409+ rows = std::get<0 >(GetParam ());
1410+ columns = std::get<1 >(GetParam ());
1411+ slices = std::get<2 >(GetParam ());
1412+ memory_size = rows * columns * slices;
1413+ source_memory = lzt::aligned_malloc (memory_size, 1 );
1414+ destination_memory = lzt::aligned_malloc (memory_size, 1 );
1415+ RunMemoryCopyRegionTest (MemoryAdvice::Destination);
1416+ lzt::aligned_free (source_memory);
1417+ lzt::aligned_free (destination_memory);
1418+ }
1419+
1420+ LZT_TEST_P (
1421+ AppendMemoryCopyRegionWithSharedSystem,
1422+ GivenValidAdvisedSharedSystemMemoryWhenAppendingMemoryCopyWithRegionToAdvisedSharedSystemMemoryThenSuccessIsReturnedAndCopyIsCorrectWithSharedSystemAllocator) {
1423+ SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED ();
1424+ rows = std::get<0 >(GetParam ());
1425+ columns = std::get<1 >(GetParam ());
1426+ slices = std::get<2 >(GetParam ());
1427+ memory_size = rows * columns * slices;
1428+ source_memory = lzt::aligned_malloc (memory_size, 1 );
1429+ destination_memory = lzt::aligned_malloc (memory_size, 1 );
1430+ RunMemoryCopyRegionTest (MemoryAdvice::Both);
13271431 lzt::aligned_free (source_memory);
13281432 lzt::aligned_free (destination_memory);
13291433}
@@ -1338,7 +1442,22 @@ LZT_TEST_P(
13381442 memory_size = rows * columns * slices;
13391443 source_memory = lzt::allocate_host_memory (memory_size);
13401444 destination_memory = lzt::aligned_malloc (memory_size, 1 );
1341- RunMemoryCopyRegionTest ();
1445+ RunMemoryCopyRegionTest (MemoryAdvice::None);
1446+ lzt::free_memory (source_memory);
1447+ lzt::aligned_free (destination_memory);
1448+ }
1449+
1450+ LZT_TEST_P (
1451+ AppendMemoryCopyRegionWithSharedSystem,
1452+ GivenValidHostMemoryWhenAppendingMemoryCopyWithRegionToAdvisedSharedSystemMemoryThenSuccessIsReturnedAndCopyIsCorrectWithSharedSystemAllocator) {
1453+ SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED ();
1454+ rows = std::get<0 >(GetParam ());
1455+ columns = std::get<1 >(GetParam ());
1456+ slices = std::get<2 >(GetParam ());
1457+ memory_size = rows * columns * slices;
1458+ source_memory = lzt::allocate_host_memory (memory_size);
1459+ destination_memory = lzt::aligned_malloc (memory_size, 1 );
1460+ RunMemoryCopyRegionTest (MemoryAdvice::Destination);
13421461 lzt::free_memory (source_memory);
13431462 lzt::aligned_free (destination_memory);
13441463}
@@ -1353,7 +1472,22 @@ LZT_TEST_P(
13531472 memory_size = rows * columns * slices;
13541473 source_memory = lzt::allocate_shared_memory (memory_size);
13551474 destination_memory = lzt::aligned_malloc (memory_size, 1 );
1356- RunMemoryCopyRegionTest ();
1475+ RunMemoryCopyRegionTest (MemoryAdvice::None);
1476+ lzt::free_memory (source_memory);
1477+ lzt::aligned_free (destination_memory);
1478+ }
1479+
1480+ LZT_TEST_P (
1481+ AppendMemoryCopyRegionWithSharedSystem,
1482+ GivenValidSharedMemoryWhenAppendingMemoryCopyWithRegionToAdvisedSharedSystemMemoryThenSuccessIsReturnedAndCopyIsCorrectWithSharedSystemAllocator) {
1483+ SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED ();
1484+ rows = std::get<0 >(GetParam ());
1485+ columns = std::get<1 >(GetParam ());
1486+ slices = std::get<2 >(GetParam ());
1487+ memory_size = rows * columns * slices;
1488+ source_memory = lzt::allocate_shared_memory (memory_size);
1489+ destination_memory = lzt::aligned_malloc (memory_size, 1 );
1490+ RunMemoryCopyRegionTest (MemoryAdvice::Destination);
13571491 lzt::free_memory (source_memory);
13581492 lzt::aligned_free (destination_memory);
13591493}
@@ -1368,7 +1502,22 @@ LZT_TEST_P(
13681502 memory_size = rows * columns * slices;
13691503 source_memory = lzt::allocate_device_memory (memory_size);
13701504 destination_memory = lzt::aligned_malloc (memory_size, 1 );
1371- RunMemoryCopyRegionTest ();
1505+ RunMemoryCopyRegionTest (MemoryAdvice::None);
1506+ lzt::free_memory (source_memory);
1507+ lzt::aligned_free (destination_memory);
1508+ }
1509+
1510+ LZT_TEST_P (
1511+ AppendMemoryCopyRegionWithSharedSystem,
1512+ GivenValidDeviceMemoryWhenAppendingMemoryCopyWithRegionToAdvisedSharedSystemMemoryThenSuccessIsReturnedAndCopyIsCorrectWithSharedSystemAllocator) {
1513+ SKIP_IF_SHARED_SYSTEM_ALLOC_UNSUPPORTED ();
1514+ rows = std::get<0 >(GetParam ());
1515+ columns = std::get<1 >(GetParam ());
1516+ slices = std::get<2 >(GetParam ());
1517+ memory_size = rows * columns * slices;
1518+ source_memory = lzt::allocate_device_memory (memory_size);
1519+ destination_memory = lzt::aligned_malloc (memory_size, 1 );
1520+ RunMemoryCopyRegionTest (MemoryAdvice::Destination);
13721521 lzt::free_memory (source_memory);
13731522 lzt::aligned_free (destination_memory);
13741523}
0 commit comments