29#include "timemory/components/gotcha/backends.hpp"
40#include <unordered_map>
42#if defined(TIMEMORY_USE_MPI) || defined(TIMEMORY_USE_MPI_HEADERS)
46#if !defined(NUM_TIMEMORY_MPIP_WRAPPERS)
47# define NUM_TIMEMORY_MPIP_WRAPPERS 246
57template <
typename Toolset,
typename Tag>
58TIMEMORY_VISIBILITY(
"default")
59TIMEMORY_NOINLINE
void configure_mpip(std::set<std::string> permit = {},
60 std::set<std::string> reject = {});
64template <
typename Toolset,
typename Tag>
65TIMEMORY_VISIBILITY(
"default")
70template <
typename Toolset,
typename Tag>
71TIMEMORY_VISIBILITY(
"default")
76template <
typename Toolset,
typename Tag>
97 if(get_tool_count()++ == 0)
99 get_tool_instance() = std::make_shared<mpip_tuple_t>(
"timemory_mpip");
100 get_tool_instance()->start();
106 auto idx = --get_tool_count();
107 if(get_tool_instance().
get())
109 get_tool_instance()->stop();
111 get_tool_instance().reset();
118 struct persistent_data
120 std::atomic<short> m_configured;
121 std::atomic<int64_t> m_count;
125 static persistent_data& get_persistent_data()
127 static persistent_data _instance;
131 static std::atomic<short>& get_configured()
133 return get_persistent_data().m_configured;
136 static toolset_ptr_t& get_tool_instance() {
return get_persistent_data().m_tool; }
138 static std::atomic<int64_t>& get_tool_count()
140 return get_persistent_data().m_count;
159template <
typename Toolset,
typename Tag>
165 static std::shared_ptr<handle_t> _handle;
169 _handle = std::make_shared<handle_t>();
172 auto cleanup_functor = [=]() {
181 std::stringstream ss;
182 ss <<
"timemory-mpip-" << demangle<Toolset>() <<
"-" << demangle<Tag>();
198template <
typename Toolset,
typename Tag>
205 std::stringstream ss;
206 ss <<
"timemory-mpip-" << demangle<Toolset>() <<
"-" << demangle<Tag>();
218#if !defined(TIMEMORY_USE_GOTCHA) || \
219 (!defined(TIMEMORY_USE_MPI) && !defined(TIMEMORY_USE_MPI_HEADERS))
221template <
typename Toolset,
typename Tag>
227template <
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.
#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
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()
static constexpr size_t mpip_wrapper_count
std::shared_ptr< mpip_tuple_t > toolset_ptr_t
static std::string description()
#define DEBUG_PRINT_HERE(...)