28#include "timemory/components/papi/backends.hpp"
46template <
size_t MaxNumEvents>
48:
public base<papi_array<MaxNumEvents>, std::array<long long, MaxNumEvents>>
66 template <
typename Tp>
67 using array_t = std::array<Tp, MaxNumEvents>;
77 static auto&
get_initializer() {
return papi_common::get_initializer<common_type>(); }
80 if(!is_configured<common_type>())
81 papi_common::initialize<common_type>();
86 papi_common::finalize<common_type>();
89 static void finalize() { papi_common::finalize<common_type>(); }
112 if(is_configured<common_type>())
113 papi::read(event_set<common_type>(), read_value.data());
119 template <
typename Tp =
double>
120 std::vector<Tp>
get()
const
122 std::vector<Tp> values;
123 auto& _data =
load();
124 values.reserve(_data.size());
125 for(
auto& itr : _data)
126 values.emplace_back(itr);
127 values.resize(
events.size());
136 if(tracker_type::get_thread_started() == 0)
139 events = get_events<common_type>();
150 if(tracker_type::get_thread_started() == 0 ||
events.size() == 0)
153 events = get_events<common_type>();
164 value = (
record() - value);
173 accum[i] += rhs.accum[i];
175 value[i] += rhs.value[i];
184 accum[i] -= rhs.accum[i];
186 value[i] -= rhs.value[i];
204 using base_type::accum;
208 using base_type::value;
213 trait::uses_value_storage<this_type, value_type>::value>;
224 return "papi_array" + std::to_string((event_set<common_type>() < 0)
226 : event_set<common_type>());
233 return accum.at(evt_type);
239 template <
typename Archive>
240 void load(Archive& ar,
const unsigned int)
242 ar(cereal::make_nvp(
"laps",
laps), cereal::make_nvp(
"value", value),
243 cereal::make_nvp(
"accum", accum), cereal::make_nvp(
"events",
events));
249 template <
typename Archive>
250 void save(Archive& ar,
const unsigned int)
const
255 ar(cereal::make_nvp(
"laps",
laps), cereal::make_nvp(
"repr_data", _disp),
256 cereal::make_nvp(
"value", value), cereal::make_nvp(
"accum", accum),
257 cereal::make_nvp(
"display", _disp), cereal::make_nvp(
"events",
events));
265 std::vector<std::string> arr(
events.size());
267 arr[i] = papi::get_event_info(
events[i]).short_descr;
271 size_t n = std::string::npos;
272 while((n = itr.find(
"L/S")) != std::string::npos)
273 itr.replace(n, 3,
"Loads_Stores");
278 size_t n = std::string::npos;
279 while((n = itr.find(
'/')) != std::string::npos)
280 itr.replace(n, 1,
"_per_");
285 size_t n = std::string::npos;
286 while((n = itr.find(
' ')) != std::string::npos)
287 itr.replace(n, 1,
"_");
289 while((n = itr.find(
"__")) != std::string::npos)
290 itr.replace(n, 2,
"_");
301 std::vector<std::string> arr(
events.size());
303 arr[i] = papi::get_event_info(
events[i]).long_descr;
312 std::vector<std::string> arr(
events.size());
314 arr[i] = papi::get_event_info(
events[i]).units;
323 std::vector<int64_t> arr(
events.size());
336 auto _get_display = [&](std::ostream&
os,
size_type idx) {
337 auto _obj_value = val[idx];
338 auto _evt_type =
events[idx];
339 string_t _label = papi::get_event_info(_evt_type).short_descr;
340 string_t _disp = papi::get_event_info(_evt_type).units;
345 std::stringstream ss;
346 std::stringstream ssv;
347 std::stringstream ssi;
349 ssv << std::setw(_width) << std::setprecision(_prec) << _obj_value;
353 ssi <<
" " << _label;
354 ss << ssv.str() << ssi.str();
358 std::stringstream ss;
372 if(obj.
events.size() == 0)
382 std::stringstream ss_value;
383 std::stringstream ss_extra;
384 ss_value.setf(_flags);
385 ss_value << std::setw(_width) << std::setprecision(_prec) << _value;
388 ss_extra <<
" " << _disp;
390 else if(!_label.empty())
392 ss_extra <<
" " << _label;
394 os << ss_value.str() << ss_extra.str();
Declare the papi component types.
void stop(TupleT< Tp... > &obj, Args &&... args)
void start(TupleT< Tp... > &obj, Args &&... args)
Inherit from this policy to add reference counting support. Useful if you want to turn a global setti...
tim::mpl::apply< std::string > string
const std::string std::ostream * os
static short get_precision()
static std::string get_label()
void set_stopped()
store that stop has been called
static std::string display_unit()
static fmtflags get_format_flags()
storage< Tp, Value > storage_type
void set_started()
store that start has been called
A very lightweight storage class which provides nothing.
this_type & operator-=(const this_type &rhs)
std::function< event_list()> get_initializer_t
friend std::ostream & operator<<(std::ostream &os, const this_type &obj)
std::vector< std::string > label_array() const
static std::string label()
std::array< long long, MaxNumEvents > value_type
this_type & operator+=(const this_type &rhs)
string_t get_display() const
std::vector< std::string > display_unit_array() const
std::vector< int64_t > unit_array() const
papi_array(papi_array &&) noexcept=default
std::vector< Tp > get() const
typename value_type::value_type entry_type
std::vector< std::string > description_array() const
std::array< Tp, MaxNumEvents > array_t
this_type & operator/=(size_t _val)
static std::string description()
static const short precision
void save(Archive &ar, const unsigned int) const
entry_type get_display(int evt_type) const
void load(Archive &ar, const unsigned int)
std::vector< int > event_list
papi_array(const papi_array &)=default
static value_type record()
papi_array< MaxNumEvents > this_type
static void thread_finalize()
static auto & get_initializer()
static bool finalize_papi()
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 the component provides to internally store wh...