Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Classes | Namespaces | Functions | Variables
stacktrace.cpp File Reference
#include "shambase/stacktrace.hpp"
#include "shambase/time.hpp"
#include <sstream>
#include <string>
#include <vector>
+ Include dependency graph for stacktrace.cpp:

Go to the source code of this file.

Classes

struct  shambase::details::ChromeProfileEntry
 Chrome tracing profile entry. More...
 
struct  shambase::details::ProfileEntry
 Structure to hold data for a profiling entry. More...
 

Namespaces

namespace  shambase
 namespace for basic c++ utilities
 

Functions

void shambase::details::add_entry_chrome (std::source_location loc, f64 time, bool is_start)
 Add a Chrome tracing entry to the storage.
 
void shambase::details::clear_chrome_entry ()
 Clear the Chrome tracing entries storage.
 
void shambase::details::dump_profilings_chrome (const std::string &process_prefix, u32 world_rank)
 Dump the profiling data in a Chrome Tracing format.
 
f64 shambase::details::get_wtime ()
 Returns the current wall clock time in seconds.
 
void shambase::details::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 entry for start and end.
 
void shambase::details::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 entry in the builtin profiling data.
 
void shambase::details::clear_profiling_data ()
 Clear the profiling data. (should be done in large run to avoid out-of-memory)
 
void shambase::details::dump_profilings (const std::string &process_prefix, u32 world_rank)
 Dump the profiling data in a JSON format to a file.
 
void shambase::set_callstack_process_identifier (std::string identifier)
 
void shambase::add_callstack_gen_info_generator (std::string(*generator)())
 
std::string shambase::fmt_callstack ()
 Get the formatted callstack.
 

Variables

std::vector< ChromeProfileEntryshambase::details::profile_data_chrome
 Chrome tracing entries storage.
 
auto shambase::details::make_timer
 Utility to create a timer and start it.
 
Timer shambase::details::global_timer = make_timer()
 Wall time global timer.
 
std::vector< ProfileEntryshambase::details::profile_data
 Vector to hold profiling entries.
 
std::string shambase::_callstack_process_identifier
 
std::vector< std::function< std::string()> > shambase::_callstack_gen_info_generators
 

Detailed Description

Author
Timothée David–Cléris (tim.s.nosp@m.hamr.nosp@m.ock@p.nosp@m.roto.nosp@m.n.me)

Definition in file stacktrace.cpp.

Function Documentation

◆ add_entry_chrome()

void shambase::details::add_entry_chrome ( std::source_location  loc,
f64  time,
bool  is_start 
)
inline

Add a Chrome tracing entry to the storage.

Parameters
locThe source location of the entry
timeThe time of the entry
is_startWhether the entry is a start or end entry

Definition at line 70 of file stacktrace.cpp.

◆ clear_chrome_entry()

void shambase::details::clear_chrome_entry ( )
inline

Clear the Chrome tracing entries storage.

Definition at line 83 of file stacktrace.cpp.

◆ clear_profiling_data()

void shambase::details::clear_profiling_data ( )

Clear the profiling data. (should be done in large run to avoid out-of-memory)

Definition at line 195 of file stacktrace.cpp.

+ Here is the call graph for this function:

◆ dump_profilings()

void shambase::details::dump_profilings ( const std::string &  process_prefix,
u32  world_rank 
)

Dump the profiling data in a JSON format to a file.

Parameters
process_prefixThe prefix of the process name.
world_rankThe rank of the process.

Definition at line 200 of file stacktrace.cpp.

+ Here is the call graph for this function:

◆ dump_profilings_chrome()

void shambase::details::dump_profilings_chrome ( const std::string &  process_prefix,
u32  world_rank 
)

Dump the profiling data in a Chrome Tracing format.

Parameters
process_prefixThe prefix of the process name.
world_rankThe rank of the process.

Definition at line 85 of file stacktrace.cpp.

◆ get_wtime()

f64 shambase::details::get_wtime ( )

Returns the current wall clock time in seconds.

Get the current wall time.

Returns
f64 The current wall clock time in seconds.
f64 Wall time in seconds since program start

Definition at line 179 of file stacktrace.cpp.

+ Here is the call graph for this function:

◆ register_profile_entry()

void shambase::details::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 entry in the builtin profiling data.

Parameters
locThe source location of the profile entry.
start_timeThe start time of the profile entry.
end_timeThe end time of the profile entry.

Definition at line 188 of file stacktrace.cpp.

+ Here is the call graph for this function:

◆ register_profile_entry_start()

void shambase::details::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 entry for start and end.

Parameters
locThe source location of the profile entry.
start_timeThe start time of the profile entry.

Definition at line 184 of file stacktrace.cpp.

+ Here is the call graph for this function:

Variable Documentation

◆ global_timer

Timer shambase::details::global_timer = make_timer()

Wall time global timer.

Definition at line 140 of file stacktrace.cpp.

◆ make_timer

auto shambase::details::make_timer
Initial value:
= []() -> Timer {
Timer tmp;
tmp.start();
return tmp;
}

Utility to create a timer and start it.

Definition at line 133 of file stacktrace.cpp.

◆ profile_data

std::vector<ProfileEntry> shambase::details::profile_data

Vector to hold profiling entries.

Definition at line 172 of file stacktrace.cpp.

◆ profile_data_chrome

std::vector<ChromeProfileEntry> shambase::details::profile_data_chrome

Chrome tracing entries storage.

Definition at line 61 of file stacktrace.cpp.