From e3a01690a5e197230b2c5980671cd09b3e798004 Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Thu, 29 Jul 2021 15:35:52 -0500 Subject: [PATCH] Add global_flags reporting to pointer info. global_flags reporting allows discovery of an allocation's memory model (coarse, fine, kernarg). This is critical on gfx90a and also allows discovery of the memory model of IPC imports. Change-Id: Icbc3c243ca20e264af5e1931becd2419f762c7ad --- runtime/hsa-runtime/core/runtime/runtime.cpp | 7 ++++++- runtime/hsa-runtime/inc/hsa_ext_amd.h | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/runtime/hsa-runtime/core/runtime/runtime.cpp b/runtime/hsa-runtime/core/runtime/runtime.cpp index b3e30a8b46..7afee4cbf3 100644 --- a/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -776,7 +776,7 @@ hsa_status_t Runtime::PtrInfo(void* ptr, hsa_amd_pointer_info_t* info, void* (*a HsaPointerInfo thunkInfo; uint32_t* mappedNodes; - hsa_amd_pointer_info_t retInfo; + hsa_amd_pointer_info_t retInfo = {0}; // check output struct has an initialized size. if (info->size == 0) return HSA_STATUS_ERROR_INVALID_ARGUMENT; @@ -805,6 +805,11 @@ hsa_status_t Runtime::PtrInfo(void* ptr, hsa_amd_pointer_info_t* info, void* (*a retInfo.hostBaseAddress = thunkInfo.CPUAddress; retInfo.sizeInBytes = thunkInfo.SizeInBytes; retInfo.userData = thunkInfo.UserData; + retInfo.global_flags = thunkInfo.MemFlags.ui32.CoarseGrain + ? HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_COARSE_GRAINED + : HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_FINE_GRAINED; + retInfo.global_flags |= + thunkInfo.MemFlags.ui32.Uncached ? HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_KERNARG_INIT : 0; if (block_info != nullptr) { // Block_info reports the thunk allocation from which we may have suballocated. // For locked memory we want to return the host address since hostBaseAddress is used to diff --git a/runtime/hsa-runtime/inc/hsa_ext_amd.h b/runtime/hsa-runtime/inc/hsa_ext_amd.h index bfecc8ed67..f0fbb5958b 100644 --- a/runtime/hsa-runtime/inc/hsa_ext_amd.h +++ b/runtime/hsa-runtime/inc/hsa_ext_amd.h @@ -1774,6 +1774,12 @@ typedef struct hsa_amd_pointer_info_s { GPU boards) any such agent may be returned. */ hsa_agent_t agentOwner; + /* + Contains a bitfield of hsa_amd_memory_pool_global_flag_t values. + Reports the effective global flags bitmask for the allocation. This field is not meaningful if + the type of the allocation is HSA_EXT_POINTER_TYPE_UNKNOWN. + */ + uint32_t global_flags; } hsa_amd_pointer_info_t; /**