28#include "timemory/components/timing/backends.hpp"
66struct derivation_types<component::child_cpu_util>
68 using type = type_list<type_list<component::wall_clock, component::child_cpu_clock>,
69 type_list<component::wall_clock, component::child_user_clock,
70 component::child_system_clock>>;
79struct child_system_clock :
public base<child_system_clock>
81 using ratio_t = std::nano;
82 using value_type = int64_t;
83 using base_type = base<child_system_clock, value_type>;
87 static value_type
record() noexcept
89 return tim::get_child_clock_system_now<int64_t, ratio_t>();
91 double get() const noexcept
93 return load() /
static_cast<double>(base_type::get_unit());
95 double get_display() const noexcept {
return get(); }
99 value = (
record() - value);
105struct child_user_clock :
public base<child_user_clock>
107 using ratio_t = std::nano;
108 using value_type = int64_t;
109 using base_type = base<child_user_clock, value_type>;
113 static value_type
record() noexcept
115 return tim::get_child_clock_user_now<int64_t, ratio_t>();
117 double get() const noexcept
119 return load() /
static_cast<double>(base_type::get_unit());
121 double get_display() const noexcept {
return get(); }
125 value = (
record() - value);
131struct child_cpu_clock :
public base<child_cpu_clock>
133 using ratio_t = std::nano;
134 using value_type = int64_t;
135 using base_type = base<child_cpu_clock, value_type>;
140 return "Total CPU time spent in both user- and kernel-mode";
142 static value_type
record() noexcept
144 return tim::get_child_clock_cpu_now<int64_t, ratio_t>();
146 double get() const noexcept
148 return load() /
static_cast<double>(base_type::get_unit());
150 double get_display() const noexcept {
return get(); }
154 value = (
record() - value);
160struct child_cpu_util :
public base<child_cpu_util, std::pair<int64_t, int64_t>>
162 using ratio_t = std::nano;
163 using value_type = std::pair<int64_t, int64_t>;
164 using base_type = base<child_cpu_util, value_type>;
169 return "Percentage of CPU-clock time divided by wall-clock time";
171 static value_type
record()
176 double get() const noexcept
179 double denom = (_data.second > 0) ? _data.second : 1;
180 double numer = (_data.second > 0) ? _data.first : 0;
181 return 100.0 *
static_cast<double>(numer) /
static_cast<double>(denom);
184 double get_display() const noexcept {
return get(); }
186 void start() noexcept
197 value = (
record() - value);
203 bool is_derived() const noexcept {
return m_derive; }
205 bool assemble(
const wall_clock* wc,
const child_cpu_clock* cc)
noexcept
212 bool assemble(
const wall_clock* wc,
const child_user_clock* uc,
213 const child_system_clock* sc)
noexcept
220 bool derive(
const wall_clock* wc,
const child_cpu_clock* cc)
noexcept
222 if(m_derive && wc && cc)
224 value.first = cc->get_value();
225 value.second = wc->get_value();
232 bool derive(
const wall_clock* wc,
const child_user_clock* uc,
233 const child_system_clock* sc)
noexcept
235 if(m_derive && wc && uc && sc)
237 value.first = uc->get_value() + sc->get_value();
238 value.second = wc->get_value();
246 this_type&
operator+=(
const this_type& rhs)
noexcept
253 this_type&
operator-=(
const this_type& rhs)
noexcept
261 bool m_derive =
false;
#define TIMEMORY_DECLARE_COMPONENT(NAME)
Declare a non-templated component type in the tim::component namespace.
#define TIMEMORY_DEFINE_CONCRETE_TRAIT(TRAIT, COMPONENT, VALUE)
#define TIMEMORY_STATISTICS_TYPE(COMPONENT, TYPE)
void load(Archive &ar, tim::node::graph< Tp > &d)
void assemble(TupleT< Tp... > &obj, Args &&... args)
void record(TupleT< Tp... > &obj, Args &&... args)
void derive(TupleT< Tp... > &obj, Args &&... args)
void stop(TupleT< Tp... > &obj, Args &&... args)
void start(TupleT< Tp... > &obj, Args &&... args)
std::array< Tp, N > & operator+=(std::array< Tp, N > &, Other &&)
std::array< Tp, N > & operator-=(std::array< Tp, N > &, const std::array< Tp, N > &)
tim::mpl::apply< std::string > string
auto get(const auto_bundle< Tag, Types... > &_obj)
description("A generic option for any setting. Each argument MUST be passed in " "form: 'NAME=VALUE'. E.g. --timemory-args " "\"papi_events=PAPI_TOT_INS,PAPI_TOT_CYC\" text_output=off") .action([&](parser_t &p)
static value_type record() noexcept
std::tuple< type_list<> > type