diff --git a/projects/rocprofiler-sdk/samples/api_buffered_tracing/CMakeLists.txt b/projects/rocprofiler-sdk/samples/api_buffered_tracing/CMakeLists.txt index 03f3a0dde9..2903c24412 100644 --- a/projects/rocprofiler-sdk/samples/api_buffered_tracing/CMakeLists.txt +++ b/projects/rocprofiler-sdk/samples/api_buffered_tracing/CMakeLists.txt @@ -57,4 +57,5 @@ set_tests_properties( "samples" ENVIRONMENT "${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$" - ) + FAIL_REGULAR_EXPRESSION + "threw an exception") diff --git a/projects/rocprofiler-sdk/samples/api_callback_tracing/CMakeLists.txt b/projects/rocprofiler-sdk/samples/api_callback_tracing/CMakeLists.txt index 6aae451d7d..ebcac38eac 100644 --- a/projects/rocprofiler-sdk/samples/api_callback_tracing/CMakeLists.txt +++ b/projects/rocprofiler-sdk/samples/api_callback_tracing/CMakeLists.txt @@ -57,4 +57,5 @@ set_tests_properties( "samples" ENVIRONMENT "${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$" - ) + FAIL_REGULAR_EXPRESSION + "threw an exception") diff --git a/projects/rocprofiler-sdk/samples/counter_collection/CMakeLists.txt b/projects/rocprofiler-sdk/samples/counter_collection/CMakeLists.txt index 4e80703f07..3ad3ab924b 100644 --- a/projects/rocprofiler-sdk/samples/counter_collection/CMakeLists.txt +++ b/projects/rocprofiler-sdk/samples/counter_collection/CMakeLists.txt @@ -52,4 +52,5 @@ set_tests_properties( "samples" ENVIRONMENT "${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$" - ) + FAIL_REGULAR_EXPRESSION + "threw an exception") diff --git a/projects/rocprofiler-sdk/samples/intercept_table/CMakeLists.txt b/projects/rocprofiler-sdk/samples/intercept_table/CMakeLists.txt index a365ea5d8e..c472d663ad 100644 --- a/projects/rocprofiler-sdk/samples/intercept_table/CMakeLists.txt +++ b/projects/rocprofiler-sdk/samples/intercept_table/CMakeLists.txt @@ -56,4 +56,5 @@ set_tests_properties( "samples" ENVIRONMENT "${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$" - ) + FAIL_REGULAR_EXPRESSION + "threw an exception") diff --git a/projects/rocprofiler-sdk/source/lib/common/utility.cpp b/projects/rocprofiler-sdk/source/lib/common/utility.cpp index 7e4f228238..5327551390 100644 --- a/projects/rocprofiler-sdk/source/lib/common/utility.cpp +++ b/projects/rocprofiler-sdk/source/lib/common/utility.cpp @@ -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(ts.tv_sec) * nanosec) + static_cast(ts.tv_nsec); - return nanosec / _period; + return (static_cast(ts.tv_sec) * nanosec) + static_cast(ts.tv_nsec); } std::vector diff --git a/projects/rocprofiler-sdk/source/lib/common/utility.hpp b/projects/rocprofiler-sdk/source/lib/common/utility.hpp index e9ddca6e0f..35d234e74e 100644 --- a/projects/rocprofiler-sdk/source/lib/common/utility.hpp +++ b/projects/rocprofiler-sdk/source/lib/common/utility.hpp @@ -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