Add API for available GPU memory

Add support for AMD Agent to return amount of memory available

Change-Id: I5c32e2cebbaa2993b044250aefe434e4cc02d8c2
Signed-off-by: David Yat Sin <david.yatsin@amd.com>
This commit is contained in:
David Yat Sin authored and David Yat Sin committed 2022-06-07 10:33:18 -04:00
1 parent dd671b49e5
commit 4ac840269c
4 files changed
+28 -1

No files matched your search

@@ -1032,6 +1032,23 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
break;
}
return GetInfo((hsa_agent_info_t)HSA_AMD_AGENT_INFO_COMPUTE_UNIT_COUNT, value);
case HSA_AMD_AGENT_INFO_MEMORY_AVAIL: {
HSAuint64 availableBytes;
HSAKMT_STATUS status;
status = hsaKmtAvailableMemory(node_id(), &availableBytes);
if (status != HSAKMT_STATUS_SUCCESS)
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
for (auto r: regions())
availableBytes += ((AMD::MemoryRegion*)r)->GetCacheSize();
availableBytes += scratch_cache_.free_bytes();
*((uint64_t*)value) = availableBytes;
break;
}
default:
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
break;