From 1f3231bc959abe103184a1b0d4001c627513cba2 Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Mon, 20 Jun 2022 00:44:31 -0500 Subject: [PATCH] Define new function attributes (#55) - decorates several functions with OMNITRACE_HOT [ROCm/rocprofiler-systems commit: 32a8d40d254d61710a4425001dcf816c415051a6] --- .../source/lib/omnitrace/library/config.hpp | 36 +++++++++---------- .../source/lib/omnitrace/library/debug.hpp | 16 ++++----- .../lib/omnitrace/library/defines.hpp.in | 15 +++++--- .../source/lib/omnitrace/library/redirect.hpp | 6 ++-- .../source/lib/omnitrace/library/runtime.hpp | 20 +++++------ 5 files changed, 51 insertions(+), 42 deletions(-) diff --git a/projects/rocprofiler-systems/source/lib/omnitrace/library/config.hpp b/projects/rocprofiler-systems/source/lib/omnitrace/library/config.hpp index 1bc88458ce..255fcf8ce4 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace/library/config.hpp +++ b/projects/rocprofiler-systems/source/lib/omnitrace/library/config.hpp @@ -43,7 +43,7 @@ namespace omnitrace inline namespace config { bool -settings_are_configured(); +settings_are_configured() OMNITRACE_HOT; void configure_settings(bool _init = true); @@ -92,7 +92,7 @@ std::string get_config_file(); Mode -get_mode(); +get_mode() OMNITRACE_HOT; bool& is_attached(); @@ -101,10 +101,10 @@ bool& is_binary_rewrite(); bool -get_is_continuous_integration(); +get_is_continuous_integration() OMNITRACE_HOT; bool -get_debug_env(); +get_debug_env() OMNITRACE_HOT; bool get_debug_init(); @@ -113,40 +113,40 @@ bool get_debug_finalize(); bool -get_debug(); +get_debug() OMNITRACE_HOT; bool -get_debug_sampling(); +get_debug_sampling() OMNITRACE_HOT; bool -get_debug_tid(); +get_debug_tid() OMNITRACE_HOT; bool -get_debug_pid(); +get_debug_pid() OMNITRACE_HOT; int -get_verbose_env(); +get_verbose_env() OMNITRACE_HOT; int -get_verbose(); +get_verbose() OMNITRACE_HOT; bool& -get_use_perfetto(); +get_use_perfetto() OMNITRACE_HOT; bool& -get_use_timemory(); +get_use_timemory() OMNITRACE_HOT; bool& -get_use_roctracer(); +get_use_roctracer() OMNITRACE_HOT; bool& -get_use_rocm_smi(); +get_use_rocm_smi() OMNITRACE_HOT; bool& -get_use_sampling(); +get_use_sampling() OMNITRACE_HOT; bool& -get_use_thread_sampling(); +get_use_thread_sampling() OMNITRACE_HOT; bool& get_use_pid(); @@ -155,7 +155,7 @@ bool& get_use_mpip(); bool& -get_use_critical_trace(); +get_use_critical_trace() OMNITRACE_HOT; bool get_use_kokkosp(); @@ -253,7 +253,7 @@ get_trace_thread_locks(); // Runtime configuration data // State& -get_state(); +get_state() TIMEMORY_HOT; /// returns old state State set_state(State); diff --git a/projects/rocprofiler-systems/source/lib/omnitrace/library/debug.hpp b/projects/rocprofiler-systems/source/lib/omnitrace/library/debug.hpp index 9195ceb868..b297a885f0 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace/library/debug.hpp +++ b/projects/rocprofiler-systems/source/lib/omnitrace/library/debug.hpp @@ -44,28 +44,28 @@ namespace omnitrace inline namespace config { bool -get_debug(); +get_debug() OMNITRACE_HOT; int -get_verbose(); +get_verbose() OMNITRACE_HOT; bool -get_debug_env(); +get_debug_env() OMNITRACE_HOT; int -get_verbose_env(); +get_verbose_env() OMNITRACE_HOT; bool -get_is_continuous_integration(); +get_is_continuous_integration() OMNITRACE_HOT; bool -get_debug_tid(); +get_debug_tid() OMNITRACE_HOT; bool -get_debug_pid(); +get_debug_pid() OMNITRACE_HOT; bool -get_critical_trace_debug(); +get_critical_trace_debug() OMNITRACE_HOT; } // namespace config namespace debug diff --git a/projects/rocprofiler-systems/source/lib/omnitrace/library/defines.hpp.in b/projects/rocprofiler-systems/source/lib/omnitrace/library/defines.hpp.in index 37e88dd48f..1dde14889e 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace/library/defines.hpp.in +++ b/projects/rocprofiler-systems/source/lib/omnitrace/library/defines.hpp.in @@ -57,10 +57,17 @@ #define OMNITRACE_SAMPLING_GPU_BUSY OMNITRACE_SAMPLING_GPU_BUSY_idx #define OMNITRACE_SAMPLING_GPU_MEMORY_USAGE OMNITRACE_SAMPLING_GPU_MEMORY_USAGE_idx -#define OMNITRACE_ATTRIBUTE(...) __attribute__((__VA_ARGS__)) -#define OMNITRACE_VISIBILITY(MODE) OMNITRACE_ATTRIBUTE(visibility(MODE)) -#define OMNITRACE_PUBLIC_API OMNITRACE_VISIBILITY("default") -#define OMNITRACE_HIDDEN_API OMNITRACE_VISIBILITY("hidden") +#define OMNITRACE_ATTRIBUTE(...) __attribute__((__VA_ARGS__)) +#define OMNITRACE_VISIBILITY(MODE) OMNITRACE_ATTRIBUTE(visibility(MODE)) +#define OMNITRACE_PUBLIC_API OMNITRACE_VISIBILITY("default") +#define OMNITRACE_HIDDEN_API OMNITRACE_VISIBILITY("hidden") +#define OMNITRACE_INLINE OMNITRACE_ATTRIBUTE(always_inline) inline +#define OMNITRACE_NOINLINE OMNITRACE_ATTRIBUTE(noinline) +#define OMNITRACE_HOT OMNITRACE_ATTRIBUTE(hot) +#define OMNITRACE_CONST OMNITRACE_ATTRIBUTE(const) +#define OMNITRACE_PURE OMNITRACE_ATTRIBUTE(pure) +#define OMNITRACE_PACKED OMNITRACE_ATTRIBUTE(__packed__) +#define OMNITRACE_PACKED_ALIGN(VAL) OMNITRACE_PACKED OMNITRACE_ATTRIBUTE(__aligned__(VAL)) #if defined(OMNITRACE_CI) && OMNITRACE_CI > 0 # if defined(NDEBUG) diff --git a/projects/rocprofiler-systems/source/lib/omnitrace/library/redirect.hpp b/projects/rocprofiler-systems/source/lib/omnitrace/library/redirect.hpp index 9e26acf666..24dabfc3df 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace/library/redirect.hpp +++ b/projects/rocprofiler-systems/source/lib/omnitrace/library/redirect.hpp @@ -22,6 +22,8 @@ #pragma once +#include "library/defines.hpp" + #include #include #include @@ -34,10 +36,10 @@ namespace omnitrace inline namespace config { bool -get_debug(); +get_debug() OMNITRACE_HOT; int -get_verbose(); +get_verbose() OMNITRACE_HOT; } // namespace config struct redirect diff --git a/projects/rocprofiler-systems/source/lib/omnitrace/library/runtime.hpp b/projects/rocprofiler-systems/source/lib/omnitrace/library/runtime.hpp index fe3ab4d9e4..91a8b310da 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace/library/runtime.hpp +++ b/projects/rocprofiler-systems/source/lib/omnitrace/library/runtime.hpp @@ -68,37 +68,37 @@ std::unique_ptr& get_gotcha_bundle(); std::atomic& -get_cpu_cid(); +get_cpu_cid() TIMEMORY_HOT; unique_ptr_t>& -get_cpu_cid_stack(int64_t _tid = threading::get_id(), int64_t _parent = 0); +get_cpu_cid_stack(int64_t _tid = threading::get_id(), int64_t _parent = 0) TIMEMORY_HOT; using cpu_cid_data_t = std::tuple; using cpu_cid_pair_t = std::tuple; using cpu_cid_parent_map_t = std::unordered_map; unique_ptr_t& -get_cpu_cid_parents(int64_t _tid = threading::get_id()); +get_cpu_cid_parents(int64_t _tid = threading::get_id()) TIMEMORY_HOT; cpu_cid_data_t -create_cpu_cid_entry(int64_t _tid = threading::get_id()); +create_cpu_cid_entry(int64_t _tid = threading::get_id()) TIMEMORY_HOT; cpu_cid_pair_t -get_cpu_cid_entry(uint64_t _cid, int64_t _tid = threading::get_id()); +get_cpu_cid_entry(uint64_t _cid, int64_t _tid = threading::get_id()) TIMEMORY_HOT; tim::mutex_t& -get_cpu_cid_stack_lock(int64_t _tid = threading::get_id()); +get_cpu_cid_stack_lock(int64_t _tid = threading::get_id()) TIMEMORY_HOT; ThreadState& -get_thread_state(); +get_thread_state() TIMEMORY_HOT; /// returns old state -ThreadState set_thread_state(ThreadState); +ThreadState set_thread_state(ThreadState) TIMEMORY_HOT; -ThreadState push_thread_state(ThreadState); +ThreadState push_thread_state(ThreadState) TIMEMORY_HOT; ThreadState -pop_thread_state(); +pop_thread_state() TIMEMORY_HOT; struct scoped_thread_state {