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.
tim::env Namespace Reference

Typedefs

using user_bundle_spec_t = std::function< std::string()>
 
using user_bundle_variables_t = std::unordered_map< size_t, std::vector< user_bundle_spec_t > >
 

Functions

user_bundle_variables_tget_user_bundle_variables (TIMEMORY_API)
 static so that projects cannot globally change this More...
 
user_bundle_variables_tget_user_bundle_variables (project::kokkosp)
 
std::vector< TIMEMORY_COMPONENTget_bundle_components (const std::vector< user_bundle_spec_t > &_priority)
 
template<typename ApiT >
user_bundle_variables_tget_user_bundle_variables (ApiT)
 non-static so that projects can globally change this for their project/API More...
 
template<size_t Idx, typename Api , typename AltApi = Api>
void initialize_bundle (AltApi _api=AltApi{})
 
template<template< typename... > class CompList, typename... CompTypes, typename std::enable_if< sizeof...(CompTypes) !=0, int >::type = 0>
void initialize (CompList< CompTypes... > &obj, const std::string &env_var, const std::string &default_env)
 
template<typename T , typename... Args>
void initialize (T *obj, Args &&... args)
 
template<size_t Idx, typename Type , template< size_t, typename > class Bundle>
void insert (Bundle< Idx, Type > &obj, const std::string &env_var, const std::string &default_env)
 
template<typename T , typename... Args>
void insert (T *obj, Args &&... args)
 
template<typename Bundle , typename... Args>
void configure (const std::string &env_var, const std::string &default_env, Args &&... args)
 

Typedef Documentation

◆ user_bundle_spec_t

using tim::env::user_bundle_spec_t = typedef std::function<std::string()>

Definition at line 63 of file components.hpp.

◆ user_bundle_variables_t

using tim::env::user_bundle_variables_t = typedef std::unordered_map<size_t, std::vector<user_bundle_spec_t> >

Definition at line 65 of file components.hpp.

Function Documentation

◆ configure()

template<typename Bundle , typename... Args>
void tim::env::configure ( const std::string &  env_var,
const std::string &  default_env,
Args &&...  args 
)

Definition at line 301 of file types.hpp.

302{
303 auto env_result = tim::get_env(env_var, default_env);
304 tim::configure<Bundle>(enumerate_components(tim::delimit(env_result)),
305 std::forward<Args>(args)...);
306}
std::vector< TIMEMORY_COMPONENT > enumerate_components(const Container< StringT, ExtraArgs... > &component_names)
description: use this function to generate an array of enumerations from a list of string that can be...
Definition: enumerate.hpp:62
Tp get_env(const std::string &env_id, Tp _default, bool _store)
ContainerT delimit(const std::string &line, const std::string &delimiters="\"',;: ", PredicateT &&predicate=[](const std::string &s) -> std::string { return s;})
Definition: delimit.hpp:68

References tim::delimit(), tim::enumerate_components(), and tim::get_env().

◆ get_bundle_components()

std::vector< TIMEMORY_COMPONENT > tim::env::get_bundle_components ( const std::vector< user_bundle_spec_t > &  _priority)

Definition at line 99 of file components.cpp.

100{
101 std::string _custom{};
102 bool _fallthrough = false;
103 auto _replace = [&_fallthrough](const std::string& _key) {
104 const std::string _ft = "fallthrough";
105 auto _pos = _key.find(_ft);
106 if(_pos != std::string::npos)
107 {
108 _fallthrough = true;
109 return _key.substr(0, _pos) + _key.substr(_pos + _ft.length() + 1);
110 }
111 return _key;
112 };
113
114 for(const auto& itr : _priority)
115 {
116 auto _spec = itr();
117 if(_spec.length() > 0)
118 {
119 if(_spec != "none" && _spec != "NONE")
120 _custom += _replace(_spec);
121 else
122 _fallthrough = false;
123 if(!_fallthrough)
124 break;
125 }
126 }
127
128 auto _debug = (settings::instance()) ? (settings::instance()->get_debug()) : false;
129 CONDITIONAL_PRINT_HERE(_debug, "getting user bundle components: %s", _custom.c_str());
130
132}
tim::mpl::apply< std::string > string
Definition: macros.hpp:53
#define CONDITIONAL_PRINT_HERE(CONDITION,...)
Definition: macros.hpp:183

References CONDITIONAL_PRINT_HERE, tim::delimit(), tim::enumerate_components(), and tim::settings::instance().

◆ get_user_bundle_variables() [1/3]

template<typename ApiT >
user_bundle_variables_t & tim::env::get_user_bundle_variables ( ApiT  )
inline

non-static so that projects can globally change this for their project/API

Definition at line 71 of file components.hpp.

72{
73 static user_bundle_variables_t _instance{};
74 return _instance;
75}
std::unordered_map< size_t, std::vector< user_bundle_spec_t > > user_bundle_variables_t
Definition: components.hpp:66

◆ get_user_bundle_variables() [2/3]

user_bundle_variables_t & tim::env::get_user_bundle_variables ( project::kokkosp  )

Definition at line 81 of file components.cpp.

