timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
tim::component::papi_rate_tuple< RateT, EventTypes > Struct Template Reference

This component pairs a tim::component::papi_tuple with a component which will provide an interval over which the hardware counters will be reported, e.g. if RateT is tim::component::wall_clock, the reported values will be the hardware-counters w.r.t. the wall-clock time. If RateT is tim::component::cpu_clock, the reported values will be the hardware counters w.r.t. the cpu time. More...

#include "timemory/components/papi/papi_rate_tuple.hpp"

+ Collaboration diagram for tim::component::papi_rate_tuple< RateT, EventTypes >:

Public Types

using size_type = std::size_t
 
using tuple_type = papi_tuple< EventTypes... >
 
using rate_type = RateT
 
using value_type = std::pair< tuple_type, rate_type >
 
using this_type = papi_rate_tuple< RateT, EventTypes... >
 
using base_type = base< this_type, value_type >
 
using storage_type = typename base_type::storage_type
 
using common_type = tuple_type
 
template<typename Tp >
using array_t = std::array< Tp, num_events >
 

Public Member Functions

void start ()
 
void stop ()
 
this_typeoperator+= (const this_type &rhs)
 
this_typeoperator-= (const this_type &rhs)
 
template<typename Tp = double>
auto get () const
 

Static Public Member Functions

static void configure ()
 
static void initialize ()
 
static void finalize ()
 
static void global_init ()
 
static void global_finalize ()
 
static void thread_init ()
 
static void thread_finalize ()
 
static std::string label ()
 
static std::string description ()
 
static auto label_array ()
 
static auto description_array ()
 
static auto display_unit_array ()
 
static auto unit_array ()
 
template<typename... Args>
static opaque get_opaque (Args &&...)
 

Static Public Attributes

static const size_type num_events = sizeof...(EventTypes)
 

Friends

struct operation::record< common_type >
 
struct operation::start< this_type >
 
struct operation::stop< this_type >
 
struct operation::set_started< this_type >
 
struct operation::set_stopped< this_type >
 
class impl::storage< this_type, trait::uses_value_storage< this_type, value_type >::value >
 
std::ostream & operator<< (std::ostream &os, const this_type &obj)
 

Detailed Description

template<typename RateT, int... EventTypes>
struct tim::component::papi_rate_tuple< RateT, EventTypes >

This component pairs a tim::component::papi_tuple with a component which will provide an interval over which the hardware counters will be reported, e.g. if RateT is tim::component::wall_clock, the reported values will be the hardware-counters w.r.t. the wall-clock time. If RateT is tim::component::cpu_clock, the reported values will be the hardware counters w.r.t. the cpu time.

Template Parameters
RateTComponent whose value will be the divisor for all the hardware counters
EventTypesCompile-time constant list of PAPI event identifiers
// the "Instructions" alias below explicitly collects the total instructions per
second,
// the number of load instructions per second, the number of store instructions per
second using Instructions = papi_rate_tuple<wall_clock, PAPI_TOT_INS, PAPI_LD_INS,
PAPI_SR_INS>;
Instructions inst{};
inst.start();
...
inst.stop();
std::vector<double> data = inst.get();
static common_data & data()

Definition at line 74 of file papi_rate_tuple.hpp.

Member Typedef Documentation

◆ array_t

template<typename RateT , int... EventTypes>
template<typename Tp >
using tim::component::papi_rate_tuple< RateT, EventTypes >::array_t = std::array<Tp, num_events>

Definition at line 94 of file papi_rate_tuple.hpp.

◆ base_type

template<typename RateT , int... EventTypes>
using tim::component::papi_rate_tuple< RateT, EventTypes >::base_type = base<this_type, value_type>

Definition at line 89 of file papi_rate_tuple.hpp.

◆ common_type

template<typename RateT , int... EventTypes>
using tim::component::papi_rate_tuple< RateT, EventTypes >::common_type = tuple_type

Definition at line 91 of file papi_rate_tuple.hpp.

