35 #include "timemory/components/gotcha/backends.hpp"
41 #include <unordered_map>
43 #if defined(TIMEMORY_USE_MPI)
47 #if !defined(NUM_TIMEMORY_MPIP_WRAPPERS)
48 # define NUM_TIMEMORY_MPIP_WRAPPERS 246
58 template <
typename Toolset,
typename Tag>
59 TIMEMORY_VISIBILITY(
"default")
61 std::set<std::string> reject = {});
65 template <
typename Toolset,
typename Tag>
66 TIMEMORY_VISIBILITY(
"default")
72 TIMEMORY_VISIBILITY("default")
98 if(get_tool_count()++ == 0)
100 get_tool_instance() = std::make_shared<mpip_tuple_t>(
"timemory_mpip");
101 get_tool_instance()->start();
107 auto idx = --get_tool_count();
108 if(get_tool_instance().
get())
110 get_tool_instance()->stop();
112 get_tool_instance().reset();
119 struct persistent_data
121 std::atomic<short> m_configured;
122 std::atomic<int64_t> m_count;
123 toolset_ptr_t m_tool;
126 static persistent_data& get_persistent_data()
128 static persistent_data _instance;
132 static std::atomic<short>& get_configured()
134 return get_persistent_data().m_configured;
137 static toolset_ptr_t& get_tool_instance() {
return get_persistent_data().m_tool; }
139 static std::atomic<int64_t>& get_tool_count()
141 return get_persistent_data().m_count;
160 template <
typename Toolset,
typename Tag>
166 static std::shared_ptr<handle_t> _handle;
170 _handle = std::make_shared<handle_t>();
173 auto cleanup_functor = [=]() {
182 std::stringstream ss;
183 ss <<
"timemory-mpip-" << demangle<Toolset>() <<
"-" << demangle<Tag>();
199 template <
typename Toolset,
typename Tag>
206 std::stringstream ss;
207 ss <<
"timemory-mpip-" << demangle<Toolset>() <<
"-" << demangle<Tag>();
219 #if !defined(TIMEMORY_USE_GOTCHA) || !defined(TIMEMORY_USE_MPI)
221 template <
typename Toolset,
typename Tag>
227 template <
typename Toolset,
typename Tag>
232 static bool is_initialized =
false;
239 mpip_gotcha_t::get_initializer() = []() {
489 mpip_gotcha_t::get_reject_list() = [reject]() {
490 auto _reject = reject;
492 auto reject_list = tim::get_env<std::string>(
"TIMEMORY_MPIP_REJECT_LIST",
"");
500 mpip_gotcha_t::get_permit_list() = [permit]() {
501 auto _permit = permit;
503 auto permit_list = tim::get_env<std::string>(
"TIMEMORY_MPIP_PERMIT_LIST",
"");
510 is_initialized =
true;
This is a variadic component wrapper where all components are allocated on the stack and cannot be di...
static pointer_t instance()
Get a shared pointer to the instance for the current thread.
#define TIMEMORY_C_GOTCHA(...)
The declaration for the types for manager without definitions.
void configure_mpip(std::set< std::string >, std::set< std::string >)
#define NUM_TIMEMORY_MPIP_WRAPPERS
uint64_t activate_mpip()
The thread that first activates mpip will be the thread that turns it off. Function returns the numbe...
void configure_mpip(std::set< std::string > permit={}, std::set< std::string > reject={})
uint64_t deactivate_mpip(uint64_t)
The thread that created the initial mpip handle will turn off. Returns the number of handles active.
tim::mpl::apply< std::string > string
auto get(const auto_bundle< Tag, Types... > &_obj)
ContainerT delimit(const std::string &line, const std::string &delimiters="\"',;: ", PredicateT &&predicate=[](const std::string &s) -> std::string { return s;})
The gotcha component rewrites the global offset table such that calling the wrapped function actually...
static std::string label()
std::shared_ptr< mpip_tuple_t > toolset_ptr_t
static std::string description()
#define DEBUG_PRINT_HERE(...)
typename typename typename