From a448da496362f614923b7835e4c44d0f89fee68f Mon Sep 17 00:00:00 2001 From: "Wen-Heng (Jack) Chung" Date: Thu, 19 Dec 2019 18:03:40 +0000 Subject: [PATCH] Introduce a new API roctracer_get_timestamp(). roctracer_status_t roctracer_get_timestamp(uint64_t* timestamp); Get system timestamp for roctracer clients. The API could be used to help roctracer clients understand the reference frame of timestamps when receiving activity callbacks, as the nanoseconds reported in the activity callbacks are not in the same reference frame as CPU walltime clock. [ROCm/roctracer commit: b7aa8fedb73d6564378b2fc5ffb76f830429fb7b] --- projects/roctracer/inc/roctracer.h | 4 ++++ projects/roctracer/src/core/roctracer.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/projects/roctracer/inc/roctracer.h b/projects/roctracer/inc/roctracer.h index 812fc464f4..ce9b31add9 100644 --- a/projects/roctracer/inc/roctracer.h +++ b/projects/roctracer/inc/roctracer.h @@ -225,6 +225,10 @@ bool roctracer_load( void roctracer_unload(bool destruct); +// Get system timestamp. +roctracer_status_t roctracer_get_timestamp( + uint64_t* timestamp); + #ifdef __cplusplus } // extern "C" block #endif // __cplusplus diff --git a/projects/roctracer/src/core/roctracer.cpp b/projects/roctracer/src/core/roctracer.cpp index 07a998db11..87b0ace7ff 100644 --- a/projects/roctracer/src/core/roctracer.cpp +++ b/projects/roctracer/src/core/roctracer.cpp @@ -1106,6 +1106,12 @@ PUBLIC_API void roctracer_unload(bool destruct) { ONLOAD_TRACE_END(); } +PUBLIC_API roctracer_status_t roctracer_get_timestamp(uint64_t* timestamp) { + API_METHOD_PREFIX + *timestamp = util::HsaRsrcFactory::Instance().TimestampNs(); + API_METHOD_SUFFIX +} + PUBLIC_API bool OnLoad(HsaApiTable* table, uint64_t runtime_version, uint64_t failed_tool_count, const char* const* failed_tool_names) { ONLOAD_TRACE_BEG();