◆ rate_type

template<typename RateT , int... EventTypes>
using tim::component::papi_rate_tuple< RateT, EventTypes >::rate_type = RateT

Definition at line 86 of file papi_rate_tuple.hpp.

◆ size_type

template<typename RateT , int... EventTypes>
using tim::component::papi_rate_tuple< RateT, EventTypes >::size_type = std::size_t

Definition at line 82 of file papi_rate_tuple.hpp.

◆ storage_type

template<typename RateT , int... EventTypes>
using tim::component::papi_rate_tuple< RateT, EventTypes >::storage_type = typename base_type::storage_type

Definition at line 90 of file papi_rate_tuple.hpp.

◆ this_type

template<typename RateT , int... EventTypes>
using tim::component::papi_rate_tuple< RateT, EventTypes >::this_type = papi_rate_tuple<RateT, EventTypes...>

Definition at line 88 of file papi_rate_tuple.hpp.

◆ tuple_type

template<typename RateT , int... EventTypes>
using tim::component::papi_rate_tuple< RateT, EventTypes >::tuple_type = papi_tuple<EventTypes...>

Definition at line 85 of file papi_rate_tuple.hpp.

◆ value_type

template<typename RateT , int... EventTypes>
using tim::component::papi_rate_tuple< RateT, EventTypes >::value_type = std::pair<tuple_type, rate_type>

Definition at line 87 of file papi_rate_tuple.hpp.

Member Function Documentation

◆ configure()

template<typename RateT , int... EventTypes>
static void tim::component::papi_rate_tuple< RateT, EventTypes >::configure ( )
inlinestatic

◆ description()

template<typename RateT , int... EventTypes>
static std::string tim::component::papi_rate_tuple< RateT, EventTypes >::description ( )
inlinestatic

Definition at line 141 of file papi_rate_tuple.hpp.

142 {
143 return std::string(
144 "Reports the rate of the given set of HW counters w.r.t. the ") +
145 rate_type::label() + " component";
146 }
tim::mpl::apply< std::string > string
Definition: macros.hpp:53

◆ description_array()

template<typename RateT , int... EventTypes>
static auto tim::component::papi_rate_tuple< RateT, EventTypes >::description_array ( )
inlinestatic

Definition at line 196 of file papi_rate_tuple.hpp.

197 {
199 for(auto& itr : arr)
200 itr += " Rate";
201 return arr;
202 }
static array_t< std::string > description_array()
Definition: papi_tuple.hpp:323

References tim::component::papi_tuple< EventTypes >::description_array().

◆ display_unit_array()

template<typename RateT , int... EventTypes>
static auto tim::component::papi_rate_tuple< RateT, EventTypes >::display_unit_array ( )
inlinestatic

Definition at line 204 of file papi_rate_tuple.hpp.

205 {
206 auto arr = tuple_type::label_array();
207 for(auto& itr : arr)
208 {
209 if(itr.empty())
210 itr = "1";
211 itr += "/" + rate_type::display_unit();
212 }
213 return arr;
214 }
static array_t< std::string > label_array()
Definition: papi_tuple.hpp:312

References tim::component::papi_tuple< EventTypes >::label_array().

◆ finalize()

template<typename RateT , int... EventTypes>
static void tim::component::papi_rate_tuple< RateT, EventTypes >::finalize ( )
inlinestatic

◆ get()

template<typename RateT , int... EventTypes>
template<typename Tp = double>
auto tim::component::papi_rate_tuple< RateT, EventTypes >::get ( ) const
inline

Definition at line 180 of file papi_rate_tuple.hpp.

181 {
182 auto _val = value.first.template get<Tp>();
183 for(auto& itr : _val)
184 itr /= value.second.get();
185 return _val;
186 }

◆ get_opaque()

template<typename... Args>
static opaque tim::component::empty_base::get_opaque ( Args &&  ...)
inlinestaticinherited

Definition at line 72 of file declaration.hpp.

