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::component::user_bundle< Idx, Tag > Struct Template Reference

#include "timemory/components/user_bundle/components.hpp"

+ Collaboration diagram for tim::component::user_bundle< Idx, Tag >:

Public Types

using tag_type = Tag
 
using mutex_t = std::mutex
 
using start_func_t = std::function< void *(const std::string &, scope::config)>
 
using stop_func_t = std::function< void(void *)>
 
using get_func_t = std::function< void(void *, void *&, size_t)>
 
using delete_func_t = std::function< void(void *)>
 
using opaque_array_t = std::vector< opaque >
 
using typeid_vec_t = std::vector< size_t >
 
using typeid_set_t = std::set< size_t >
 
using value_type = void
 
using this_type = user_bundle< Idx, Tag >
 
using base_type = base< this_type, value_type >
 
using storage_type = typename base_type::storage_type
 

Public Member Functions

 user_bundle ()
 
 user_bundle (const char *_prefix, scope::config _scope=scope::get_default())
 
 user_bundle (const char *_prefix, opaque_array_t _bundle_vec, typeid_vec_t _typeids, scope::config _scope=scope::get_default())
 
 user_bundle (const char *_prefix, opaque_array_t _bundle_vec, typeid_set_t _typeids, scope::config _scope=scope::get_default())
 
 ~user_bundle ()=default
 
 user_bundle (const user_bundle &)=default
 
 user_bundle (user_bundle &&rhs) noexcept=default
 
user_bundleoperator= (const user_bundle &rhs)=default
 
user_bundleoperator= (user_bundle &&rhs) noexcept=default
 
void clear ()
 
template<typename T >
T * get ()
 
void get () const
 
void get (void *&ptr, size_t _typeid_hash) const
 
template<typename Type , typename... Types, typename... Args>
void insert (Args... args)
 

Static Public Member Functions

static size_t bundle_size ()
 
static void global_init (bool _preinit=false)
 
static void global_init (storage_type *)
 
static void configure (opaque &&obj, std::set< size_t > &&_typeids)
 
template<typename Type , typename... Types, typename... Args>
static void configure (Args &&... args)
 
static void reset ()
 
static opaque_array_tget_data ()
 template instantiation-specific static opaque array More...
 
static typeid_vec_tget_typeids ()
 template instantiation-specific static set of type identifiers More...
 
static mutex_tget_lock ()
 template instantiation-specific static mutex More...
 
template<typename... Args>
static opaque get_opaque (Args &&...)
 

Static Public Attributes

static constexpr auto index = Idx
 

Friends

struct operation::record< this_type >
 
struct operation::start< this_type >
 
struct operation::stop< this_type >
 
struct operation::set_started< this_type >
 
struct operation::set_stopped< this_type >
 

Detailed Description

template<size_t Idx, typename Tag>
struct tim::component::user_bundle< Idx, Tag >

Definition at line 191 of file components.hpp.

Member Typedef Documentation

◆ base_type

template<size_t Idx, typename Tag >
using tim::component::user_bundle< Idx, Tag >::base_type = base<this_type, value_type>

Definition at line 210 of file components.hpp.

◆ delete_func_t

template<size_t Idx, typename Tag >
using tim::component::user_bundle< Idx, Tag >::delete_func_t = std::function<void(void*)>

Definition at line 203 of file components.hpp.

◆ get_func_t

template<size_t Idx, typename Tag >
using tim::component::user_bundle< Idx, Tag >::get_func_t = std::function<void(void*, void*&, size_t)>

Definition at line 202 of file components.hpp.

◆ mutex_t

template<size_t Idx, typename Tag >
using tim::component::user_bundle< Idx, Tag >::mutex_t = std::mutex

Definition at line 199 of file components.hpp.

◆ opaque_array_t

template<size_t Idx, typename Tag >
using tim::component::user_bundle< Idx, Tag >::opaque_array_t = std::vector<opaque>

Definition at line 204 of file components.hpp.

◆ start_func_t

template<size_t Idx, typename Tag >
using tim::component::user_bundle< Idx, Tag >::start_func_t = std::function<void*(const std::string&, scope::config)>

Definition at line 200 of file components.hpp.

◆ stop_func_t

template<size_t Idx, typename Tag >
using tim::component::user_bundle< Idx, Tag >::stop_func_t = std::function<void(void*)>

