32#include "timemory/backends/dmp.hpp"
51template <
typename... Types>
56 static constexpr size_t value =
sizeof...(Types);
71template <
template <
typename...>
class Tuple,
typename... Tp>
74 using type = Tuple<std::remove_pointer_t<Tp>...>;
118template <
typename Up,
typename Ap = trait::is_available_t<Up>>
121template <
typename Up>
125 using Vp =
typename Up::value_type;
126 static constexpr bool value = !std::is_void<Vp>::value;
129template <
typename Up>
134 static constexpr bool value = !std::is_void<Vp>::value;
139template <
typename Up>
143 using Vp =
typename Up::value_type;
149template <
typename Up>
186decltype(internal::resolve_record_type<U>(0))
189 return internal::resolve_record_type<U>(0);
194template <
typename T,
typename V =
typename T::value_type>
201 std::is_same<V, type>::value);
206template <
typename Up,
typename Vp>
217template <
typename U,
typename StatsT>
319template <
typename Ret,
typename Lhs,
typename Rhs>
327 TIMEMORY_DEFAULT_OBJECT(
insert)
329 template <
typename Up,
typename... Args>
332 static_assert(!std::is_pointer<Up>::value,
333 "SFINAE tests will always fail with pointer types");
334 return sfinae(obj, 0, 0, std::forward<Args>(args)...);
338 template <
typename Up,
typename... Args>
339 static TIMEMORY_HOT
auto sfinae(Up& obj,
int,
int, Args&&... args)
340 ->
decltype(obj.insert(std::forward<Args>(args)...))
342 return obj.insert(std::forward<Args>(args)...);
345 template <
typename Up,
typename... Args>
346 static TIMEMORY_HOT
auto sfinae(Up& obj,
int,
long, Args&&... args)
347 ->
decltype(obj->insert(std::forward<Args>(args)...))
349 return obj->insert(std::forward<Args>(args)...);
352 template <
typename Up,
typename... Args>
353 static TIMEMORY_INLINE
auto sfinae(Up&,
long,
long, Args&&...) -> std::nullptr_t
366 template <
typename Up,
typename Vp>
369 static_assert(!std::is_pointer<Up>::value,
370 "SFINAE tests will always fail with pointer types");
371 sfinae(obj, 0, 0, std::forward<Vp>(arg));
375 template <
typename Up,
typename Vp>
376 TIMEMORY_HOT
auto sfinae(Up& obj,
int,
int, Vp&& arg)
const
377 ->
decltype(obj.stack_push(std::forward<Vp>(arg)), void())
379 obj.stack_push(std::forward<Vp>(arg));
382 template <
typename Up,
typename Vp>
383 TIMEMORY_HOT
auto sfinae(Up& obj,
int,
long, Vp&& arg)
const
384 ->
decltype(obj->stack_push(std::forward<Vp>(arg)), void())
387 obj->stack_push(std::forward<Vp>(arg));
390 template <
typename Up,
typename... Args>
391 TIMEMORY_INLINE
void sfinae(Up&,
long,
long, Args&&...)
const
400 TIMEMORY_DEFAULT_OBJECT(
pop)
402 template <
typename Up,
typename... Args>
403 TIMEMORY_HOT
decltype(
auto)
operator()(Up& obj, Args&&... args)
const
405 static_assert(!std::is_pointer<Up>::value,
406 "SFINAE tests will always fail with pointer types");
407 return sfinae(obj, 0, std::forward<Args>(args)...);
411 template <
typename Up,
typename... Args>
412 TIMEMORY_HOT
auto sfinae(Up& obj,
int, Args&&... args)
const
413 ->
decltype(obj.pop(std::forward<Args>(args)...))
415 return obj.pop(std::forward<Args>(args)...);
418 template <
typename Up,
typename... Args>
419 TIMEMORY_INLINE
void sfinae(Up&,
long, Args&&...)
const
430 template <
typename Up,
typename Vp>
433 static_assert(!std::is_pointer<Up>::value,
434 "SFINAE tests will always fail with pointer types");
435 sfinae(obj, 0, 0, std::forward<Vp>(arg));
439 template <
typename Up,
typename Vp>
440 TIMEMORY_HOT
auto sfinae(Up& obj,
int,
int, Vp&& arg)
const
441 ->
decltype(obj.stack_pop(std::forward<Vp>(arg)), void())
443 obj.stack_pop(std::forward<Vp>(arg));
446 template <
typename Up,
typename Vp>
447 TIMEMORY_HOT
auto sfinae(Up& obj,
int,
long, Vp&& arg)
const
448 ->
decltype(obj->stack_pop(std::forward<Vp>(arg)), void())
451 obj->stack_pop(std::forward<Vp>(arg));
454 template <
typename Up,
typename... Args>
455 TIMEMORY_INLINE
void sfinae(Up&,
long,
long, Args&&...)
const
472 template <
typename Up>
475 static_assert(!std::is_pointer<Up>::value,
476 "SFINAE tests will always fail with pointer types");
477 return sfinae(obj, 0);
481 template <
typename Up>
482 static TIMEMORY_HOT
auto sfinae(Up& obj,
int) ->
decltype(obj.set_started())
484 return obj.set_started();
487 template <
typename Up>
488 static TIMEMORY_INLINE
auto sfinae(Up&,
long) ->
void
505 template <
typename Up>
508 static_assert(!std::is_pointer<Up>::value,
509 "SFINAE tests will always fail with pointer types");
510 return sfinae(obj, 0);
514 template <
typename Up>
515 static TIMEMORY_HOT
auto sfinae(Up& obj,
int) ->
decltype(obj.set_stopped())
517 return obj.set_stopped();
520 template <
typename Up>
521 static TIMEMORY_INLINE
auto sfinae(Up&,
long) ->
void
534struct set_depth_change;
595template <
typename T,
bool DefaultValue>
600 template <
typename Up>
603 static_assert(!std::is_pointer<Up>::value,
604 "SFINAE tests will always fail with pointer types");
605 return sfinae(obj, 0);
609 template <
typename Up>
610 static auto sfinae(
const Up& obj,
int) ->
decltype(obj.get_is_running())
612 return obj.get_is_running();
615 template <
typename Up>
616 static auto sfinae(
const Up& obj,
long) ->
decltype(obj.is_running())
618 return obj.is_running();
621 template <
typename Up>
622 static auto sfinae(
const Up&, ...) ->
bool
636template <
typename T,
bool DefaultValue>
641 template <
typename Up>
644 static_assert(!std::is_pointer<Up>::value,
645 "SFINAE tests will always fail with pointer types");
646 return sfinae(obj, 0);
650 template <
typename Up>
651 static auto sfinae(
const Up& obj,
int) ->
decltype(obj.get_is_flat())
653 return obj.get_is_flat();
656 template <
typename Up>
657 static auto sfinae(
const Up&, ...) ->
bool
671template <
typename T,
bool DefaultValue>
676 template <
typename Up>
679 static_assert(!std::is_pointer<Up>::value,
680 "SFINAE tests will always fail with pointer types");
681 return sfinae(obj, 0);
685 template <
typename Up>
686 static auto sfinae(
const Up& obj,
int) ->
decltype(obj.get_is_invalid())
688 return obj.get_is_invalid();
691 template <
typename Up>
692 static auto sfinae(
const Up&, ...) ->
bool
706template <
typename T,
bool DefaultValue>
711 template <
typename Up>
714 static_assert(!std::is_pointer<Up>::value,
715 "SFINAE tests will always fail with pointer types");
716 return sfinae(obj, 0);
720 template <
typename Up>
721 static auto sfinae(
const Up& obj,
int) ->
decltype(obj.get_is_on_stack())
723 return obj.get_is_on_stack();
726 template <
typename Up>
727 static auto sfinae(
const Up&, ...) ->
bool
740template <
typename T,
int64_t DefaultDepth = 0>
745 template <
typename Up, enable_if_t<!std::is_po
inter<decay_t<Up>>::value,
int> = 0>
748 static_assert(!std::is_pointer<Up>::value,
749 "SFINAE tests will always fail with pointer types");
750 return sfinae(obj, 0, 0);
753 template <
typename Up, enable_if_t<std::is_po
inter<decay_t<Up>>::value,
int> = 0>
759 return sfinae(*obj, 0, 0);
763 template <
typename Up>
764 auto sfinae(Up& obj,
int,
int)
const ->
decltype(obj.get_depth())
766 return obj.get_depth();
769 template <
typename Up>
770 auto sfinae(Up& obj,
int,
long)
const ->
decltype(obj.depth())
775 template <
typename Up>
776 auto sfinae(Up&&,
long,
long)
const
797 TIMEMORY_INLINE auto operator()(
type& obj)
const
815 template <
typename Up>
818 static_assert(!std::is_pointer<Up>::value,
819 "SFINAE tests will always fail with pointer types");
820 return sfinae(obj, 0);
824 template <
typename Up>
825 static auto sfinae(Up& obj,
int) ->
decltype(obj.get_iterator())
827 return obj.get_iterator();
830 template <
typename Up>
831 static auto sfinae(Up&&, ...) -> std::nullptr_t
845struct priority_start;
850struct standard_start;
935struct get_labeled_data;
955struct print_statistics;
970struct add_statistics;
980struct extra_serialization;
984template <typename T, bool Enabled = trait::echo_enabled<T>::value>
1004template <
typename T>
1009template <
typename T>
1014template <
typename T,
typename Op,
typename Tag = TIMEMORY_API>
1019template <
typename T>
1024template <
typename T>
1029template <
typename T>
1034template <
typename Tag = TIMEMORY_API>
1039template <
typename T>
1042 static_assert(std::is_default_constructible<T>::value,
1043 "Type is not default constructible and therefore a dummy object (for "
1044 "placeholders and meta-programming) cannot be automatically generated. "
1045 "Please specialize tim::operation::dummy<T> to provide operator()() "
1046 "which returns a dummy object.");
1048 TIMEMORY_DEFAULT_OBJECT(
dummy)
1050 TIMEMORY_INLINE T operator()()
const
1060template <
typename T>
1061struct python_class_name;
1070template <
typename Type,
bool has_data>
1075template <
typename Type,
bool has_data>
1080template <
typename Type,
bool has_data>
1085template <
typename Type,
bool has_data>
1090template <
typename Type,
bool has_data>
1095template <
typename Type,
bool has_data>
1100template <
typename Type>
1106 using graph_t =
typename storage_type::graph_type;
1109 template <
typename Tp>
1112 TIMEMORY_DEFAULT_OBJECT(
merge)
1118 template <
typename Tp>
1121 template <
typename Tp>
1125 template <
typename Tp>
1130 template <
typename Tp>
1133 template <
typename Tp>
1140template <
typename Type>
1146 using graph_t =
typename storage_type::graph_type;
1155template <
typename Type>
1160template <
typename Type>
1176 explicit TIMEMORY_COLD
print(
bool _forced_json =
false,
1241 PRINT_HERE(
"%s",
"Null pointer to settings! Disabling");
1250 PRINT_HERE(
"%s",
"Null pointer to settings! Disabling");
1259 PRINT_HERE(
"%s",
"Null pointer to settings! Disabling");
1268 PRINT_HERE(
"%s",
"Null pointer to settings! Disabling");
1278 PRINT_HERE(
"%s",
"Null pointer to settings! Disabling");
1288 PRINT_HERE(
"%s",
"Null pointer to settings! Disabling");
1297 PRINT_HERE(
"%s",
"Null pointer to settings! Disabling");
1307 PRINT_HERE(
"%s",
"Null pointer to settings! Disabling");
1343template <
typename Tp>
1360 using result_tree = std::map<std::string, std::vector<basic_tree_vector_type>>;
1368 explicit TIMEMORY_COLD
print(
1393 if(node_init && node_rank > 0)
1399 print_json(json_outfname, node_results);
1401 print_tree(tree_outfname, node_tree);
1403 print_text(text_outfname, data_stream);
1405 print_plot(json_outfname,
"");
1410 print_cout(data_stream);
1425 print_json(json_diffname, node_delta);
1427 print_text(text_diffname, diff_stream);
1430 std::stringstream ss;
1431 ss <<
"Difference vs. " << json_inpfname;
1432 print_plot(json_diffname, ss.str());
1438 print_cout(diff_stream);
1449 TIMEMORY_COLD
void update_data()
override;
1450 TIMEMORY_COLD
void setup()
override;
1451 TIMEMORY_COLD
void read_json()
override;
1453 TIMEMORY_COLD
void print_dart()
override;
1459 }
catch(std::exception& e)
1461 fprintf(stderr,
"Exception: %s\n", e.what());
1464 TIMEMORY_COLD
virtual void print_tree(
const std::string& fname, result_tree& rt);
1466 TIMEMORY_COLD
void write_stream(stream_type&
stream, result_type& results);
1467 TIMEMORY_COLD
void print_json(
const std::string& fname, result_type& results);
1468 TIMEMORY_COLD
const auto&
get_data()
const {
return data; }
1475 std::vector<result_node*> flat;
1476 for(
auto& ritr : results)
1478 for(
auto& itr : ritr)
1480 flat.push_back(&itr);
1498template <
typename Tp>
1501 template <
typename... Args>
1512template <
typename T>
::tim::statistics< Tp > max(::tim::statistics< Tp > lhs, const Tp &rhs)
void mark_begin(TupleT< Tp... > &obj, Args &&... args)
void audit(TupleT< Tp... > &obj, Args &&... args)
void store(TupleT< Tp... > &obj, Args &&... args)
void record(TupleT< Tp... > &obj, Args &&... args)
void stop(TupleT< Tp... > &obj, Args &&... args)
void mark_end(TupleT< Tp... > &obj, Args &&... args)
void mark(TupleT< Tp... > &obj, Args &&... args)
void print(std::ostream &os, Args &&... args)
void start(TupleT< Tp... > &obj, Args &&... args)
Tp & plus(Tp &, const Up &)
auto divide(Tp &_lhs, Up _rhs, type_list<>,...) -> decltype(_lhs/=_rhs, void())
Tp & minus(Tp &, const Up &)
Tp & multiply(Tp &, const Up &)
typename has_data< U >::type has_data_t
typename is_enabled< U >::type is_enabled_t
decltype(internal::resolve_record_type< U >(0)) resolve_record_type()
std::integral_constant< int, ModeV > mode_constant
This operation class echoes DartMeasurements for a CDash dashboard.
char argparse::argument_parser tim::settings * _settings
tim::mpl::apply< std::string > string
const std::string std::ostream * os
auto get(const auto_bundle< Tag, Types... > &_obj)
Tuple< std::remove_pointer_t< Tp >... > type
typename remove_pointers< Tp >::type remove_pointers_t
Include the macros for operations.
Declare the storage types.
Basic hierarchical tree implementation. Expects population from tim::graph.
concept that specifies that a type is not a useful type
This data type is used when rendering the hierarchical representation (i.e. requires recursion) repre...
typename mpl::function_traits< decltype(&resolve_record_type< T >)>::result_type type
static constexpr bool value
This class executes a cleanup routine at the end of the application.
The purpose of this operation class is operating on two components to compose a result,...
The purpose of this operation class is construct an object with specific args.
This operation class is used for copying the object generically.
This class post-processes strings for a given API.
static constexpr bool value
static constexpr bool value
std::string text_diffname
std::shared_ptr< settings > settings_t
virtual void read_json()=0
print(std::string _label, bool _forced_json, settings_t _settings=settings::shared_instance())
virtual void print_dart()=0
void set_max_call_stack(int64_t v)
virtual void print_cout(stream_type stream)
std::string json_outfname
std::shared_ptr< utility::stream > stream_type
int64_t get_max_depth() const
void set_verbose(int32_t v)
auto get_json_diff_name() const
auto get_text_output_name() const
virtual void print_plot(const std::string &fname, std::string suffix)
std::string text_outfname
virtual void update_data()=0
std::string json_inpfname
auto get_json_output_name() const
std::string json_diffname
auto get_json_input_name() const
virtual void print_custom()=0
std::string tree_outfname
auto get_text_diff_name() const
auto get_tree_output_name() const
virtual void write(std::ostream &os, stream_type stream)
print(bool _forced_json=false, settings_t _settings=settings::shared_instance())
virtual void print_text(const std::string &fname, stream_type stream)
merge(result_type &, const result_type &)
typename storage_type::graph_type graph_t
typename storage_type::result_array_t result_type
impl::storage< Type, has_data > storage_type
typename storage_type::singleton_type singleton_t
typename storage_type::graph_type graph_t
vector_t< basic_tree< Tp > > operator()(const vector_t< basic_tree< Tp > > &, const vector_t< basic_tree< Tp > > &)
vector_t< basic_tree< Tp > > operator()(const vector_t< vector_t< basic_tree< Tp > > > &_bt, size_t _root=0)
typename storage_type::result_array_t result_type
std::vector< Tp > vector_t
vector_t< basic_tree< Tp > > operator()(const vector_t< basic_tree< Tp > > &_bt)
impl::storage< Type, has_data > storage_type
typename storage_type::singleton_type singleton_t
std::vector< uint64_t > hierarchy_type
void print_custom() override
std::vector< basic_tree_type > basic_tree_vector_type
impl::storage< Tp, has_data > storage_type
print(const std::string &_label, storage_type *_data, const settings_t &_settings=settings::shared_instance())
typename storage_type::dmp_result_t result_type
std::function< void(this_type *)> callback_type
std::vector< result_node * > get_flattened(result_type &results)
typename storage_type::graph_node graph_node
const auto & get_node_input() const
std::map< std::string, std::vector< basic_tree_vector_type > > result_tree
const auto & get_node_results() const
typename storage_type::graph_t graph_type
const auto & get_data() const
const auto & get_node_delta() const
typename storage_type::result_node result_node
~print() override=default
static callback_type & get_default_callback()
This operation class is used for invoking the static initializer and thread-local initializer of a co...
This operation class is similar to pointer_operator but can handle non-pointer types.
This operation attempts to call a member function which provides a depth value.
auto operator()(Up obj) const
auto operator()(Up &obj) const
This operation attempts to call a member function which provides whether or not the component pushed ...
auto operator()(const Up &obj) const
This operation attempts to call a member function which provides whether or not the component is in a...
auto operator()(const Up &obj) const
This operation attempts to call a member function which provides whether or not the component is in a...
auto operator()(const Up &obj) const
This operation attempts to call a member function which provides a pointer to a component which exist...
auto operator()(Up &obj) const
This operation attempts to call a member function which provides a pointer to the data storage struct...
This operation class is used for invoking the static initializer and thread-local initializer of a co...
auto operator()(Up &obj, Args &&... args) const
typename Up::value_type Vp
static constexpr bool value
This operation attempts to call a member function which provides whether or not the component current...
auto operator()(const Up &obj) const
This operation class is used for a single measurement for a component.
This operation class is used for sampling.
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 sets whether or not the component is in a val...
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 sets whether or not the component is currentl...
This operation attempts to call a member function which sets a pointer to a reference value in persis...
Call the set_prefix member function. These instantiations are always inlined because of the use of st...
This operation attempts to call a member function which the component provides to internally store wh...
auto operator()(Up &obj) const
This operation attempts to call a member function which the component provides to internally store wh...
auto operator()(Up &obj) const
void operator()(Up &obj, Vp &&arg) const
void operator()(Up &obj, Vp &&arg) const
static constexpr bool value
static pointer_t shared_instance()
trait that signifies that an implementation for the component is available. When this is set to false...
trait that signifies the component will calculate min/max/stddev
This trait is used to determine whether the (expensive) instantiation of the storage class happens.
#define TSTAG(X)
\macro TSTAG