33 #include "timemory/components/user_bundle/backends.hpp"
47 #include <unordered_map>
64 std::unordered_map<size_t, std::vector<user_bundle_spec_t>>;
68 template <
typename ApiT>
75 #if defined(TIMEMORY_USER_BUNDLE_HEADER_MODE)
80 inline std::vector<TIMEMORY_COMPONENT>
87 std::vector<TIMEMORY_COMPONENT>
93 template <
size_t Idx,
typename Api,
typename AltApi = Api>
99 auto itr = variables.find(Idx);
100 if(itr != variables.end())
103 tim::configure<user_bundle_type>(_enum);
120 template <
size_t Idx,
typename Tag>
122 :
public base<user_bundle<Idx, Tag>, void>
129 using lock_t = std::unique_lock<mutex_t>;
145 using get_func_t = std::function<void(
void*,
void*&,
size_t)>;
151 return "Generic bundle of components designed for runtime configuration by a "
152 "user via environment variables and/or direct insertion";
156 static void global_init() TIMEMORY_VISIBILITY("default");
171 :
m_scope(scope::get_default())
209 for(
const auto& itr : _typeids)
224 base_type::operator=(rhs);
237 ,
m_scope(std::move(rhs.m_scope))
242 rhs.m_bundle.clear();
249 base_type::operator=(std::move(rhs));
250 m_scope = std::move(rhs.m_scope);
254 rhs.m_bundle.clear();
267 for(
auto&& itr : _typeids)
272 PRINT_HERE(
"Skipping duplicate typeid: %lu", (
unsigned long) itr);
281 PRINT_HERE(
"No typeids. Sum: %lu", (
unsigned long) sum);
284 get_data().emplace_back(std::move(obj));
288 template <
typename Type,
typename...
Types,
typename... Args>
292 factory::get_typeids<Type>());
296 factory::get_typeids<Types>()));
305 PRINT_HERE(
"Resetting %s", demangle<this_type>().c_str());
367 template <
typename T>
370 auto _typeid_hash = typeid_hash<T>();
371 void* void_ptr =
nullptr;
374 itr.get(void_ptr, _typeid_hash);
376 return static_cast<T*
>(void_ptr);
378 return static_cast<T*
>(void_ptr);
381 void get(
void*& ptr,
size_t _hash)
const
417 for(
auto&& itr : _typeids)
422 PRINT_HERE(
"Skipping duplicate typeid: %lu", (
unsigned long) itr);
431 PRINT_HERE(
"No typeids. Sum: %lu", (
unsigned long) sum);
434 m_bundle.emplace_back(std::move(obj));
438 template <
typename Type,
typename...
Types,
typename... Args>
441 this->
insert(factory::get_opaque<Type>(args...), factory::get_typeids<Type>());
443 factory::get_typeids<Types>()));
456 return std::any_of(_targ.begin(), _targ.end(),
457 [&_val](
auto itr) { return (itr == _val); });
461 struct persistent_data
471 static persistent_data& get_persistent_data() TIMEMORY_VISIBILITY("default");
492 template <
size_t Idx,
typename Tag>
497 PRINT_HERE(
"Global initialization of %s", demangle<this_type>().c_str());
498 env::initialize_bundle<Idx, Tag>();
503 template <
size_t Idx,
typename Tag>
507 static persistent_data _instance{};
518 #if defined(TIMEMORY_USER_BUNDLE_HEADER_MODE)
Forward declaration of user_bundle components. User-bundles are similar to the classical profiling in...
std::vector< TIMEMORY_COMPONENT > get_bundle_components(const std::vector< user_bundle_spec_t > &_priority)
void initialize_bundle(AltApi _api=AltApi{})
std::function< std::string()> user_bundle_spec_t
std::unordered_map< size_t, std::vector< user_bundle_spec_t > > user_bundle_variables_t
user_bundle_variables_t & get_user_bundle_variables(TIMEMORY_API)
static so that projects cannot globally change this
char const std::string & _prefix
std::recursive_mutex mutex_t
Recursive mutex is used for convenience since the performance penalty vs. a regular mutex is not real...
tim::mpl::apply< std::string > string
The declaration for the types for settings without definitions.
bool get_is_running() const
storage< Tp, Value > storage_type
user_bundle< Idx, Tag > Type
void get(void *&ptr, size_t _hash) const
static bool contains(size_t _val, const typeid_vec_t &_targ)
static void global_init()
user_bundle & operator=(user_bundle &&rhs) noexcept
user_bundle(const char *_prefix, opaque_array_t _bundle_vec, const typeid_set_t &_typeids, scope::config _scope=scope::get_default())
static void configure(opaque &&obj, std::set< size_t > &&_typeids)
static void global_init(storage_type *)
static value_type record()
void insert(opaque &&obj, typeid_set_t &&_typeids)
std::function< void(void *, void *&, size_t)> get_func_t
user_bundle(user_bundle &&rhs) noexcept
static string_t description()
static constexpr auto index
static opaque_array_t & get_data()
std::function< void *(const string_t &, scope::config)> start_func_t
static size_t bundle_size()
void insert(Args... args)
typename base_type::storage_type storage_type
void set_scope(const scope::config &val)
user_bundle(const char *_prefix, opaque_array_t _bundle_vec, typeid_vec_t _typeids, scope::config _scope=scope::get_default())
std::unique_lock< mutex_t > lock_t
static void configure(Args &&... args)
user_bundle(const user_bundle &rhs)
static mutex_t & get_lock()
user_bundle(const char *_prefix, scope::config _scope=scope::get_default())
user_bundle & operator=(const user_bundle &rhs)
std::function< void(void *)> delete_func_t
std::vector< opaque > opaque_array_t
void set_prefix(const char *_prefix)
std::set< size_t > typeid_set_t
std::function< void(void *)> stop_func_t
std::vector< size_t > typeid_vec_t
base< this_type, value_type > base_type
static typeid_vec_t & get_typeids()
This operation attempts to call a member function which the component provides to internally store wh...
This operation attempts to call a member function which the component provides to internally store wh...
this data type encodes the options of storage scope. The default is hierarchical (tree) scope....
#define TIMEMORY_FOLD_EXPRESSION(...)