Definition at line 201 of file components.hpp.

◆ storage_type

template<size_t Idx, typename Tag >
using tim::component::user_bundle< Idx, Tag >::storage_type = typename base_type::storage_type

Definition at line 211 of file components.hpp.

◆ tag_type

template<size_t Idx, typename Tag >
using tim::component::user_bundle< Idx, Tag >::tag_type = Tag

Definition at line 198 of file components.hpp.

◆ this_type

template<size_t Idx, typename Tag >
using tim::component::user_bundle< Idx, Tag >::this_type = user_bundle<Idx, Tag>

Definition at line 209 of file components.hpp.

◆ typeid_set_t

template<size_t Idx, typename Tag >
using tim::component::user_bundle< Idx, Tag >::typeid_set_t = std::set<size_t>

Definition at line 206 of file components.hpp.

◆ typeid_vec_t

template<size_t Idx, typename Tag >
using tim::component::user_bundle< Idx, Tag >::typeid_vec_t = std::vector<size_t>

Definition at line 205 of file components.hpp.

◆ value_type

template<size_t Idx, typename Tag >
using tim::component::user_bundle< Idx, Tag >::value_type = void

Definition at line 208 of file components.hpp.

Constructor & Destructor Documentation

◆ user_bundle() [1/6]

template<size_t Idx, typename Tag >
tim::component::user_bundle< Idx, Tag >::user_bundle ( )
inline

Definition at line 239 of file components.hpp.

240 : internal::user_bundle{ scope::get_default(), get_typeids(),
241 (persistent_init(), get_data()) }
242 {}
static typeid_vec_t & get_typeids()
template instantiation-specific static set of type identifiers
Definition: components.hpp:414
static opaque_array_t & get_data()
template instantiation-specific static opaque array
Definition: components.hpp:411

◆ user_bundle() [2/6]

template<size_t Idx, typename Tag >
tim::component::user_bundle< Idx, Tag >::user_bundle ( const char *  _prefix,
scope::config  _scope = scope::get_default() 
)
inlineexplicit

Definition at line 244 of file components.hpp.

245 : internal::user_bundle{ _scope, get_typeids(), (persistent_init(), get_data()),
246 _prefix }
247 {}
char const std::string & _prefix
Definition: config.cpp:55

◆ user_bundle() [3/6]

template<size_t Idx, typename Tag >
tim::component::user_bundle< Idx, Tag >::user_bundle ( const char *  _prefix,
opaque_array_t  _bundle_vec,
typeid_vec_t  _typeids,
scope::config  _scope = scope::get_default() 
)
inline

Definition at line 249 of file components.hpp.

251 : internal::user_bundle{ _scope, std::move(_typeids), std::move(_bundle_vec),
252 _prefix }
253 {}

◆ user_bundle() [4/6]

template<size_t Idx, typename Tag >
tim::component::user_bundle< Idx, Tag >::user_bundle ( const char *  _prefix,
opaque_array_t  _bundle_vec,
typeid_set_t  _typeids,
scope::config  _scope = scope::get_default() 
)
inline

Definition at line 255 of file components.hpp.

257 : internal::user_bundle{ _scope, typeid_vec_t{}, std::move(_bundle_vec), _prefix }
258 {
259 m_typeids.reserve(_typeids.size());
260 for(const auto& itr : _typeids)
261 m_typeids.emplace_back(itr);
262 }
std::vector< size_t > typeid_vec_t
Definition: components.hpp:205

◆ ~user_bundle()

template<size_t Idx, typename Tag >
tim::component::user_bundle< Idx, Tag >::~user_bundle ( )
default

◆ user_bundle() [5/6]

template<size_t Idx, typename Tag >
tim::component::user_bundle< Idx, Tag >::user_bundle ( const user_bundle< Idx, Tag > &  )
default

◆ user_bundle() [6/6]

template<size_t Idx, typename Tag >
tim::component::user_bundle< Idx, Tag >::user_bundle ( user_bundle< Idx, Tag > &&  rhs)
defaultnoexcept

Member Function Documentation

◆ bundle_size()

template<size_t Idx, typename Tag >
static size_t tim::component::user_bundle< Idx, Tag >::bundle_size ( )
inlinestatic

Definition at line 219 of file components.hpp.

219{ return get_data().size(); }

References tim::component::user_bundle< Idx, Tag >::get_data().

◆ clear()

