From 4afca0647e9ef24e579068bf6557c533a21af5d6 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 12 Sep 2022 07:34:24 -0400 Subject: [PATCH] SWDEV-352502 - SWDEV-355630 - Revert "SWDEV-299940 - Query global memory available on device with HSA attribute HSA_AMD_AGENT_INFO_MEMORY_AVAIL" This reverts commit 73021582d341385db124c48267adde914b0aebe4. Change-Id: I86175ccf2b543c3ff3dffec6ccae410976972f22 --- rocclr/device/rocm/rocdevice.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/rocclr/device/rocm/rocdevice.cpp b/rocclr/device/rocm/rocdevice.cpp index 531338074d..7d7870d5f3 100644 --- a/rocclr/device/rocm/rocdevice.cpp +++ b/rocclr/device/rocm/rocdevice.cpp @@ -1665,23 +1665,10 @@ device::VirtualDevice* Device::createVirtualDevice(amd::CommandQueue* queue) { bool Device::globalFreeMemory(size_t* freeMemory) const { const uint TotalFreeMemory = 0; const uint LargestFreeBlock = 1; - uint64_t globalAvailMemory; - // Queries memory available in bytes across all global pools owned by the agent - if (HSA_STATUS_SUCCESS != - hsa_agent_get_info(bkendDevice_, - static_cast(HSA_AMD_AGENT_INFO_MEMORY_AVAIL), - &globalAvailMemory)) { - LogError("HSA_AMD_AGENT_INFO_MEMORY_AVAIL query failed."); - } - globalAvailMemory = globalAvailMemory / Ki; - if (globalAvailMemory > HIP_HIDDEN_FREE_MEM * Ki) { - globalAvailMemory -= HIP_HIDDEN_FREE_MEM * Ki; - } else { - globalAvailMemory = 0; - } - - freeMemory[TotalFreeMemory] = globalAvailMemory; + freeMemory[TotalFreeMemory] = freeMem_ / Ki; + freeMemory[TotalFreeMemory] -= (freeMemory[TotalFreeMemory] > HIP_HIDDEN_FREE_MEM * Ki) ? + HIP_HIDDEN_FREE_MEM * Ki : 0; // since there is no memory heap on ROCm, the biggest free block is // equal to total free local memory freeMemory[LargestFreeBlock] = freeMemory[TotalFreeMemory];