From fc561ff37a4496d20f744fdef38f5fb7c797056d Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 20 May 2025 18:13:01 +0000 Subject: [PATCH] rocr: Add all sysfs entries for L2 Cache For L2 Cache and above, we report the total amount of cache for the whole partition, so we add up the L2 Cache entry for each partition. --- runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp index 5be10ffc79..6022c4ac8a 100644 --- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp @@ -1430,7 +1430,14 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const { const size_t num_cache = cache_props_.size(); for (size_t i = 0; i < num_cache; ++i) { const uint32_t line_level = cache_props_[i].CacheLevel; - if (reinterpret_cast(value)[line_level - 1] == 0) + /* + * L1 Cache is per CU. + * For L2 Cache and above, we report total for the partition so we sum + * all the node entries. + */ + if (line_level >= 2) + reinterpret_cast(value)[line_level - 1] += cache_props_[i].CacheSize * 1024; + else if (reinterpret_cast(value)[line_level - 1] == 0) reinterpret_cast(value)[line_level - 1] = cache_props_[i].CacheSize * 1024; } } break;