template<size_t Idx, typename Tag >
void tim::component::user_bundle< Idx, Tag >::clear ( )
inline

Definition at line 336 of file components.hpp.

337 {
339 stop();
340 m_typeids.clear();
341 m_bundle.clear();
342 m_setup = false;
343 }
void stop(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:386
bool get_is_running() const
Definition: data.hpp:455

References tim::component::base< Tp, Value >::get_is_running(), and tim::invoke::stop().

◆ configure() [1/2]

template<size_t Idx, typename Tag >
template<typename Type , typename... Types, typename... Args>
static void tim::component::user_bundle< Idx, Tag >::configure ( Args &&...  args)
inlinestatic

Definition at line 281 of file components.hpp.

282 {
283 this_type::configure(factory::get_opaque<Type>(std::forward<Args>(args)...),
284 factory::get_typeids<Type>());
285
287 this_type::configure(factory::get_opaque<Types>(std::forward<Args>(args)...),
288 factory::get_typeids<Types>()));
289 }
static void configure(opaque &&obj, std::set< size_t > &&_typeids)
Definition: components.hpp:273
#define TIMEMORY_FOLD_EXPRESSION(...)
Definition: types.hpp:56

References tim::component::user_bundle< Idx, Tag >::configure(), and TIMEMORY_FOLD_EXPRESSION.

◆ configure() [2/2]

template<size_t Idx, typename Tag >
static void tim::component::user_bundle< Idx, Tag >::configure ( opaque &&  obj,
std::set< size_t > &&  _typeids 
)
inlinestatic

Definition at line 273 of file components.hpp.

274 {
275 internal::user_bundle::configure(get_data(), get_typeids(), get_lock(),
276 std::forward<opaque>(obj),
277 std::forward<std::set<size_t>>(_typeids));
278 }
static mutex_t & get_lock()
template instantiation-specific static mutex
Definition: components.hpp:417

Referenced by tim::component::user_bundle< Idx, Tag >::configure().

◆ get() [1/3]

template<size_t Idx, typename Tag >
template<typename T >
T * tim::component::user_bundle< Idx, Tag >::get ( )
inline

Definition at line 346 of file components.hpp.

347 {
348 auto _typeid_hash = typeid_hash<T>();
349 void* void_ptr = nullptr;
350 for(auto& itr : m_bundle)
351 {
352 itr.get(void_ptr, _typeid_hash);
353 if(void_ptr)
354 return static_cast<T*>(void_ptr);
355 }
356 return static_cast<T*>(void_ptr);
357 }

◆ get() [2/3]

template<size_t Idx, typename Tag >
void tim::component::user_bundle< Idx, Tag >::get ( ) const
inline

Definition at line 359 of file components.hpp.

359{}

◆ get() [3/3]

template<size_t Idx, typename Tag >
void tim::component::user_bundle< Idx, Tag >::get ( void *&  ptr,
size_t  _typeid_hash 
) const
inline

Definition at line 361 of file components.hpp.

362 {
363 base_type::get(ptr, _typeid_hash);
364 internal::user_bundle::get(ptr, _typeid_hash);
365 }
auto get(const auto_bundle< Tag, Types... > &_obj)
auto get() const
retrieve the current measurement value in the units for the type

References tim::component::base< Tp, Value >::get(), and tim::get().

◆ get_data()

template<size_t Idx, typename Tag >
static opaque_array_t & tim::component::user_bundle< Idx, Tag >::get_data ( )
inlinestatic

template instantiation-specific static opaque array

Definition at line 411 of file components.hpp.

411{ return get_persistent_data().m_data; }

Referenced by tim::component::user_bundle< Idx, Tag >::bundle_size(), and tim::component::user_bundle< Idx, Tag >::reset().

◆ get_lock()

template<size_t Idx, typename Tag >
static mutex_t & tim::component::user_bundle< Idx, Tag >::get_lock ( )
inlinestatic

template instantiation-specific static mutex

Definition at line 417 of file components.hpp.

417{ return get_persistent_data().m_lock; }

Referenced by tim::component::user_bundle< Idx, Tag >::reset().

◆ get_opaque()

template<typename... Args>
static opaque tim::component::empty_base::get_opaque ( Args &&  ...)
inlinestaticinherited

Definition at line 72 of file declaration.hpp.

73 {
74 return opaque{};
75 }

◆ get_typeids()

