rocr: Add queries for async scratch reclaim

Add support for these 2 new queries:
- HSA_AMD_AGENT_INFO_SCRATCH_LIMIT_MAX
  Maximum amount of scratch memory allowed on this agent

- HSA_AMD_AGENT_INFO_SCRATCH_LIMIT_CURRENT
  Current limit for scratch memory on this agent
This commit is contained in:
David Yat Sin
2025-02-06 16:22:52 +00:00
committed by Yat Sin, David
parent aa2f98e6f9
commit 107b48fb15
3 changed files with 30 additions and 1 deletions
@@ -415,6 +415,10 @@ hsa_status_t CpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
case HSA_AMD_AGENT_INFO_AQL_EXTENSIONS:
memset(value, 0, sizeof(uint8_t) * 8);
break;
case HSA_AMD_AGENT_INFO_SCRATCH_LIMIT_MAX:
case HSA_AMD_AGENT_INFO_SCRATCH_LIMIT_CURRENT:
*((uint64_t*)value) = 0;
break;
default:
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
break;
@@ -1630,6 +1630,12 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
memset(value, 0, sizeof(uint8_t) * 8);
/* Not yet implemented */
break;
case HSA_AMD_AGENT_INFO_SCRATCH_LIMIT_MAX:
*((uint64_t*)value) = MaxScratchDevice();
break;
case HSA_AMD_AGENT_INFO_SCRATCH_LIMIT_CURRENT:
*((uint64_t*)value) = scratch_limit_async_threshold_;
break;
default:
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
break;
+20 -1
View File
@@ -731,7 +731,26 @@ typedef enum hsa_amd_agent_info_s {
* bit is set at that position. User may use the hsa_flag_isset64 macro to verify whether a flag
* is set. The type of this attribute is uint8_t[8].
*/
HSA_AMD_AGENT_INFO_AQL_EXTENSIONS = 0xA115 /* Not implemented yet */
HSA_AMD_AGENT_INFO_AQL_EXTENSIONS = 0xA115, /* Not implemented yet */
/**
* Maximum allowed value in bytes for scratch limit for this agent. This amount
* is shared accross all queues created on this agent.
* The type of this attribute is uint64_t.
*/
HSA_AMD_AGENT_INFO_SCRATCH_LIMIT_MAX = 0xA116,
/**
* Current scratch limit threshold in bytes for this agent. This limit can be
* modified using the hsa_amd_agent_set_async_scratch_limit call.
* - AQL dispatches that require scratch-memory above this threshold will trigger a
* scratch use-once.
* - AQL dispatches using less scratch-memory than this threshold, ROCr will
* permanently assign the allocated scratch memory to the queue handling the dispatch.
* This memory can be reclaimed by calling hsa_amd_agent_set_async_scratch_limit
* with a lower threshold by current value.
*
* The type of this attribute is uint64_t.
*/
HSA_AMD_AGENT_INFO_SCRATCH_LIMIT_CURRENT = 0xA117
} hsa_amd_agent_info_t;
/**