Fix pointer info block base address fetch.

Thunk may report nullptr for host base if the host does not have
access.  Use agent base in this case.

Change-Id: I44883d35a3fff0941b1e3037d16b059591a6c511


[ROCm/ROCR-Runtime commit: 397608e2c0]
This commit is contained in:
Sean Keely
2020-04-29 14:52:24 -05:00
vanhempi 0e3850b003
commit 4b3a5b6151
@@ -790,11 +790,14 @@ hsa_status_t Runtime::PtrInfo(void* ptr, hsa_amd_pointer_info_t* info, void* (*a
retInfo.sizeInBytes = thunkInfo.SizeInBytes;
retInfo.userData = thunkInfo.UserData;
if (block_info != nullptr) {
// The only time host and agent ptr may be different is when the memory is lock memory (malloc
// memory pinned for GPU access). In this case there can not be any suballocation so
// block_info is redundant and unused. Host address is returned since host address is used to
// manipulate lock memory. This protects future use of block_info with lock memory.
block_info->base = retInfo.hostBaseAddress;
// 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
// manipulate locked memory and it is possible that hostBaseAddress is different from
// agentBaseAddress.
// For device memory, hostBaseAddress is either equal to agentBaseAddress or is NULL when the
// CPU does not have access.
assert((retInfo.hostBaseAddress || retInfo.agentBaseAddress) && "Thunk pointer info returned no base address.");
block_info->base = (retInfo.hostBaseAddress ? retInfo.hostBaseAddress : retInfo.agentBaseAddress);
block_info->length = retInfo.sizeInBytes;
}
if (retInfo.type == HSA_EXT_POINTER_TYPE_HSA) {