timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
|
#include "timemory/manager/manager.hpp"
Classes | |
struct | get_storage |
This is used to apply/query storage data for multiple component types. More... | |
struct | get_storage< Tuple< Types... > > |
Overload for a tuple/type-list. More... | |
Public Types | |
using | this_type = manager |
using | pointer_t = std::shared_ptr< this_type > |
using | pointer_pair_t = std::pair< pointer_t, pointer_t > |
using | size_type = std::size_t |
using | string_t = std::string |
using | comm_group_t = std::tuple< mpi::comm_t, int32_t > |
using | mutex_t = std::recursive_mutex |
using | auto_lock_t = std::unique_lock< mutex_t > |
using | auto_lock_ptr_t = std::shared_ptr< std::unique_lock< mutex_t > > |
using | initializer_func_t = std::function< bool()> |
using | initializer_list_t = std::deque< initializer_func_t > |
using | finalizer_func_t = std::function< void()> |
using | finalizer_pair_t = std::pair< std::string, finalizer_func_t > |
using | finalizer_list_t = std::deque< finalizer_pair_t > |
using | finalizer_pmap_t = std::map< int32_t, finalizer_list_t > |
using | synchronize_list_t = uomap_t< string_t, uomap_t< int64_t, std::function< void()> > > |
using | finalizer_void_t = std::multimap< void *, finalizer_func_t > |
using | settings_ptr_t = std::shared_ptr< settings > |
using | filemap_t = std::map< string_t, std::map< string_t, std::set< string_t > > > |
using | metadata_func_t = std::vector< std::function< void(void *)> > |
using | metadata_info_t = std::multimap< string_t, string_t > |
using | enum_set_t = std::set< TIMEMORY_COMPONENT > |
template<typename Tp > | |
using | enum_map_t = std::map< TIMEMORY_COMPONENT, Tp > |
Public Member Functions | |
manager () | |
~manager () | |
manager (const manager &)=delete | |
manager (manager &&)=delete | |
manager & | operator= (const manager &)=delete |
manager & | operator= (manager &&)=delete |
template<typename Func > | |
void | add_cleanup (void *, Func &&) |
add functors to destroy instances based on a pointer More... | |
template<typename Func > | |
void | add_cleanup (const std::string &, Func &&) |
add functors to destroy instances based on a string key More... | |
template<typename InitFuncT > | |
void | add_initializer (InitFuncT &&) |
this is used by storage classes for finalization. More... | |
template<typename StackFuncT , typename FinalFuncT > | |
void | add_finalizer (const std::string &, StackFuncT &&, FinalFuncT &&, bool, int32_t=0) |
this is used by storage classes for finalization. More... | |
void | remove_cleanup (void *) |
remove a cleanup functor More... | |
void | remove_cleanup (const std::string &) |
remove a cleanup functor More... | |
void | remove_finalizer (const std::string &) |
remove a finalizer functor More... | |
void | cleanup (const std::string &) |
execute a cleanup based on a key More... | |
void | cleanup () |
void | initialize () |
void | finalize () |
bool | is_initialized () const |
bool | is_finalized () const |
void | add_file_output (const string_t &_category, const string_t &_label, const string_t &_file) |
void | add_text_output (const string_t &_label, const string_t &_file) |
void | add_json_output (const string_t &_label, const string_t &_file) |
void | set_write_metadata (short v) |
Set to 0 for yes if other output, -1 for never, or 1 for yes. More... | |
void | write_metadata (const std::string &, const char *="") |
Print metadata to filename. More... | |
std::ostream & | write_metadata (std::ostream &) |
Write metadata to ostream. More... | |
void | update_metadata_prefix () |
Updates settings, rank, output prefix, etc. More... | |
int32_t | get_rank () const |
Get the dmp rank. This is stored to avoid having to do MPI/UPC++ query after finalization has been called. More... | |
bool | is_finalizing () const |
Query whether finalization is currently occurring. More... | |
void | is_finalizing (bool v) |
Sets whether finalization is currently occuring. More... | |
void | add_entries (uint64_t n) |
Add number of component output data entries. If this value is zero, metadata output is suppressed unless tim::manager::set_write_metadata was assigned a value of 1. More... | |
void | add_synchronization (const std::string &, int64_t, std::function< void()>) |
Add function for synchronizing data in threads. More... | |
void | remove_synchronization (const std::string &, int64_t) |
Remove function for synchronizing data in threads. More... | |
void | synchronize () |
Synchronizes thread-data for storage. More... | |
int32_t | instance_count () const |
Get the instance ID for this manager instance. More... | |
int64_t | get_tid () const |
Get the thread-index for this manager instance. More... | |
template<typename Archive , typename Tp > | |
void | do_serialize (Archive &ar, const enum_set_t &_types) |
Static Public Member Functions | |
static pointer_t | instance () |
Get a shared pointer to the instance for the current thread. More... | |
static pointer_t | master_instance () |
Get a shared pointer to the instance on the primary thread. More... | |
static int32_t | total_instance_count () |
Get the number of instances that are currently allocated. This is decremented during the destructor of each manager instance, unlike tim::manager::get_thread_count() More... | |
static void | use_exit_hook (bool val) |
Enable setting std::exit callback. More... | |
static void | exit_hook () |
The exit hook function. More... | |
static int32_t | get_thread_count () |
This effectively provides the total number of threads which collected data. It is only "decremented" when the last manager instance has been deleted, at which point it is set to zero. More... | |
static bool | get_is_main_thread () |
Return whether this is the main thread. More... | |
template<typename Tp > | |
static void | add_metadata (const std::string &, const Tp &) |
Add a metadata entry of a non-string type. If this fails to serialize, either include either the approiate header from timemory/tpls/cereal/cereal/types or provides a serialization function for the type. More... | |
static void | add_metadata (const std::string &, const char *) |
Add a metadata entry of a const character array. This only exists to avoid the template function from serializing the pointer. More... | |
static void | add_metadata (const std::string &, const std::string &) |
Add a metadata entry of a string. More... | |
static void | set_persistent_master (pointer_t _pinst) |
This function stores the primary manager instance for the application. More... | |
static void | update_settings (const settings &_settings) |
Updates the settings instance use by the manager instance. More... | |
Protected Member Functions | |
string_t | get_prefix () const |
void | internal_write_metadata (const char *="") |
Friends | |
template<typename... Types> | |
struct | get_storage |
template<typename... Types> | |
struct | filtered_get_storage |
Definition at line 66 of file manager.hpp.
using tim::manager::auto_lock_ptr_t = std::shared_ptr<std::unique_lock<mutex_t> > |
Definition at line 80 of file manager.hpp.
using tim::manager::auto_lock_t = std::unique_lock<mutex_t> |
Definition at line 79 of file manager.hpp.
using tim::manager::comm_group_t = std::tuple<mpi::comm_t, int32_t> |
Definition at line 77 of file manager.hpp.
using tim::manager::enum_map_t = std::map<TIMEMORY_COMPONENT, Tp> |
Definition at line 95 of file manager.hpp.
using tim::manager::enum_set_t = std::set<TIMEMORY_COMPONENT> |
Definition at line 93 of file manager.hpp.
using tim::manager::filemap_t = std::map<string_t, std::map<string_t, std::set<string_t> >> |
Definition at line 90 of file manager.hpp.
using tim::manager::finalizer_func_t = std::function<void()> |
Definition at line 83 of file manager.hpp.
using tim::manager::finalizer_list_t = std::deque<finalizer_pair_t> |
Definition at line 85 of file manager.hpp.
using tim::manager::finalizer_pair_t = std::pair<std::string, finalizer_func_t> |
Definition at line 84 of file manager.hpp.
using tim::manager::finalizer_pmap_t = std::map<int32_t, finalizer_list_t> |
Definition at line 86 of file manager.hpp.
using tim::manager::finalizer_void_t = std::multimap<void*, finalizer_func_t> |
Definition at line 88 of file manager.hpp.
using tim::manager::initializer_func_t = std::function<bool()> |
Definition at line 81 of file manager.hpp.
using tim::manager::initializer_list_t = std::deque<initializer_func_t> |
Definition at line 82 of file manager.hpp.
using tim::manager::metadata_func_t = std::vector<std::function<void(void*)> > |
Definition at line 91 of file manager.hpp.
using tim::manager::metadata_info_t = std::multimap<string_t, string_t> |
Definition at line 92 of file manager.hpp.
using tim::manager::mutex_t = std::recursive_mutex |
Definition at line 78 of file manager.hpp.
using tim::manager::pointer_pair_t = std::pair<pointer_t, pointer_t> |
Definition at line 74 of file manager.hpp.
using tim::manager::pointer_t = std::shared_ptr<this_type> |
Definition at line 73 of file manager.hpp.
using tim::manager::settings_ptr_t = std::shared_ptr<settings> |
Definition at line 89 of file manager.hpp.
using tim::manager::size_type = std::size_t |
Definition at line 75 of file manager.hpp.
using tim::manager::string_t = std::string |
Definition at line 76 of file manager.hpp.
using tim::manager::synchronize_list_t = uomap_t<string_t, uomap_t<int64_t, std::function<void()> >> |
Definition at line 87 of file manager.hpp.
using tim::manager::this_type = manager |
Definition at line 72 of file manager.hpp.
tim::manager::manager | ( | ) |
tim::manager::~manager | ( | ) |
|
delete |
|
delete |
void tim::manager::add_cleanup | ( | const std::string & | _key, |
Func && | _func | ||
) |
add functors to destroy instances based on a string key
Definition at line 431 of file manager.hpp.
References remove_cleanup().
void tim::manager::add_cleanup | ( | void * | _key, |
Func && | _func | ||
) |
add functors to destroy instances based on a pointer
Definition at line 421 of file manager.hpp.
|
inline |
Add number of component output data entries. If this value is zero, metadata output is suppressed unless tim::manager::set_write_metadata was assigned a value of 1.
Definition at line 157 of file manager.hpp.
void tim::manager::add_file_output | ( | const string_t & | _category, |
const string_t & | _label, | ||
const string_t & | _file | ||
) |
void tim::manager::add_finalizer | ( | const std::string & | _key, |
StackFuncT && | _stack_func, | ||
FinalFuncT && | _inst_func, | ||
bool | _is_master, | ||
int32_t | _priority = 0 |
||
) |
this is used by storage classes for finalization.
Definition at line 457 of file manager.hpp.
References tim::settings::get_global_output_prefix(), and remove_finalizer().
void tim::manager::add_initializer | ( | InitFuncT && | _init_func | ) |
this is used by storage classes for finalization.
Definition at line 443 of file manager.hpp.
|
static |
Add a metadata entry of a const character array. This only exists to avoid the template function from serializing the pointer.
|
static |
Add a metadata entry of a string.
|
static |
Add a metadata entry of a non-string type. If this fails to serialize, either include either the approiate header from timemory/tpls/cereal/cereal/types or provides a serialization function for the type.
Definition at line 479 of file manager.hpp.
Referenced by kokkosp_declare_metadata().
void tim::manager::add_synchronization | ( | const std::string & | , |
int64_t | , | ||
std::function< void()> | |||
) |
Add function for synchronizing data in threads.
void tim::manager::cleanup | ( | ) |
void tim::manager::cleanup | ( | const std::string & | ) |
execute a cleanup based on a key
void tim::manager::do_serialize | ( | Archive & | ar, |
const enum_set_t & | _types | ||
) |
Definition at line 571 of file manager.hpp.
|
static |
The exit hook function.
void tim::manager::finalize | ( | ) |
|
static |
Return whether this is the main thread.
|
protected |
|
inline |
Get the dmp rank. This is stored to avoid having to do MPI/UPC++ query after finalization has been called.
Definition at line 149 of file manager.hpp.
|
inlinestatic |
This effectively provides the total number of threads which collected data. It is only "decremented" when the last manager instance has been deleted, at which point it is set to zero.
Definition at line 182 of file manager.hpp.
Referenced by tim::operation::finalize::get< Type, true >::operator()().
|
inline |
Get the thread-index for this manager instance.
Definition at line 307 of file manager.hpp.
void tim::manager::initialize | ( | ) |
|
static |
Get a shared pointer to the instance for the current thread.
Referenced by tim::operation::finalize::flamegraph< Type >::flamegraph(), tim::component::activate_mpip(), tim::component::deactivate_mpip(), tim::component::perfetto_trace::global_finalize(), tim::openmp::callback_connector< Components, Api >::is_enabled(), tim::operation::finalize::print< Tp, true >::print_json(), tim::operation::finalize::print< Tp, true >::print_tree(), and timemory_trace_init().
|
inline |
Get the instance ID for this manager instance.
Definition at line 305 of file manager.hpp.
|
protected |
|
inline |
Definition at line 132 of file manager.hpp.
|
inline |
Query whether finalization is currently occurring.
Definition at line 151 of file manager.hpp.
|
inline |
Sets whether finalization is currently occuring.
Definition at line 153 of file manager.hpp.
|
inline |
Definition at line 131 of file manager.hpp.
|
static |
Get a shared pointer to the instance on the primary thread.
Referenced by tim::if().
void tim::manager::remove_cleanup | ( | const std::string & | ) |
remove a cleanup functor
void tim::manager::remove_cleanup | ( | void * | ) |
remove a cleanup functor
Referenced by add_cleanup().
void tim::manager::remove_finalizer | ( | const std::string & | ) |
remove a finalizer functor
Referenced by add_finalizer().
void tim::manager::remove_synchronization | ( | const std::string & | , |
int64_t | |||
) |
Remove function for synchronizing data in threads.
|
inlinestatic |
This function stores the primary manager instance for the application.
Definition at line 395 of file manager.hpp.
|
inline |
Set to 0 for yes if other output, -1 for never, or 1 for yes.
Definition at line 140 of file manager.hpp.
void tim::manager::synchronize | ( | ) |
Synchronizes thread-data for storage.
|
inlinestatic |
Get the number of instances that are currently allocated. This is decremented during the destructor of each manager instance, unlike tim::manager::get_thread_count()
Definition at line 174 of file manager.hpp.
void tim::manager::update_metadata_prefix | ( | ) |
Updates settings, rank, output prefix, etc.
|
inlinestatic |
Updates the settings instance use by the manager instance.
Definition at line 401 of file manager.hpp.
References tim::_settings.
|
inlinestatic |
Enable setting std::exit callback.
Definition at line 176 of file manager.hpp.
void tim::manager::write_metadata | ( | const std::string & | , |
const char * | = "" |
||
) |
Print metadata to filename.
std::ostream & tim::manager::write_metadata | ( | std::ostream & | ) |
Write metadata to ostream.
|
friend |
Definition at line 301 of file manager.hpp.
|
friend |
Definition at line 298 of file manager.hpp.