intel/dev,perf: Use a single timescale function
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Rohan Garg <rohan.garg@intel.com> Acked-by: Antonio Caggiano <antonio.caggiano@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13996>
This commit is contained in:
parent
02a4d622ed
commit
d3724de894
|
@ -448,7 +448,12 @@ static inline uint64_t
|
|||
intel_device_info_timebase_scale(const struct intel_device_info *devinfo,
|
||||
uint64_t gpu_timestamp)
|
||||
{
|
||||
return (1000000000ull * gpu_timestamp) / devinfo->timestamp_frequency;
|
||||
/* Try to avoid going over the 64bits when doing the scaling */
|
||||
uint64_t upper_ts = gpu_timestamp >> 32;
|
||||
uint64_t lower_ts = gpu_timestamp & 0xffffffff;
|
||||
uint64_t upper_scaled_ts = upper_ts * 1000000000ull / devinfo->timestamp_frequency;
|
||||
uint64_t lower_scaled_ts = lower_ts * 1000000000ull / devinfo->timestamp_frequency;
|
||||
return (upper_scaled_ts << 32) + lower_scaled_ts;
|
||||
}
|
||||
|
||||
bool intel_get_device_info_from_fd(int fh, struct intel_device_info *devinfo);
|
||||
|
|
|
@ -223,8 +223,8 @@ std::vector<PerfRecord> IntelDriver::parse_perf_records(const std::vector<uint8_
|
|||
|
||||
uint64_t gpu_timestamp = gpu_timestamp_udw + gpu_timestamp_ldw;
|
||||
|
||||
auto duration = intel_perf_scale_gpu_timestamp(&perf->devinfo,
|
||||
gpu_timestamp - prev_gpu_timestamp);
|
||||
auto duration = intel_device_info_timebase_scale(&perf->devinfo,
|
||||
gpu_timestamp - prev_gpu_timestamp);
|
||||
|
||||
// Skip perf-records that are too short by checking
|
||||
// the distance between last report and this one
|
||||
|
@ -318,8 +318,7 @@ uint64_t IntelDriver::gpu_next()
|
|||
// Consume first record
|
||||
records.erase(std::begin(records), std::begin(records) + 1);
|
||||
|
||||
return intel_perf_scale_gpu_timestamp(&perf->devinfo,
|
||||
gpu_timestamp);
|
||||
return intel_device_info_timebase_scale(&perf->devinfo, gpu_timestamp);
|
||||
}
|
||||
|
||||
uint64_t IntelDriver::next()
|
||||
|
@ -336,8 +335,8 @@ uint32_t IntelDriver::gpu_clock_id() const
|
|||
|
||||
uint64_t IntelDriver::gpu_timestamp() const
|
||||
{
|
||||
return intel_perf_scale_gpu_timestamp(&perf->devinfo,
|
||||
read_gpu_timestamp(drm_device.fd));
|
||||
return intel_device_info_timebase_scale(&perf->devinfo,
|
||||
read_gpu_timestamp(drm_device.fd));
|
||||
}
|
||||
|
||||
} // namespace pps
|
||||
|
|
|
@ -1027,17 +1027,6 @@ can_use_mi_rpc_bc_counters(const struct intel_device_info *devinfo)
|
|||
return devinfo->ver <= 11;
|
||||
}
|
||||
|
||||
uint64_t intel_perf_scale_gpu_timestamp(const struct intel_device_info *devinfo,
|
||||
uint64_t ts)
|
||||
{
|
||||
// Try to avoid going over the 64bits when doing the scaling
|
||||
uint64_t lower_ts = ts >> 6;
|
||||
uint64_t scaled_ts = lower_ts * 1000000000ull / devinfo->timestamp_frequency;
|
||||
scaled_ts <<= 6;
|
||||
scaled_ts += (ts & 0x3f) * 1000000000ull / devinfo->timestamp_frequency;
|
||||
return scaled_ts;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
intel_perf_report_timestamp(const struct intel_perf_query_info *query,
|
||||
const uint32_t *report)
|
||||
|
|
|
@ -464,11 +464,6 @@ void intel_perf_query_result_accumulate(struct intel_perf_query_result *result,
|
|||
uint64_t intel_perf_report_timestamp(const struct intel_perf_query_info *query,
|
||||
const uint32_t *report);
|
||||
|
||||
/** Turn a GPU timestamp into a nanosecond value.
|
||||
*/
|
||||
uint64_t intel_perf_scale_gpu_timestamp(const struct intel_device_info *devinfo,
|
||||
uint64_t ts);
|
||||
|
||||
/** Accumulate the delta between 2 snapshots of OA perf registers (layout
|
||||
* should match description specified through intel_perf_query_register_layout).
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue