Utility timestamp_ns() fix (#175)
* Update lib/common/utility.* - fix timestamp_ns() * Update samples/**/CMakeLists.txt - fail test if exception thrown * source formatting (clang-format v11) (#176) Co-authored-by: jrmadsen <jrmadsen@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
55f2dabbb3
Коммит
7a8931e57f
@@ -57,4 +57,5 @@ set_tests_properties(
|
||||
"samples"
|
||||
ENVIRONMENT
|
||||
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$<TARGET_FILE:rocprofiler::rocprofiler>"
|
||||
)
|
||||
FAIL_REGULAR_EXPRESSION
|
||||
"threw an exception")
|
||||
|
||||
@@ -57,4 +57,5 @@ set_tests_properties(
|
||||
"samples"
|
||||
ENVIRONMENT
|
||||
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$<TARGET_FILE:rocprofiler::rocprofiler>"
|
||||
)
|
||||
FAIL_REGULAR_EXPRESSION
|
||||
"threw an exception")
|
||||
|
||||
@@ -52,4 +52,5 @@ set_tests_properties(
|
||||
"samples"
|
||||
ENVIRONMENT
|
||||
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$<TARGET_FILE:rocprofiler::rocprofiler-library>"
|
||||
)
|
||||
FAIL_REGULAR_EXPRESSION
|
||||
"threw an exception")
|
||||
|
||||
@@ -56,4 +56,5 @@ set_tests_properties(
|
||||
"samples"
|
||||
ENVIRONMENT
|
||||
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$<TARGET_FILE:rocprofiler::rocprofiler>"
|
||||
)
|
||||
FAIL_REGULAR_EXPRESSION
|
||||
"threw an exception")
|
||||
|
||||
@@ -90,7 +90,7 @@ get_accurate_clock_id_impl()
|
||||
}
|
||||
|
||||
uint64_t
|
||||
get_clock_freq_ns_impl(clockid_t _clk_id)
|
||||
get_clock_period_ns_impl(clockid_t _clk_id)
|
||||
{
|
||||
constexpr auto nanosec = std::nano::den;
|
||||
|
||||
@@ -110,9 +110,7 @@ get_clock_freq_ns_impl(clockid_t _clk_id)
|
||||
<< ") returned very low frequency (<1Hz)";
|
||||
}
|
||||
|
||||
auto&& _period =
|
||||
(static_cast<uint64_t>(ts.tv_sec) * nanosec) + static_cast<uint64_t>(ts.tv_nsec);
|
||||
return nanosec / _period;
|
||||
return (static_cast<uint64_t>(ts.tv_sec) * nanosec) + static_cast<uint64_t>(ts.tv_nsec);
|
||||
}
|
||||
|
||||
std::vector<std::string>
|
||||
|
||||
@@ -51,7 +51,7 @@ clockid_t
|
||||
get_accurate_clock_id_impl();
|
||||
|
||||
uint64_t
|
||||
get_clock_freq_ns_impl(clockid_t _clk_id);
|
||||
get_clock_period_ns_impl(clockid_t _clk_id);
|
||||
|
||||
inline uint64_t
|
||||
get_tid()
|
||||
@@ -69,10 +69,10 @@ get_accurate_clock_id()
|
||||
}
|
||||
|
||||
inline uint64_t
|
||||
get_accurate_clock_freq_ns()
|
||||
get_accurate_clock_period_ns()
|
||||
{
|
||||
static auto clk_freq = get_clock_freq_ns_impl(get_accurate_clock_id());
|
||||
return clk_freq;
|
||||
static auto clk_period = get_clock_period_ns_impl(get_accurate_clock_id());
|
||||
return clk_period;
|
||||
}
|
||||
|
||||
inline uint64_t
|
||||
@@ -95,17 +95,20 @@ get_ticks(clockid_t clk_id_v) noexcept
|
||||
inline uint64_t
|
||||
timestamp_ns()
|
||||
{
|
||||
return get_ticks(get_accurate_clock_id()) * get_accurate_clock_freq_ns();
|
||||
auto&& clk_period = get_accurate_clock_period_ns();
|
||||
if(ROCPROFILER_LIKELY(clk_period == 1)) return get_ticks(get_accurate_clock_id());
|
||||
return get_ticks(get_accurate_clock_id()) / clk_period;
|
||||
}
|
||||
|
||||
// this equates to HSA-runtime library implementation of os::ReadSystemClock()
|
||||
inline uint64_t
|
||||
system_timestamp_ns()
|
||||
{
|
||||
constexpr auto boottime_clk = CLOCK_BOOTTIME;
|
||||
static auto boottime_clk_freq = get_clock_freq_ns_impl(boottime_clk);
|
||||
constexpr auto boottime_clk = CLOCK_BOOTTIME;
|
||||
static auto boottime_clk_period = get_clock_period_ns_impl(boottime_clk);
|
||||
|
||||
return get_ticks(boottime_clk) * boottime_clk_freq;
|
||||
if(ROCPROFILER_LIKELY(boottime_clk_period == 1)) return get_ticks(boottime_clk);
|
||||
return get_ticks(boottime_clk) / boottime_clk_period;
|
||||
}
|
||||
|
||||
std::vector<std::string>
|
||||
|
||||
Ссылка в новой задаче
Block a user