From 3258d72d3b914f9c7cab2d65078dbdd3c5cd2286 Mon Sep 17 00:00:00 2001 From: Mike Li Date: Mon, 12 Apr 2021 13:39:25 -0400 Subject: [PATCH] Get GPU cache information from KFD Signed-off-by: Mike Li Change-Id: I8dc8c97ae81c3747b7cd88cf2cdb7a9e4694a88d [ROCm/ROCR-Runtime commit: d077606e227757f533e003081e89e6886d5d564f] --- .../hsa-runtime/core/runtime/amd_gpu_agent.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp index fe62f2e1fc..090d3d0a18 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp @@ -830,12 +830,16 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const { case HSA_AGENT_INFO_DEVICE: *((hsa_device_type_t*)value) = HSA_DEVICE_TYPE_GPU; break; - case HSA_AGENT_INFO_CACHE_SIZE: + case HSA_AGENT_INFO_CACHE_SIZE: { std::memset(value, 0, sizeof(uint32_t) * 4); - // TODO: no GPU cache info from KFD. Hardcode for now. - // GCN whitepaper: L1 data cache is 16KB. - ((uint32_t*)value)[0] = 16 * 1024; - break; + assert(cache_props_.size() > 0 && "GPU cache info missing."); + 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) + reinterpret_cast(value)[line_level - 1] = cache_props_[i].CacheSize * 1024; + } + } break; case HSA_AGENT_INFO_ISA: *((hsa_isa_t*)value) = core::Isa::Handle(isa_); break;