From e8fef02e5a6bea03005f6c33cf294222b472d878 Mon Sep 17 00:00:00 2001 From: Yiannis Papadopoulos <102817138+ypapadop-amd@users.noreply.github.com> Date: Thu, 8 Jan 2026 13:40:22 -0500 Subject: [PATCH] rocr/aie: Use util/os to get system memory (#2520) --- .../hsa-runtime/core/driver/xdna/amd_xdna_driver.cpp | 6 ------ .../runtime/hsa-runtime/core/inc/amd_xdna_driver.h | 3 --- .../runtime/hsa-runtime/core/runtime/amd_aie_agent.cpp | 8 +++----- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/driver/xdna/amd_xdna_driver.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/driver/xdna/amd_xdna_driver.cpp index 7d7f913ea4..a1ca73c32a 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/driver/xdna/amd_xdna_driver.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/driver/xdna/amd_xdna_driver.cpp @@ -155,12 +155,6 @@ hsa_status_t XdnaDriver::DiscoverDriver(std::unique_ptr& driver) { return HSA_STATUS_ERROR; } -uint64_t XdnaDriver::GetSystemMemoryByteSize() { - const long pagesize = sysconf(_SC_PAGESIZE); - const long page_count = sysconf(_SC_PHYS_PAGES); - return pagesize * page_count; -} - uint64_t XdnaDriver::GetDevHeapByteSize() { return dev_heap_size; } diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/amd_xdna_driver.h b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/amd_xdna_driver.h index 7713e173cf..46b3dd2ea0 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/amd_xdna_driver.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/amd_xdna_driver.h @@ -181,9 +181,6 @@ public: static hsa_status_t DiscoverDriver(std::unique_ptr& driver); - /// @brief Returns the size of the system memory heap in bytes. - static uint64_t GetSystemMemoryByteSize(); - /// @brief Returns the size of the dev heap in bytes. static uint64_t GetDevHeapByteSize(); diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_aie_agent.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_aie_agent.cpp index af7b7a1bf5..cc5a14118e 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_aie_agent.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_aie_agent.cpp @@ -53,6 +53,7 @@ #include "core/inc/amd_xdna_driver.h" #include "core/inc/driver.h" #include "core/inc/runtime.h" +#include "core/util/os.h" namespace rocr { namespace AMD { @@ -293,11 +294,8 @@ hsa_status_t AieAgent::QueueCreate(size_t size, hsa_queue_type32_t queue_type, u } void AieAgent::InitRegionList() { - /// TODO: Find a way to set the other memory properties in a reasonable way. - /// This should be easier once the ROCt source is incorporated into the - /// ROCr source. Since the AIE itself currently has no memory regions of - /// its own all memory is just the system DRAM. - const uint64_t total_system_memory = XdnaDriver::GetSystemMemoryByteSize(); + /// AIE itself currently has no memory regions of its own, all memory is just the system DRAM. + const uint64_t total_system_memory = os::HostTotalPhysicalMemory(); /// For allocating kernel arguments or other objects that only need /// system memory.