73 {
74 return opaque{};
75 }

◆ global_finalize()

template<typename RateT , int... EventTypes>
static void tim::component::papi_rate_tuple< RateT, EventTypes >::global_finalize ( )
inlinestatic

Definition at line 114 of file papi_rate_tuple.hpp.

115 {
116 /*operation::fini<tuple_type>{}(
117 operation::mode_constant<operation::fini_mode::global>{});
118 operation::fini<rate_type>{}(
119 operation::mode_constant<operation::fini_mode::global>{});*/
120 }

◆ global_init()

template<typename RateT , int... EventTypes>
static void tim::component::papi_rate_tuple< RateT, EventTypes >::global_init ( )
inlinestatic

Definition at line 107 of file papi_rate_tuple.hpp.

108 {
109 operation::init<tuple_type>{}(
110 operation::mode_constant<operation::init_mode::global>{});
111 operation::init<rate_type>{}(
112 operation::mode_constant<operation::init_mode::global>{});
113 }

◆ initialize()

template<typename RateT , int... EventTypes>
static void tim::component::papi_rate_tuple< RateT, EventTypes >::initialize ( )
inlinestatic

◆ label()

template<typename RateT , int... EventTypes>
static std::string tim::component::papi_rate_tuple< RateT, EventTypes >::label ( )
inlinestatic

Definition at line 137 of file papi_rate_tuple.hpp.

138 {
139 return tuple_type::label() + "_" + properties<rate_type>::id() + "_rate";
140 }
static std::string label()
Definition: papi_tuple.hpp:225
static constexpr const char * id()
Definition: properties.hpp:221

References tim::component::properties< Tp >::id(), and tim::component::papi_tuple< EventTypes >::label().

◆ label_array()

template<typename RateT , int... EventTypes>
static auto tim::component::papi_rate_tuple< RateT, EventTypes >::label_array ( )
inlinestatic

Definition at line 188 of file papi_rate_tuple.hpp.

189 {
190 auto arr = tuple_type::label_array();
191 for(auto& itr : arr)
192 itr += " per " + rate_type::get_display_unit();
193 return arr;
194 }

References tim::component::papi_tuple< EventTypes >::label_array().

◆ operator+=()

template<typename RateT , int... EventTypes>
this_type & tim::component::papi_rate_tuple< RateT, EventTypes >::operator+= ( const this_type rhs)
inline

Definition at line 165 of file papi_rate_tuple.hpp.

166 {
167 value.first += rhs.value.first;
168 value.second += rhs.value.second;
169 return *this;
170 }

◆ operator-=()

template<typename RateT , int... EventTypes>
this_type & tim::component::papi_rate_tuple< RateT, EventTypes >::operator-= ( const this_type rhs)
inline

Definition at line 172 of file papi_rate_tuple.hpp.

173 {
174 value.first -= rhs.value.first;
175 value.second -= rhs.value.second;
176 return *this;
177 }

◆ start()

template<typename RateT , int... EventTypes>
void tim::component::papi_rate_tuple< RateT, EventTypes >::start ( )
inline

Definition at line 153 of file papi_rate_tuple.hpp.

154 {
155 value.first.start();
156 value.second.start();
157 }

◆ stop()

template<typename RateT , int... EventTypes>
void tim::component::papi_rate_tuple< RateT, EventTypes >::stop ( )
inline

Definition at line 159 of file papi_rate_tuple.hpp.

160 {
161 value.second.stop();
162 value.first.stop();
163 }

◆ thread_finalize()

template<typename RateT , int... EventTypes>
static void tim::component::papi_rate_tuple< RateT, EventTypes >::thread_finalize ( )
inlinestatic

Definition at line 129 of file papi_rate_tuple.hpp.

130 {
131 /*operation::fini<tuple_type>{}(
132 operation::mode_constant<operation::fini_mode::thread>{});
133 operation::fini<rate_type>{}(
134 operation::mode_constant<operation::fini_mode::thread>{});*/
135 }

