intel: move timestamp scaling helper to intel/perf
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Antonio Caggiano <antonio.caggiano@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13831>
This commit is contained in:

committed by
Marge Bot

parent
6126742648
commit
5a2cff9bc8
@@ -40,16 +40,6 @@ uint64_t IntelDriver::get_min_sampling_period_ns()
|
|||||||
return (2.f * perf->devinfo.timestamp_frequency) / 1000000000ull;
|
return (2.f * perf->devinfo.timestamp_frequency) / 1000000000ull;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t scale_gpu_timestamp(uint64_t ts, uint64_t timestamp_frequency)
|
|
||||||
{
|
|
||||||
// Try to avoid going over the 64bits when doing the scaling
|
|
||||||
uint64_t lower_ts = ts >> 6;
|
|
||||||
uint64_t scaled_ts = lower_ts * 1000000000ull / timestamp_frequency;
|
|
||||||
scaled_ts <<= 6;
|
|
||||||
scaled_ts += (ts & 0x3f) * 1000000000ull / timestamp_frequency;
|
|
||||||
return scaled_ts;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t read_gpu_timestamp(int drm_fd)
|
uint64_t read_gpu_timestamp(int drm_fd)
|
||||||
{
|
{
|
||||||
drm_i915_reg_read reg_read = {};
|
drm_i915_reg_read reg_read = {};
|
||||||
@@ -233,8 +223,8 @@ std::vector<PerfRecord> IntelDriver::parse_perf_records(const std::vector<uint8_
|
|||||||
|
|
||||||
uint64_t gpu_timestamp = gpu_timestamp_udw + gpu_timestamp_ldw;
|
uint64_t gpu_timestamp = gpu_timestamp_udw + gpu_timestamp_ldw;
|
||||||
|
|
||||||
auto duration = scale_gpu_timestamp(gpu_timestamp - prev_gpu_timestamp,
|
auto duration = intel_perf_scale_gpu_timestamp(&perf->devinfo,
|
||||||
perf->devinfo.timestamp_frequency);
|
gpu_timestamp - prev_gpu_timestamp);
|
||||||
|
|
||||||
// Skip perf-records that are too short by checking
|
// Skip perf-records that are too short by checking
|
||||||
// the distance between last report and this one
|
// the distance between last report and this one
|
||||||
@@ -328,7 +318,8 @@ uint64_t IntelDriver::gpu_next()
|
|||||||
// Consume first record
|
// Consume first record
|
||||||
records.erase(std::begin(records), std::begin(records) + 1);
|
records.erase(std::begin(records), std::begin(records) + 1);
|
||||||
|
|
||||||
return scale_gpu_timestamp(gpu_timestamp, perf->devinfo.timestamp_frequency);
|
return intel_perf_scale_gpu_timestamp(&perf->devinfo,
|
||||||
|
gpu_timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t IntelDriver::next()
|
uint64_t IntelDriver::next()
|
||||||
@@ -345,8 +336,8 @@ uint32_t IntelDriver::gpu_clock_id() const
|
|||||||
|
|
||||||
uint64_t IntelDriver::gpu_timestamp() const
|
uint64_t IntelDriver::gpu_timestamp() const
|
||||||
{
|
{
|
||||||
return scale_gpu_timestamp(read_gpu_timestamp(drm_device.fd),
|
return intel_perf_scale_gpu_timestamp(&perf->devinfo,
|
||||||
perf->devinfo.timestamp_frequency);
|
read_gpu_timestamp(drm_device.fd));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace pps
|
} // namespace pps
|
||||||
|
@@ -1027,6 +1027,17 @@ can_use_mi_rpc_bc_counters(const struct intel_device_info *devinfo)
|
|||||||
return devinfo->ver <= 11;
|
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
|
uint64_t
|
||||||
intel_perf_report_timestamp(const struct intel_perf_query_info *query,
|
intel_perf_report_timestamp(const struct intel_perf_query_info *query,
|
||||||
const uint32_t *report)
|
const uint32_t *report)
|
||||||
|
@@ -464,6 +464,11 @@ 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,
|
uint64_t intel_perf_report_timestamp(const struct intel_perf_query_info *query,
|
||||||
const uint32_t *report);
|
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
|
/** Accumulate the delta between 2 snapshots of OA perf registers (layout
|
||||||
* should match description specified through intel_perf_query_register_layout).
|
* should match description specified through intel_perf_query_register_layout).
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user