82{
83 static user_bundle_variables_t _instance = {
84 { component::kokkosp_bundle_idx,
85 { []() { return settings::kokkos_components(); },
86 []() { return get_env<std::string>("TIMEMORY_KOKKOSP_COMPONENTS", ""); },
87 []() { return get_env<std::string>("KOKKOS_TIMEMORY_COMPONENTS", ""); },
88 []() { return settings::trace_components(); },
89 []() { return settings::profiler_components(); },
90 []() { return settings::components(); },
91 []() { return settings::global_components(); } } }
92 };
93 return _instance;
94}
profiler_components
Definition: settings.cpp:1696
trace_components
Definition: settings.cpp:1694
global_components
Definition: settings.cpp:1682
components
Definition: settings.cpp:1700
kokkos_components
Definition: settings.cpp:1698

References tim::components, tim::global_components, tim::kokkos_components, tim::profiler_components, and tim::trace_components.

◆ get_user_bundle_variables() [3/3]

user_bundle_variables_t & tim::env::get_user_bundle_variables ( TIMEMORY_API  )

static so that projects cannot globally change this

Definition at line 43 of file components.cpp.

44{
45 static user_bundle_variables_t _instance = {
46 { component::global_bundle_idx,
47 { []() { return settings::global_components(); } } },
48 { component::ompt_bundle_idx,
49 { []() { return settings::ompt_components(); },
50 []() { return settings::trace_components(); },
51 []() { return settings::profiler_components(); },
52 []() { return settings::components(); },
53 []() { return settings::global_components(); } } },
54 { component::mpip_bundle_idx,
55 { []() { return settings::mpip_components(); },
56 []() { return settings::trace_components(); },
57 []() { return settings::profiler_components(); },
58 []() { return settings::components(); },
59 []() { return settings::global_components(); } } },
60 { component::ncclp_bundle_idx,
61 { []() { return settings::ncclp_components(); },
62 []() { return settings::mpip_components(); },
63 []() { return settings::trace_components(); },
64 []() { return settings::profiler_components(); },
65 []() { return settings::components(); },
66 []() { return settings::global_components(); } } },
67 { component::trace_bundle_idx,
68 { []() { return settings::trace_components(); },
69 []() { return settings::components(); },
70 []() { return settings::global_components(); } } },
71 { component::profiler_bundle_idx,
72 { []() { return settings::profiler_components(); },
73 []() { return settings::components(); },
74 []() { return settings::global_components(); } } },
75 };
76 return _instance;
77}
mpip_components
Definition: settings.cpp:1690
ompt_components
Definition: settings.cpp:1688
ncclp_components
Definition: settings.cpp:1692

References tim::components, tim::global_components, tim::mpip_components, tim::ncclp_components, tim::ompt_components, tim::profiler_components, and tim::trace_components.

◆ initialize() [1/2]

template<template< typename... > class CompList, typename... CompTypes, typename std::enable_if< sizeof...(CompTypes) !=0, int >::type = 0>
void tim::env::initialize ( CompList< CompTypes... > &  obj,
const std::string &  env_var,
const std::string &  default_env 
)

Definition at line 252 of file types.hpp.

254{
255 auto env_result = tim::get_env(env_var, default_env);
257}
void initialize(CompList< CompTypes... > &obj, std::initializer_list< EnumT > components)
Definition: initialize.hpp:53

References tim::delimit(), tim::enumerate_components(), tim::get_env(), and tim::initialize().

Referenced by initialize().

◆ initialize() [2/2]

template<typename T , typename... Args>
void tim::env::initialize ( T *  obj,
Args &&...  args 
)

Definition at line 271 of file types.hpp.

272{
273 if(obj)
274 initialize(*obj, std::forward<Args>(args)...);
275}
void initialize(T *obj, Args &&... args)
Definition: types.hpp:271

References initialize().

◆ initialize_bundle()

template<size_t Idx, typename Api , typename AltApi = Api>
void tim::env::initialize_bundle ( AltApi  _api = AltApi{})

Definition at line 97 of file components.hpp.

97 {})
98{
99 using user_bundle_type = component::user_bundle<Idx, Api>;
100 auto& variables = env::get_user_bundle_variables(_api);
101 auto itr = variables.find(Idx);
102 if(itr != variables.end())
103 {
105 (settings::instance()) ? (settings::instance()->get_debug()) : false,
106 "getting user bundle components for type %s (%s)",
107 demangle<user_bundle_type>().c_str(), user_bundle_type::label().c_str());
108
109 auto _enum = env::get_bundle_components(itr->second);
110 tim::configure<user_bundle_type>(_enum);
111 }
112}
std::vector< TIMEMORY_COMPONENT > get_bundle_components(const std::vector< user_bundle_spec_t > &_priority)
Definition: components.cpp:99
user_bundle_variables_t & get_user_bundle_variables(ApiT)
non-static so that projects can globally change this for their project/API
Definition: components.hpp:71

◆ insert() [1/2]

template<size_t Idx, typename Type , template< size_t, typename > class Bundle>
void tim::env::insert ( Bundle< Idx, Type > &  obj,
const std::string &  env_var,
const std::string &  default_env 
)

Definition at line 281 of file types.hpp.

282{
283 auto env_result = tim::get_env(env_var, default_env);
285}
_reported insert(_hash_id)

References tim::delimit(), tim::enumerate_components(), and tim::get_env().

Referenced by insert().

◆ insert() [2/2]

template<typename T , typename... Args>
void tim::env::insert ( T *  obj,
Args &&...  args 
)

Definition at line 291 of file types.hpp.

292{
293 if(obj)
294 insert(*obj, std::forward<Args>(args)...);
295}
void insert(T *obj, Args &&... args)
Definition: types.hpp:291

References insert().