template<size_t Idx, typename Tag >
static typeid_vec_t & tim::component::user_bundle< Idx, Tag >::get_typeids ( )
inlinestatic

template instantiation-specific static set of type identifiers

Definition at line 414 of file components.hpp.

414{ return get_persistent_data().m_typeids; }

Referenced by tim::component::user_bundle< Idx, Tag >::reset().

◆ global_init() [1/2]

template<size_t Idx, typename Tag >
void tim::component::user_bundle< Idx, Tag >::global_init ( bool  _preinit = false)
static

Definition at line 424 of file components.hpp.

425{
427 PRINT_HERE("Global initialization of %s", demangle<this_type>().c_str());
428 get_persistent_data().init(_preinit);
429}
#define PRINT_HERE(...)
Definition: macros.hpp:152

References tim::debug, PRINT_HERE, and tim::verbose.

◆ global_init() [2/2]

template<size_t Idx, typename Tag >
static void tim::component::user_bundle< Idx, Tag >::global_init ( storage_type )
inlinestatic

Definition at line 221 of file components.hpp.

221{ global_init(false); }
static void global_init(bool _preinit=false)
Definition: components.hpp:424

References tim::component::user_bundle< Idx, Tag >::global_init().

Referenced by tim::component::user_bundle< Idx, Tag >::global_init().

◆ insert()

template<size_t Idx, typename Tag >
template<typename Type , typename... Types, typename... Args>
void tim::component::user_bundle< Idx, Tag >::insert ( Args...  args)
inline

Definition at line 369 of file components.hpp.

370 {
371 this->insert(factory::get_opaque<Type>(args...), factory::get_typeids<Type>());
372 TIMEMORY_FOLD_EXPRESSION(this->insert(factory::get_opaque<Types>(args...),
373 factory::get_typeids<Types>()));
374 }
void insert(Args... args)
Definition: components.hpp:369

References tim::component::user_bundle< Idx, Tag >::insert(), and TIMEMORY_FOLD_EXPRESSION.

Referenced by tim::component::user_bundle< Idx, Tag >::insert().

◆ operator=() [1/2]

template<size_t Idx, typename Tag >
user_bundle & tim::component::user_bundle< Idx, Tag >::operator= ( const user_bundle< Idx, Tag > &  rhs)
default

◆ operator=() [2/2]

template<size_t Idx, typename Tag >
user_bundle & tim::component::user_bundle< Idx, Tag >::operator= ( user_bundle< Idx, Tag > &&  rhs)
defaultnoexcept

◆ reset()

template<size_t Idx, typename Tag >
static void tim::component::user_bundle< Idx, Tag >::reset ( )
inlinestatic

Definition at line 292 of file components.hpp.

293 {
295 "Resetting %s", demangle<this_type>().c_str());
297 }
void reset(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:599
#define CONDITIONAL_PRINT_HERE(CONDITION,...)
Definition: macros.hpp:183

References CONDITIONAL_PRINT_HERE, tim::debug, tim::component::user_bundle< Idx, Tag >::get_data(), tim::component::user_bundle< Idx, Tag >::get_lock(), tim::component::user_bundle< Idx, Tag >::get_typeids(), tim::invoke::reset(), and tim::verbose.

Friends And Related Function Documentation

◆ operation::record< this_type >

template<size_t Idx, typename Tag >
friend struct operation::record< this_type >
friend

Definition at line 197 of file components.hpp.

◆ operation::set_started< this_type >

template<size_t Idx, typename Tag >
friend struct operation::set_started< this_type >
friend

Definition at line 197 of file components.hpp.

◆ operation::set_stopped< this_type >

template<size_t Idx, typename Tag >
friend struct operation::set_stopped< this_type >
friend

Definition at line 197 of file components.hpp.

◆ operation::start< this_type >

template<size_t Idx, typename Tag >
friend struct operation::start< this_type >
friend

Definition at line 197 of file components.hpp.

◆ operation::stop< this_type >

template<size_t Idx, typename Tag >
friend struct operation::stop< this_type >
friend

Definition at line 197 of file components.hpp.

Member Data Documentation

◆ index

template<size_t Idx, typename Tag >
constexpr auto tim::component::user_bundle< Idx, Tag >::index = Idx
staticconstexpr

Definition at line 197 of file components.hpp.


The documentation for this struct was generated from the following file: