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/compat/library.h"
#include "timemory/config.hpp"
#include "timemory/library.h"
#include "timemory/runtime/configure.hpp"
#include "timemory/timemory.hpp"
#include "timemory/trace.hpp"
#include <cstdarg>
#include <deque>
#include <iostream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
Go to the source code of this file.
Macros | |
#define | TIMEMORY_LIBRARY_SOURCE 1 |
Typedefs | |
using | string_t = std::string |
using | library_toolset_t = TIMEMORY_LIBRARY_TYPE |
using | toolset_t = typename library_toolset_t::component_type |
using | region_map_t = std::unordered_map< std::string, std::stack< uint64_t > > |
using | record_map_t = std::unordered_map< uint64_t, toolset_t > |
using | component_enum_t = std::vector< TIMEMORY_COMPONENT > |
using | components_stack_t = std::deque< component_enum_t > |
Functions | |
std::string & | get_default_components () |
component_enum_t & | get_current_components () |
std::array< bool, 2 > & | get_library_state () |
uint64_t | timemory_get_unique_id (void) |
Returns a unique integer for a thread. More... | |
void | timemory_create_record (const char *name, uint64_t *id, int n, int *ctypes) |
void | timemory_delete_record (uint64_t id) |
Deletes the record created by timemory_create_record. More... | |
bool | timemory_library_is_initialized (void) |
Returns whether the library is initialized or not. More... | |
void | timemory_named_init_library (char *name) |
void | timemory_init_library (int argc, char **argv) |
Initializes timemory. Not strictly necessary but highly recommended. More... | |
void | timemory_finalize_library (void) |
Finalizes timemory. Output will be generated. Any attempt to store data within timemory storage is undefined after this point and will likely cause errors. More... | |
void | timemory_pause (void) |
Turn off timemory collection. More... | |
void | timemory_resume (void) |
Turn on timemory collection. More... | |
void | timemory_set_default (const char *_component_string) |
Pass in a default set of components to use. Will be overridden by TIMEMORY_COMPONENTS environment variable. More... | |
void | timemory_set_environ (const char *evar, const char *eval, int over, int parse) |
void | timemory_add_components (const char *_component_string) |
Add some components to the current set of components being collected Any components which are currently being collected are ignored. More... | |
void | timemory_remove_components (const char *_component_string) |
Remove some components to the current set of components being collected. Any components which are not currently being collected are ignored. More... | |
void | timemory_push_components (const char *_component_string) |
Replace the current set of components with a new set of components. More... | |
void | timemory_push_components_enum (int types,...) |
Replace the current set of components with a new set of components with the set of enumerations provided to the function. First argument should be the number of new components. More... | |
void | timemory_pop_components (void) |
Inverse of the last timemory_push_components or timemory_push_components_enum call. Popping all components will restore to set the configured as the default. More... | |
void | timemory_begin_record (const char *name, uint64_t *id) |
void | timemory_begin_record_types (const char *name, uint64_t *id, const char *ctypes) |
Similar to timemory_begin_record but accepts a specific set of components as a string. More... | |
void | timemory_begin_record_enum (const char *name, uint64_t *id,...) |
Similar to timemory_begin_record but accepts a specific enumerated set of components, which is terminated by TIMEMORY_COMPONENTS_END. More... | |
uint64_t | timemory_get_begin_record (const char *name) |
Variant to timemory_begin_record which returns a unique integer. More... | |
uint64_t | timemory_get_begin_record_types (const char *name, const char *ctypes) |
Variant to timemory_begin_record_types which returns a unique integer. More... | |
uint64_t | timemory_get_begin_record_enum (const char *name,...) |
Variant to timemory_begin_record_enum which returns a unique integer. More... | |
void | timemory_end_record (uint64_t id) |
void | timemory_push_region (const char *name) |
void | timemory_pop_region (const char *name) |
void | timemory_create_record_ (const char *name, uint64_t *id, int n, int *ct) |
void | timemory_delete_record_ (uint64_t id) |
void | timemory_init_library_ (int argc, char **argv) |
void | timemory_finalize_library_ (void) |
void | timemory_set_default_ (const char *components) |
void | timemory_push_components_ (const char *components) |
void | timemory_pop_components_ (void) |
void | timemory_begin_record_ (const char *name, uint64_t *id) |
void | timemory_begin_record_types_ (const char *name, uint64_t *id, const char *ctypes) |
uint64_t | timemory_get_begin_record_ (const char *name) |
uint64_t | timemory_get_begin_record_types_ (const char *name, const char *ctypes) |
void | timemory_end_record_ (uint64_t id) |
void | timemory_push_region_ (const char *name) |
void | timemory_pop_region_ (const char *name) |
Variables | |
timemory_create_func_t | timemory_create_function = nullptr |
The function pointer to set to customize which components are used by library interface. More... | |
timemory_delete_func_t | timemory_delete_function = nullptr |
The function pointer to set which deletes an entry created by timemory_create_function. More... | |
#define TIMEMORY_LIBRARY_SOURCE 1 |
Definition at line 26 of file library.cpp.
using component_enum_t = std::vector<TIMEMORY_COMPONENT> |
Definition at line 62 of file library.cpp.
using components_stack_t = std::deque<component_enum_t> |
Definition at line 63 of file library.cpp.
Definition at line 58 of file library.cpp.
using record_map_t = std::unordered_map<uint64_t, toolset_t> |
Definition at line 61 of file library.cpp.
using region_map_t = std::unordered_map<std::string, std::stack<uint64_t> > |
Definition at line 60 of file library.cpp.
using string_t = std::string |
Definition at line 57 of file library.cpp.
Definition at line 59 of file library.cpp.
|
inline |
Definition at line 113 of file library.cpp.
Referenced by timemory_add_components(), timemory_begin_record(), timemory_get_begin_record(), and timemory_remove_components().
|
inline |
std::array< bool, 2 > & get_library_state | ( | ) |
Definition at line 127 of file library.cpp.
Referenced by timemory_finalize_library(), timemory_init_library(), timemory_library_is_initialized(), timemory_pop_trace(), timemory_pop_trace_hash(), timemory_push_trace(), timemory_push_trace_hash(), timemory_trace_is_initialized(), and timemory_trace_set_env().
void timemory_add_components | ( | const char * | components | ) |
Add some components to the current set of components being collected Any components which are currently being collected are ignored.
Definition at line 348 of file library.cpp.
References tim::enumerate_components(), and get_current_components().
void timemory_begin_record | ( | const char * | name, |
uint64_t * | id | ||
) |
[in] | name | Label for the record |
[in,out] | id | identifier passed back to timemory_end_record |
Definition at line 409 of file library.cpp.
References tim::enabled, get_current_components(), std::max(), timemory_create_record(), and tim::verbose.
Referenced by timemory_begin_record_().
void timemory_begin_record_ | ( | const char * | name, |
uint64_t * | id | ||
) |
Definition at line 638 of file library.cpp.
References timemory_begin_record().
void timemory_begin_record_enum | ( | const char * | name, |
uint64_t * | id, | ||
... | |||
) |
Similar to timemory_begin_record but accepts a specific enumerated set of components, which is terminated by TIMEMORY_COMPONENTS_END.
Definition at line 450 of file library.cpp.
References tim::enabled, std::max(), TIMEMORY_COMPONENTS_END, timemory_create_record(), and tim::verbose.
void timemory_begin_record_types | ( | const char * | name, |
uint64_t * | id, | ||
const char * | ctypes | ||
) |
Similar to timemory_begin_record but accepts a specific set of components as a string.
Definition at line 429 of file library.cpp.
References tim::enabled, tim::enumerate_components(), std::max(), timemory_create_record(), and tim::verbose.
Referenced by timemory_begin_record_types_().
void timemory_begin_record_types_ | ( | const char * | name, |
uint64_t * | id, | ||
const char * | ctypes | ||
) |
Definition at line 643 of file library.cpp.
References timemory_begin_record_types().
void timemory_create_record | ( | const char * | name, |
uint64_t * | id, | ||
int | n, | ||
int * | ct | ||
) |
[in] | name | label for the record |
[in,out] | id | assigned a unique identifier for the record |
[in] | n | number of components |
[in] | ct | array of enumeration identifiers of size n |
Function called by timemory_begin_record, timemory_begin_record_enum, timemory_begin_record_types, timemory_get_begin_record, timemory_get_begin_record_enum, timemory_get_begin_record_types, timemory_push_region for creating and starting the current collection of components.
Definition at line 156 of file library.cpp.
References timemory_create_function.
Referenced by timemory_begin_record(), timemory_begin_record_enum(), timemory_begin_record_types(), timemory_create_record_(), timemory_get_begin_record(), timemory_get_begin_record_enum(), and timemory_get_begin_record_types().
void timemory_create_record_ | ( | const char * | name, |
uint64_t * | id, | ||
int | n, | ||
int * | ct | ||
) |
Definition at line 612 of file library.cpp.
References timemory_create_record().
void timemory_delete_record | ( | uint64_t | id | ) |
Deletes the record created by timemory_create_record.
Definition at line 177 of file library.cpp.
References timemory_delete_function.
Referenced by timemory_delete_record_(), and timemory_end_record().
void timemory_delete_record_ | ( | uint64_t | id | ) |
Definition at line 617 of file library.cpp.
References timemory_delete_record().
void timemory_end_record | ( | uint64_t | id | ) |
[in] | id | Identifier for the recording entry |
Definition at line 557 of file library.cpp.
References std::max(), timemory_delete_record(), and tim::verbose.
Referenced by timemory_end_record_().
void timemory_end_record_ | ( | uint64_t | id | ) |
void timemory_finalize_library | ( | void | ) |
Finalizes timemory. Output will be generated. Any attempt to store data within timemory storage is undefined after this point and will likely cause errors.
Definition at line 253 of file library.cpp.
References get_library_state().
Referenced by c_timemory_finalize(), and timemory_finalize_library_().
void timemory_finalize_library_ | ( | void | ) |
Definition at line 624 of file library.cpp.
References timemory_finalize_library().
uint64_t timemory_get_begin_record | ( | const char * | name | ) |
Variant to timemory_begin_record which returns a unique integer.
Definition at line 482 of file library.cpp.
References tim::enabled, get_current_components(), std::max(), timemory_create_record(), and tim::verbose.
Referenced by timemory_get_begin_record_().
uint64_t timemory_get_begin_record_ | ( | const char * | name | ) |
Definition at line 648 of file library.cpp.
References timemory_get_begin_record().
uint64_t timemory_get_begin_record_enum | ( | const char * | name, |
... | |||
) |
Variant to timemory_begin_record_enum which returns a unique integer.
Definition at line 524 of file library.cpp.
References tim::enabled, std::max(), TIMEMORY_COMPONENTS_END, timemory_create_record(), and tim::verbose.
uint64_t timemory_get_begin_record_types | ( | const char * | name, |
const char * | ctypes | ||
) |
Variant to timemory_begin_record_types which returns a unique integer.
Definition at line 503 of file library.cpp.
References tim::enabled, tim::enumerate_components(), std::max(), timemory_create_record(), and tim::verbose.
Referenced by timemory_get_begin_record_types_().
uint64_t timemory_get_begin_record_types_ | ( | const char * | name, |
const char * | ctypes | ||
) |
Definition at line 653 of file library.cpp.
References timemory_get_begin_record_types().
uint64_t timemory_get_unique_id | ( | void | ) |
Returns a unique integer for a thread.
Definition at line 144 of file library.cpp.
void timemory_init_library | ( | int | argc, |
char ** | argv | ||
) |
Initializes timemory. Not strictly necessary but highly recommended.
Definition at line 212 of file library.cpp.
References tim::argv, get_library_state(), and tim::verbose.
Referenced by c_timemory_init(), timemory_init_library_(), timemory_named_init_library(), and timemory_trace_init().
void timemory_init_library_ | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 619 of file library.cpp.
References tim::argv, and timemory_init_library().
bool timemory_library_is_initialized | ( | void | ) |
Returns whether the library is initialized or not.
Definition at line 195 of file library.cpp.
References get_library_state().
void timemory_named_init_library | ( | char * | name | ) |
void timemory_pause | ( | void | ) |
void timemory_pop_components | ( | void | ) |
Inverse of the last timemory_push_components or timemory_push_components_enum call. Popping all components will restore to set the configured as the default.
Definition at line 399 of file library.cpp.
Referenced by timemory_pop_components_().
void timemory_pop_components_ | ( | void | ) |
Definition at line 636 of file library.cpp.
References timemory_pop_components().
void timemory_pop_region | ( | const char * | name | ) |
[in] | name | label for region |
Stops collection of components with label.
Definition at line 587 of file library.cpp.
Referenced by timemory_pop_region_().
void timemory_pop_region_ | ( | const char * | name | ) |
void timemory_push_components | ( | const char * | components | ) |
Replace the current set of components with a new set of components.
Definition at line 368 of file library.cpp.
Referenced by timemory_push_components_().
void timemory_push_components_ | ( | const char * | components | ) |
Definition at line 631 of file library.cpp.
References tim::components, and timemory_push_components().
void timemory_push_components_enum | ( | int | args, |
... | |||
) |
Replace the current set of components with a new set of components with the set of enumerations provided to the function. First argument should be the number of new components.
Definition at line 377 of file library.cpp.
void timemory_push_region | ( | const char * | name | ) |
[in] | name | label for region |
Starts collection of components with label.
Definition at line 573 of file library.cpp.
Referenced by timemory_push_region_().
void timemory_push_region_ | ( | const char * | name | ) |
void timemory_remove_components | ( | const char * | components | ) |
Remove some components to the current set of components being collected. Any components which are not currently being collected are ignored.
Definition at line 358 of file library.cpp.
References tim::enumerate_components(), and get_current_components().
void timemory_resume | ( | void | ) |
void timemory_set_default | ( | const char * | components | ) |
Pass in a default set of components to use. Will be overridden by TIMEMORY_COMPONENTS environment variable.
Definition at line 322 of file library.cpp.
References get_default_components().
Referenced by timemory_set_default_().
void timemory_set_default_ | ( | const char * | components | ) |
Definition at line 626 of file library.cpp.
References tim::components, and timemory_set_default().
void timemory_set_environ | ( | const char * | evar, |
const char * | eval, | ||
int | ovr, | ||
int | up | ||
) |
[in] | evar | Environment variable name |
[in] | eval | Environment variable value |
[in] | ovr | Overwrite existing environment variable when > 0 |
[in] | up | Update settings when > 0 |
Set an environment variable and (potentially) update settings with new value.
Definition at line 335 of file library.cpp.
References tim::settings::parse(), and tim::set_env().
timemory_create_func_t timemory_create_function = nullptr |
The function pointer to set to customize which components are used by library interface.
Definition at line 51 of file library.cpp.
Referenced by timemory_create_record().
timemory_delete_func_t timemory_delete_function = nullptr |
The function pointer to set which deletes an entry created by timemory_create_function.
Definition at line 52 of file library.cpp.
Referenced by timemory_delete_record().