@@ -937,89 +937,6 @@ TEST_CASE("Unit_hipMemSetAccess_Vmm2VMMInterDevMemCpy") {
937937 HIP_CHECK (hipMemAddressFree (ptrA, size_mem));
938938}
939939
940- /* *
941- * Test Description
942- * ------------------------
943- * - Allocate a chunk of memory and map it to device0. Allocate another
944- * chunk of memory and map it to device1. Check if these 2 distinct memory
945- * chunks can be mapped to a single address space.
946- * ------------------------
947- * - unit/virtualMemoryManagement/hipMemSetGetAccess.cc
948- * Test requirements
949- * ------------------------
950- * - HIP_VERSION >= 6.1
951- */
952- TEST_CASE (" Unit_hipMemSetAccess_MapPhysChksFromMulDev" ) {
953- int devicecount = 0 ;
954- HIP_CHECK (hipGetDeviceCount (&devicecount));
955- int numOfBuffers = devicecount;
956- constexpr int N = DATA_SIZE;
957- size_t buffer_size = N * sizeof (int ), granularity = 0 ;
958- int deviceId = 0 ;
959- // Allocate resources for all gpus
960- hipMemGenericAllocationHandle_t* handle = static_cast <hipMemGenericAllocationHandle_t*>(
961- malloc (sizeof (hipMemGenericAllocationHandle_t) * numOfBuffers));
962- REQUIRE (handle != nullptr );
963- size_t * size_mem = static_cast <size_t *>(malloc (sizeof (size_t ) * numOfBuffers));
964- REQUIRE (size_mem != nullptr );
965- size_t total_mem = 0 ;
966- // Create memory chunks
967- for (deviceId = 0 ; deviceId < numOfBuffers; deviceId++) {
968- hipDevice_t device;
969- HIP_CHECK (hipDeviceGet (&device, deviceId));
970- checkVMMSupported (device);
971- hipMemAllocationProp prop_loc{};
972- prop_loc.type = hipMemAllocationTypePinned;
973- prop_loc.location .type = hipMemLocationTypeDevice;
974- prop_loc.location .id = device; // Current Devices
975- HIP_CHECK (hipMemGetAllocationGranularity (&granularity, &prop_loc,
976- hipMemAllocationGranularityMinimum));
977- REQUIRE (granularity > 0 );
978- size_mem[deviceId] = ((granularity + buffer_size - 1 ) / granularity) * granularity;
979- total_mem = total_mem + size_mem[deviceId];
980- // Allocate physical memory chunks
981- HIP_CHECK (hipMemCreate (&handle[deviceId], size_mem[deviceId], &prop_loc, 0 ));
982- }
983- // Allocate virtual address range for all the memory chunks
984- hipDeviceptr_t ptrA;
985- HIP_CHECK (hipMemAddressReserve (&ptrA, total_mem, 0 , 0 , 0 ));
986- // Map the allocated chunks
987- for (deviceId = 0 ; deviceId < numOfBuffers; deviceId++) {
988- hipDevice_t device;
989- HIP_CHECK (hipDeviceGet (&device, deviceId));
990- uint64_t uiptr = reinterpret_cast <uint64_t >(ptrA);
991- uiptr = uiptr + deviceId * size_mem[deviceId];
992- HIP_CHECK (
993- hipMemMap (reinterpret_cast <void *>(uiptr), size_mem[deviceId], 0 , handle[deviceId], 0 ));
994- HIP_CHECK (hipMemRelease (handle[deviceId]));
995- // Set access
996- hipMemAccessDesc accessDesc_loc = {};
997- accessDesc_loc.location .type = hipMemLocationTypeDevice;
998- accessDesc_loc.location .id = device;
999- accessDesc_loc.flags = hipMemAccessFlagsProtReadWrite;
1000- // Make the address accessible to deviceId
1001- HIP_CHECK (
1002- hipMemSetAccess (reinterpret_cast <void *>(uiptr), size_mem[deviceId], &accessDesc_loc, 1 ));
1003- }
1004- std::vector<int > A_h (numOfBuffers * N), B_h (numOfBuffers * N);
1005- // Fill Data
1006- for (int idx = 0 ; idx < (numOfBuffers * N); idx++) {
1007- A_h[idx] = idx * idx;
1008- }
1009- HIP_CHECK (hipMemcpyHtoD (ptrA, A_h.data (), numOfBuffers * buffer_size));
1010- HIP_CHECK (hipMemcpyDtoH (B_h.data (), ptrA, numOfBuffers * buffer_size));
1011- // Validate Results
1012- REQUIRE (true == std::equal (B_h.begin (), B_h.end (), A_h.data ()));
1013- for (deviceId = 0 ; deviceId < numOfBuffers; deviceId++) {
1014- uint64_t uiptr = reinterpret_cast <uint64_t >(ptrA);
1015- uiptr = uiptr + deviceId * size_mem[deviceId];
1016- HIP_CHECK (hipMemUnmap (reinterpret_cast <void *>(uiptr), size_mem[deviceId]));
1017- }
1018- HIP_CHECK (hipMemAddressFree (ptrA, total_mem));
1019- free (handle);
1020- free (size_mem);
1021- }
1022-
1023940class vmm_resize_class {
1024941 size_t current_size_tot;
1025942 size_t current_size_rounded_tot;
0 commit comments