26namespace shambase::details {
35#ifdef SHAMROCK_USE_PROFILING
87 struct CallStackEntry {
95 CallStackEntry(
const CallStackEntry &) =
delete;
96 CallStackEntry &operator=(
const CallStackEntry &) =
delete;
97 CallStackEntry(CallStackEntry &&) =
delete;
98 CallStackEntry &operator=(CallStackEntry &&) =
delete;
100 inline ~CallStackEntry() {
110#ifdef SHAMROCK_USE_PROFILING
124#ifdef SHAMROCK_USE_PROFILING
143#ifdef SHAMROCK_USE_PROFILING
159#ifdef SHAMROCK_USE_PROFILING
175#ifdef SHAMROCK_USE_PROFILING
191#ifdef SHAMROCK_USE_PROFILING
207#ifdef SHAMROCK_USE_PROFILING
231 void set_callstack_process_identifier(std::string identifier);
233 void add_callstack_gen_info_generator(std::string (*generator)());
257#define __shamrock_stack_entry() \
258 [[maybe_unused]] StackEntry __shamrock_unique_name(stack_loc_) {}
266#define __shamrock_log_callsite(callsite) \
267 [[maybe_unused]] shambase::details::CallStackEntry __shamrock_unique_name(call_site_loc) { \
277#define __shamrock_stack_entry_with_callsite(callsite) \
278 [[maybe_unused]] StackEntry __shamrock_unique_name(stack_loc_) { callsite }
double f64
Alias for double.
std::uint32_t u32
32 bit unsigned integer
namespace for basic c++ utilities
std::string fmt_callstack()
Get the formatted callstack.
void stack_entry_start_no_time(const SourceLocation &fileloc, const std::optional< std::string > &name=std::nullopt, const std::optional< std::string > &category_name=std::nullopt)
Start a profiling event without a time info.
void stack_entry_end_no_time(const SourceLocation &fileloc, const std::optional< std::string > &name=std::nullopt, const std::optional< std::string > &category_name=std::nullopt)
End a profiling event without a time info.
void stack_entry_start(const SourceLocation &fileloc, f64 t_start, const std::optional< std::string > &name=std::nullopt, const std::optional< std::string > &category_name=std::nullopt)
Register the start of a profiling event.
void stack_entry_end(const SourceLocation &fileloc, f64 t_start, f64 tend, const std::optional< std::string > &name=std::nullopt, const std::optional< std::string > &category_name=std::nullopt)
Register the end of a profiling event.
shambase::details::NamedBasicStackEntry NamedStackEntry
Alias for shambase::details::NamedBasicStackEntry.
std::stack< SourceLocation > call_stack
The call stack used to keep track of the stack trace. It is used to print the stack trace when an exc...
void register_profile_entry(std::source_location loc, f64 start_time, f64 end_time)
Register a profile entry. This register the end of a profile entry for chrome tracing and a complete ...
void dump_profilings(const std::string &process_prefix, u32 world_rank)
Dump the profiling data in a JSON format to a file.
shambase::details::BasicStackEntry StackEntry
Alias for shambase::details::BasicStackEntry.
void dump_profilings_chrome(const std::string &process_prefix, u32 world_rank)
Dump the profiling data in a Chrome Tracing format.
void register_profile_entry_start(std::source_location loc, f64 start_time)
Register the start of a profile entry. This is required for chrome profiling as there is a separate e...
f64 get_wtime()
Returns the current wall clock time in seconds.
void clear_profiling_data()
Clear the profiling data. (should be done in large run to avoid out-of-memory).
provide information about the source location
SourceLocation loc
Source location attached to the entry.
~BasicStackEntry()
Destroy the Basic Stack Entry object.
CallStackEntry scoped_callstack_entry
scoped call stack entry
BasicStackEntry(bool do_timer=true, SourceLocation &&loc=SourceLocation{})
Construct a new Basic Stack Entry object.
bool do_timer
is the timer enabled for this entry
BasicStackEntry(SourceLocation &callsite, bool do_timer=true, SourceLocation &&loc=SourceLocation{})
Construct a new Basic Stack Entry object.
f64 wtime_start
start time of the entry
Helper class to manage the call stack entry.
bool do_timer
is the timer enabled for this entry
SourceLocation loc
Source location attached to the entry.
CallStackEntry scoped_callstack_entry
scoped call stack entry
~NamedBasicStackEntry()
Destroy the Named Basic Stack Entry object.
NamedBasicStackEntry(std::string name, bool do_timer=true, SourceLocation &&loc=SourceLocation{})
Construct a new Named Basic Stack Entry object.
f64 wtime_start
start time of the entry
std::string name
Name of the entry.
Provides macros for generating unique identifiers at compile time.