rocr/driver: add GetClockCounters API to driver interface
This commit introduces a new GetClockCounters API to the driver interface.
- Implemented GetClockCounters in KfdDriver to fetch clock counters
using hsaKmtGetClockCounters.
- Added a stub implementation of GetClockCounters in XdnaDriver that
returns HSA_STATUS_ERROR.
- Modified GpuAgent to use driver().GetClockCounters instead of
directly calling hsaKmtGetClockCounters.
Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>
[ROCm/ROCR-Runtime commit: 8d077dba3b]
Этот коммит содержится в:
коммит произвёл
Huang, Honglei1
родитель
bacf61dde9
Коммит
e459cc0c3b
@@ -583,6 +583,14 @@ hsa_status_t KfdDriver::GetDeviceHandle(uint32_t node_id, void** device_handle)
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
hsa_status_t KfdDriver::GetClockCounters(uint32_t node_id, HsaClockCounters* clock_counter) const {
|
||||
assert(clock_counter);
|
||||
|
||||
if (HSAKMT_CALL(hsaKmtGetClockCounters(node_id, clock_counter)) != HSAKMT_STATUS_SUCCESS)
|
||||
return HSA_STATUS_ERROR;
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
hsa_status_t KfdDriver::IsModelEnabled(bool* enable) const {
|
||||
// AIE does not support streaming performance monitor.
|
||||
HSAKMT_STATUS status = HSAKMT_STATUS_ERROR;
|
||||
|
||||
@@ -881,5 +881,9 @@ hsa_status_t XdnaDriver::GetDeviceHandle(uint32_t node_id, void** device_handle)
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
|
||||
hsa_status_t XdnaDriver::GetClockCounters(uint32_t node_id, HsaClockCounters* clock_counter) const {
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
|
||||
} // namespace AMD
|
||||
} // namespace rocr
|
||||
|
||||
@@ -125,6 +125,7 @@ public:
|
||||
hsa_status_t SetTrapHandler(uint32_t node_id, const void* base, uint64_t base_size,
|
||||
const void* buffer_base, uint64_t buffer_base_size) const override;
|
||||
hsa_status_t GetDeviceHandle(uint32_t node_id, void** device_handle) const override;
|
||||
hsa_status_t GetClockCounters(uint32_t node_id, HsaClockCounters* clock_counter) const override;
|
||||
|
||||
hsa_status_t OpenSMI(uint32_t node_id, int* fd) const override;
|
||||
|
||||
|
||||
@@ -239,6 +239,7 @@ public:
|
||||
hsa_status_t SetTrapHandler(uint32_t node_id, const void* base, uint64_t base_size,
|
||||
const void* buffer_base, uint64_t buffer_base_size) const override;
|
||||
hsa_status_t GetDeviceHandle(uint32_t node_id, void** device_handle) const override;
|
||||
hsa_status_t GetClockCounters(uint32_t node_id, HsaClockCounters* clock_counter) const override;
|
||||
|
||||
hsa_status_t IsModelEnabled(bool* enable) const override;
|
||||
|
||||
|
||||
@@ -276,6 +276,13 @@ public:
|
||||
virtual hsa_status_t GetDeviceHandle(uint32_t node_id, void** device_handle) const = 0;
|
||||
|
||||
|
||||
/// @brief Gets clock counters for particular Node
|
||||
/// @param[in] node_id Node ID of the agent
|
||||
/// @param[out] clock_counter Clock counter
|
||||
/// @return HSA_STATUS_SUCCESS if the driver successfully returns the clock
|
||||
virtual hsa_status_t GetClockCounters(uint32_t node_id,
|
||||
HsaClockCounters* clock_counter) const = 0;
|
||||
|
||||
/// @brief Check if the HSA KMT Model is enabled
|
||||
/// @param[out] enable True if the model is enabled, false otherwise
|
||||
virtual hsa_status_t IsModelEnabled(bool* enable) const = 0;
|
||||
|
||||
@@ -125,10 +125,10 @@ GpuAgent::GpuAgent(HSAuint32 node, const HsaNodeProperties& node_props, bool xna
|
||||
if (node_props.Capability.ui32.DoorbellType != 2)
|
||||
throw AMD::hsa_exception(HSA_STATUS_ERROR, "Agent creation failed.\nThe GPU node uses a deprecated doorbell type\n");
|
||||
|
||||
HSAKMT_STATUS err = HSAKMT_CALL(hsaKmtGetClockCounters(node_id(), &t0_));
|
||||
hsa_status_t err = driver().GetClockCounters(node_id(), &t0_);
|
||||
t1_ = t0_;
|
||||
historical_clock_ratio_ = 0.0;
|
||||
assert(err == HSAKMT_STATUS_SUCCESS && "hsaGetClockCounters error");
|
||||
assert(err == HSA_STATUS_SUCCESS && "hsaGetClockCounters error");
|
||||
|
||||
const core::Isa *isa_base;
|
||||
|
||||
@@ -1678,7 +1678,8 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
|
||||
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 ) {
|
||||
hsa_status_t err = driver().GetClockCounters(node_id(), &hsakmt_counters);
|
||||
if (err == HSA_STATUS_SUCCESS) {
|
||||
counters->cpu_clock_counter = hsakmt_counters.CPUClockCounter;
|
||||
counters->gpu_clock_counter = hsakmt_counters.GPUClockCounter;
|
||||
counters->system_clock_counter = hsakmt_counters.SystemClockCounter;
|
||||
@@ -2199,8 +2200,8 @@ uint16_t GpuAgent::GetSdmaMicrocodeVersion() const {
|
||||
}
|
||||
|
||||
void GpuAgent::SyncClocks() {
|
||||
HSAKMT_STATUS err = HSAKMT_CALL(hsaKmtGetClockCounters(node_id(), &t1_));
|
||||
assert(err == HSAKMT_STATUS_SUCCESS && "hsaGetClockCounters error");
|
||||
hsa_status_t err = driver().GetClockCounters(node_id(), &t1_);
|
||||
assert(err == HSA_STATUS_SUCCESS && "hsaGetClockCounters error");
|
||||
}
|
||||
|
||||
hsa_status_t GpuAgent::UpdateTrapHandlerWithPCS(pcs_sampling_data_t* pcs_hosttrap_buffers, pcs_sampling_data_t* pcs_stochastic_buffers) {
|
||||
|
||||
Ссылка в новой задаче
Block a user