27#include "caliper/ConfigManager.h"
28#include "caliper/cali.h"
34#if defined(TIMEMORY_PYBIND11_SOURCE)
35# include "pybind11/cast.h"
36# include "pybind11/pybind11.h"
37# include "pybind11/stl.h"
82 puts(
"Initializing caliper...");
88 static bool _ini = (
_init(),
true);
98 return (
get_nested() | CALI_ATTR_SCOPE_THREAD);
128 return "Forwards markers to Caliper instrumentation";
135 struct persistent_data
141 static persistent_data& get_persistent_data()
143 static auto _instance = persistent_data{};
154:
public base<caliper_config, void>
155,
private policy::instance_tracker<caliper_config, false>
167 static cali::ConfigManager _instance;
175 std::stringstream ss;
176 for(
auto& itr :
_args)
178 if(!ss.str().empty())
179 cmd = ss.str().substr(1);
182 std::stringstream ss;
183 for(
auto& itr : _kwargs)
185 auto _arg = itr.second;
188 ss <<
"," << itr.first;
192 ss <<
"," << itr.first <<
"=(" << _arg <<
")";
195 if(!ss.str().empty())
199 cmd += ss.str().substr(1);
205 std::cerr <<
"Configuring caliper with :: " <<
cmd << std::endl;
209 std::cerr <<
"Caliper config error: " <<
get_manager().error_msg()
216 std::cerr <<
"Caliper was not configured" << std::endl;
220#if defined(TIMEMORY_PYBIND11_SOURCE)
227 static void configure(project::python, pybind11::args
_args, pybind11::kwargs _kwargs)
231 std::stringstream ss;
232 for(
auto& itr :
_args)
234 if(!ss.str().empty())
235 cmd = ss.str().substr(1);
238 std::stringstream ss;
239 for(
auto& itr : _kwargs)
246 ss <<
"," << itr.first.cast<
std::string>() <<
"=(" << _arg <<
")";
249 if(!ss.str().empty())
253 cmd += ss.str().substr(1);
259 std::cerr <<
"Configuring caliper with :: " <<
cmd << std::endl;
262 std::cerr <<
"Caliper config error: " <<
get_manager().error_msg()
268 std::cerr <<
"Caliper was not configured" << std::endl;
279 "Starting Caliper ConfigManager");
290 "Flushing Caliper ConfigManager");
302:
public base<caliper_marker, void>
303,
public caliper_common
313 return "Generic forwarding of markers to Caliper instrumentation";
320 if(m_prefix ==
nullptr)
323 cali_begin_string(m_id, m_prefix);
327 if(m_prefix ==
nullptr)
330 cali_safe_end_string(m_id, m_prefix);
336 const char* m_prefix =
nullptr;
337 cali_id_t m_id = cali_create_attribute(
"timemory", CALI_TYPE_STRING,
345#if defined(TIMEMORY_PYBIND11_SOURCE)
354 template <
template <
typename...>
class BundleT>
356 pybind11::class_<BundleT<caliper_marker>>& _pyclass)
364 _pyclass.def_static(
"begin_region", _bregion,
"Begin a user-defined region");
365 _pyclass.def_static(
"end_region", _eregion,
"End a user-defined region");
368 pybind11::enum_<cali_attr_properties> _pyattr(
369 _pyclass,
"Attribute", pybind11::arithmetic(),
"Attributes");
370 _pyattr.value(
"Nested", CALI_ATTR_NESTED)
371 .value(
"ThreadScope", CALI_ATTR_SCOPE_THREAD)
372 .value(
"ProcessScope", CALI_ATTR_SCOPE_PROCESS)
373 .value(
"TaskScope", CALI_ATTR_SCOPE_TASK);
384struct caliper_loop_marker
385:
public base<caliper_loop_marker, void>
386,
public caliper_common
396 return "Variant of caliper_marker with support for loop marking";
404 cali_begin_string(m_id, m_prefix);
405 m_id = cali_make_loop_iteration_attribute(m_prefix);
408 void stop() { cali_end(m_id); }
413 cali_begin_int(m_id, m_itr++);
421 template <typename T, enable_if_t<std::is_integral<T>::value,
int> = 0>
426 cali_begin_int(m_id, m_itr++);
429 template <typename T, enable_if_t<std::is_integral<T>::value,
int> = 0>
436 template <typename T, enable_if_t<std::is_integral<T>::value,
int> = 0>
441 cali_begin_int(m_id, m_itr++);
447#if defined(TIMEMORY_PYBIND11_SOURCE)
448 template <
template <
typename...>
class BundleT>
449 static void configure(project::python, pybind11::class_<BundleT<caliper_marker>>&)
455 cali_id_t m_id = cali_create_attribute(
"timemory", CALI_TYPE_STRING,
457 const char* m_prefix =
nullptr;
void stop(TupleT< Tp... > &obj, Args &&... args)
void start(TupleT< Tp... > &obj, Args &&... args)
trait that designates the type supports these arguments from python. Specializations MUST be structur...
std::array< char *, 4 > _args
char const std::string & _prefix
tim::mpl::apply< std::string > string
void consume_parameters(ArgsT &&...)
lightweight tuple-alternative for meta-programming logic
static void configure(Args &&...)
static void enable_process_scope()
static std::string label()
static void enable_task_scope()
static attributes_t & get_attributes()
static void enable_thread_scope()
static auto get_task_scope()
static std::string description()
static auto get_process_scope()
static std::string & get_channel()
static auto get_thread_scope()
static attributes_t get_default_attributes()
static attributes_t get_nested()
static auto & get_manager()
static void configure(const arg_vec_t &_args, const arg_map_t &_kwargs={})
std::map< std::string, std::string > arg_map_t
static std::string description()
static std::string label()
std::vector< std::string > arg_vec_t
Loop marker for the Caliper Performance Analysis Toolbox.
void set_prefix(const char *_prefix)
tim::scope::destructor record(T itr)
static std::string label()
static std::string description()
Standard marker for the Caliper Performance Analysis Toolbox.
static void stop(const std::string &_name)
static void start(const std::string &_name)
static std::string description()
static std::string label()
void set_prefix(const char *_prefix)
provides an object which can be returned from functions that will execute the lambda provided during ...
#define CONDITIONAL_PRINT_HERE(CONDITION,...)
#define DEBUG_PRINT_HERE(...)