23namespace shambase::details {
79 std::vector<ChromeProfileEntry> profile_data_chrome;
91 return static_cast<u64>(
in * 1
e6);
130namespace shambase::details {
221 std::string _callstack_process_identifier;
223 void set_callstack_process_identifier(std::string
identifier) {
224 _callstack_process_identifier = std::move(
identifier);
227 std::vector<std::function<std::string()>> _callstack_gen_info_generators;
229 void add_callstack_gen_info_generator(std::string (*generator)()) {
230 _callstack_gen_info_generators.push_back(std::move(generator));
239 std::stack<SourceLocation>
cpy = details::call_stack;
241 std::vector<std::string>
lines;
243 while (!
cpy.empty()) {
245 lines.push_back(
l.format_one_line_func());
251 std::stringstream
ss;
253 if (!_callstack_process_identifier.empty()) {
254 ss <<
" -> process identifier: " << _callstack_process_identifier <<
"\n";
258 ss << shambase::format(
" {:2} : {}\n",
i,
lines[
i]);
261 for (
auto &generator : _callstack_gen_info_generators) {
262 ss << generator() <<
"\n";
double f64
Alias for double.
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
Class Timer measures the time elapsed since the timer was started.
void end()
Stops the timer and stores the elapsed time in nanoseconds.
f64 elasped_sec() const
Converts the stored nanosecond time to a floating point representation in seconds.
void start()
Starts the timer.
namespace for basic c++ utilities
std::string fmt_callstack()
Get the formatted callstack.
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
void add_entry_chrome(std::source_location loc, f64 time, bool is_start)
Add a Chrome tracing entry to the storage.
auto make_timer
Utility to create a timer and start it.
Timer global_timer
Wall time global timer.
void clear_chrome_entry()
Clear the Chrome tracing entries storage.
std::vector< ChromeProfileEntry > profile_data_chrome
Chrome tracing entries storage.
std::vector< ProfileEntry > profile_data
Vector to hold profiling entries.
This file contains the definition for the stacktrace related functionality.
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.
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
Chrome tracing profile entry.
u64 time_val
Time value for the profile entry.
std::string name
Name of the profile entry.
bool is_start
Flag indicating if it is the start of the profile entry.
std::string format(u32 world_rank)
Format the Chrome profile entry.
Structure to hold data for a profiling entry.
f64 time_start
Start time of the profiling entry (in sec since program start)
std::string entry_name
Name of the profiling entry.
std::string format()
Format the profile entry as a JSON string.
f64 time_end
End time of the profiling entry (in sec since program start)
Utility class to emulates std::source_location class introduced in c++20 This class provides informat...
constexpr const char * function_name() const noexcept
Returns the function name of the source location.