◆ thread_init()

template<typename RateT , int... EventTypes>
static void tim::component::papi_rate_tuple< RateT, EventTypes >::thread_init ( )
inlinestatic

Definition at line 122 of file papi_rate_tuple.hpp.

123 {
124 operation::init<tuple_type>{}(
125 operation::mode_constant<operation::init_mode::thread>{});
126 operation::init<rate_type>{}(
127 operation::mode_constant<operation::init_mode::thread>{});
128 }

◆ unit_array()

template<typename RateT , int... EventTypes>
static auto tim::component::papi_rate_tuple< RateT, EventTypes >::unit_array ( )
inlinestatic

Definition at line 216 of file papi_rate_tuple.hpp.

217 {
218 std::array<double, num_events> arr;
219 auto _units = tuple_type::unit_array();
220 for(size_t i = 0; i < _units.size(); ++i)
221 arr.at(i) = _units.at(i);
222 for(auto& itr : _units)
223 itr /= rate_type::unit();
224 return arr;
225 }
static array_t< int64_t > unit_array()
Definition: papi_tuple.hpp:345

References tim::component::papi_tuple< EventTypes >::unit_array().

Friends And Related Function Documentation

◆ impl::storage< this_type, trait::uses_value_storage< this_type, value_type >::value >

template<typename RateT , int... EventTypes>
friend class impl::storage< this_type, trait::uses_value_storage< this_type, value_type >::value >
friend

Definition at line 227 of file papi_rate_tuple.hpp.

◆ operation::record< common_type >

template<typename RateT , int... EventTypes>
friend struct operation::record< common_type >
friend

Definition at line 83 of file papi_rate_tuple.hpp.

◆ operation::set_started< this_type >

template<typename RateT , int... EventTypes>
friend struct operation::set_started< this_type >
friend

Definition at line 83 of file papi_rate_tuple.hpp.

◆ operation::set_stopped< this_type >

template<typename RateT , int... EventTypes>
friend struct operation::set_stopped< this_type >
friend

Definition at line 83 of file papi_rate_tuple.hpp.

◆ operation::start< this_type >

template<typename RateT , int... EventTypes>
friend struct operation::start< this_type >
friend

Definition at line 83 of file papi_rate_tuple.hpp.

◆ operation::stop< this_type >

template<typename RateT , int... EventTypes>
friend struct operation::stop< this_type >
friend

Definition at line 83 of file papi_rate_tuple.hpp.

◆ operator<<

template<typename RateT , int... EventTypes>
std::ostream & operator<< ( std::ostream &  os,
const this_type obj 
)
friend

Definition at line 227 of file papi_rate_tuple.hpp.

228 {
229 // output the metrics
230 auto _value = obj.get();
231 auto _label = this_type::label_array();
232 auto _disp = this_type::display_unit_array();
233 auto _prec = this_type::get_precision();
234 auto _width = this_type::get_width();
235 auto _flags = this_type::get_format_flags();
236
237 for(size_t i = 0; i < _value.size(); ++i)
238 {
239 std::stringstream ss_value;
240 std::stringstream ss_extra;
241 ss_value.setf(_flags);
242 ss_value << std::setw(_width) << std::setprecision(_prec) << _value.at(i);
243 if(!_disp.at(i).empty())
244 {
245 ss_extra << " " << _disp.at(i);
246 }
247 else if(!_label.at(i).empty())
248 {
249 ss_extra << " " << _label.at(i);
250 }
251 os << ss_value.str() << ss_extra.str();
252 if(i + 1 < _value.size())
253 os << ", ";
254 }
255 return os;
256 }
const std::string std::ostream * os

Member Data Documentation

◆ num_events

template<typename RateT , int... EventTypes>
const size_type tim::component::papi_rate_tuple< RateT, EventTypes >::num_events = sizeof...(EventTypes)
static

Definition at line 83 of file papi_rate_tuple.hpp.


The documentation for this struct was generated from the following file: