rocr: Add hsa-agent Queries for Clock Counters

Support has been added to query the following
HSA_AMD_INFO_GET_CLOCK_COUNTERS agent info exposed through the hsa api
in rocr, rather than the user having to make a direct IOCTL call
through the kernel driver.

Signed-off-by: Sunday Clement <Sunday.Clement@amd.com>


[ROCm/ROCR-Runtime commit: e97d06530e]
Этот коммит содержится в:
Sunday Clement
2025-06-19 15:32:35 -04:00
коммит произвёл Clement, Sunday
родитель a62368e2ba
Коммит 315b1abaf9
4 изменённых файлов: 37 добавлений и 2 удалений
+3
Просмотреть файл
@@ -253,6 +253,9 @@ hsa_status_t AieAgent::GetInfo(hsa_agent_info_t attribute, void *value) const {
case HSA_AMD_AGENT_INFO_MEMORY_PROPERTIES:
std::memset(value, 0, sizeof(uint8_t) * 8);
break;
case HSA_AMD_AGENT_INFO_CLOCK_COUNTERS:
std::memset(value, 0, sizeof(hsa_amd_clock_counters_t));
break;
default:
*reinterpret_cast<uint32_t *>(value) = 0;
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
+3
Просмотреть файл
@@ -417,6 +417,9 @@ hsa_status_t CpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
case HSA_AMD_AGENT_INFO_SCRATCH_LIMIT_CURRENT:
*((uint64_t*)value) = 0;
break;
case HSA_AMD_AGENT_INFO_CLOCK_COUNTERS:
memset(value, 0, sizeof(hsa_amd_clock_counters_t));
break;
default:
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
break;
+13
Просмотреть файл
@@ -1674,6 +1674,19 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
case HSA_AMD_AGENT_INFO_SCRATCH_LIMIT_CURRENT:
*((uint64_t*)value) = scratch_limit_async_threshold_;
break;
case HSA_AMD_AGENT_INFO_CLOCK_COUNTERS: {
HsaClockCounters hsakmt_counters = {};
hsa_amd_clock_counters_t* counters = static_cast<hsa_amd_clock_counters_t*>(value);
if (hsaKmtGetClockCounters(node_id(), &hsakmt_counters) == HSAKMT_STATUS_SUCCESS ) {
counters->cpu_clock_counter = hsakmt_counters.CPUClockCounter;
counters->gpu_clock_counter = hsakmt_counters.GPUClockCounter;
counters->system_clock_counter = hsakmt_counters.SystemClockCounter;
counters->system_clock_frequency = hsakmt_counters.SystemClockFrequencyHz;
break;
}
return HSA_STATUS_ERROR;
}
default:
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
break;
+18 -2
Просмотреть файл
@@ -61,9 +61,10 @@
* - 1.8 - hsa_amd_memory_get_preferred_copy_engine
* - 1.9 - hsa_amd_portable_export_dmabuf_v2
* - 1.10 - hsa_amd_vmem_address_reserve: HSA_AMD_VMEM_ADDRESS_NO_REGISTER
* - 1.11 - hsa_amd_agent_info_t: HSA_AMD_AGENT_INFO_CLOCK_COUNTERS
*/
#define HSA_AMD_INTERFACE_VERSION_MAJOR 1
#define HSA_AMD_INTERFACE_VERSION_MINOR 10
#define HSA_AMD_INTERFACE_VERSION_MINOR 11
#ifdef __cplusplus
extern "C" {
@@ -476,6 +477,16 @@ typedef enum {
HSA_IOMMU_SUPPORT_V2 = 1,
} hsa_amd_iommu_version_t;
/**
* @brief Structure containing information on the agent's clock counters.
*/
typedef struct hsa_amd_clock_counters_s {
uint64_t gpu_clock_counter;
uint64_t cpu_clock_counter;
uint64_t system_clock_counter;
uint64_t system_clock_frequency;
} hsa_amd_clock_counters_t;
/**
* @brief Agent attributes.
*/
@@ -685,7 +696,12 @@ typedef enum hsa_amd_agent_info_s {
*
* The type of this attribute is uint64_t.
*/
HSA_AMD_AGENT_INFO_SCRATCH_LIMIT_CURRENT = 0xA117
HSA_AMD_AGENT_INFO_SCRATCH_LIMIT_CURRENT = 0xA117,
/**
* Queries the driver for clock counters of the agent.
* The type of this attribute is hsa_amd_clock_counters_t.
*/
HSA_AMD_AGENT_INFO_CLOCK_COUNTERS = 0xA118
} hsa_amd_agent_info_t;
/**