rocr/driver: move wallclock frequency query to driver layer

Move the wallclock frequency query from GpuAgent to driver layer to improve
code organization and support multiple driver types. This change:

1. Add GetWallclockFrequency API to KFD/XDNA drivers
2. Move libdrm GPU info query from GpuAgent to driver implementation
3. Update GpuAgent to use the new driver API

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: 412e386b50]
This commit is contained in:
Honglei Huang
2025-06-30 14:41:19 +08:00
committed by Huang, Honglei1
parent 309e8b1a9f
commit 3fb4c8d3d7
6 changed files with 34 additions and 7 deletions
@@ -611,5 +611,21 @@ hsa_status_t KfdDriver::IsModelEnabled(bool* enable) const {
return HSA_STATUS_SUCCESS;
}
hsa_status_t KfdDriver::GetWallclockFrequency(uint32_t node_id, uint64_t* frequency) const {
assert(frequency);
amdgpu_gpu_info info;
amdgpu_device_handle handle;
if (GetDeviceHandle(node_id, reinterpret_cast<void**>(&handle)) != HSA_STATUS_SUCCESS)
return HSA_STATUS_ERROR;
if (DRM_CALL(amdgpu_query_gpu_info(handle, &info)) < 0) return HSA_STATUS_ERROR;
// Reported by libdrm in KHz.
*frequency = uint64_t(info.gpu_counter_freq) * 1000ull;
return HSA_STATUS_SUCCESS;
}
} // namespace AMD
} // namespace rocr
@@ -890,5 +890,9 @@ hsa_status_t XdnaDriver::GetTileConfig(uint32_t node_id, HsaGpuTileConfig* confi
return HSA_STATUS_ERROR;
}
hsa_status_t XdnaDriver::GetWallclockFrequency(uint32_t node_id, uint64_t* frequency) const {
return HSA_STATUS_ERROR;
}
} // namespace AMD
} // namespace rocr