timemory
3.2.1
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 61 of file library.cpp.
using components_stack_t = std::deque<component_enum_t> |
Definition at line 62 of file library.cpp.
Definition at line 57 of file library.cpp.
using record_map_t = std::unordered_map<uint64_t, toolset_t> |
Definition at line 60 of file library.cpp.
using region_map_t = std::unordered_map<std::string, std::stack<uint64_t> > |
Definition at line 59 of file library.cpp.
using string_t = std::string |
Definition at line 56 of file library.cpp.
Definition at line 58 of file library.cpp.
|
inline |
Definition at line 112 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 126 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_init(), 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 347 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 408 of file library.cpp.
References tim::enabled, get_current_components(), timemory_create_record(), and tim::verbose.
Referenced by timemory_begin_record_().
void timemory_begin_record_ | ( | const char * | name, |
uint64_t * | id | ||
) |
Definition at line 637 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 449 of file library.cpp.
References tim::enabled, 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 428 of file library.cpp.
References tim::enabled, tim::enumerate_components(), 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 642 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 155 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 611 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 176 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 616 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 556 of file library.cpp.
References 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 252 of file library.cpp.
References tim::_settings, get_library_state(), tim::settings::instance(), and tim::manager::master_instance().
Referenced by c_timemory_finalize(), and timemory_finalize_library_().
void timemory_finalize_library_ | ( | void | ) |
Definition at line 623 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 481 of file library.cpp.
References tim::enabled, get_current_components(), timemory_create_record(), and tim::verbose.
Referenced by timemory_get_begin_record_().
uint64_t timemory_get_begin_record_ | ( | const char * | name | ) |
Definition at line 647 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 523 of file library.cpp.
References tim::enabled, 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 502 of file library.cpp.
References tim::enabled, tim::enumerate_components(), 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 652 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 143 of file library.cpp.
void timemory_init_library | ( | int | argc, |
char ** | argv | ||
) |
Initializes timemory. Not strictly necessary but highly recommended.
Definition at line 211 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 618 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 194 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 398 of file library.cpp.
Referenced by timemory_pop_components_().
void timemory_pop_components_ | ( | void | ) |
Definition at line 635 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 586 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 367 of file library.cpp.
Referenced by timemory_push_components_().
void timemory_push_components_ | ( | const char * | components | ) |
Definition at line 630 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 376 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 572 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 357 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 321 of file library.cpp.
References get_default_components().
Referenced by timemory_set_default_().
void timemory_set_default_ | ( | const char * | components | ) |
Definition at line 625 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 334 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 50 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 51 of file library.cpp.
Referenced by timemory_delete_record().