28#include "timemory/components/papi/backends.hpp"
64template <
int... EventTypes>
66:
public base<papi_tuple<EventTypes...>, std::array<long long, sizeof...(EventTypes)>>
71 using value_type = std::array<
long long,
sizeof...(EventTypes)>;
80 template <
typename Tp>
81 using array_t = std::array<Tp, num_events>;
94 if(!is_configured<common_type>())
96 papi_common::get_initializer<common_type>() = []() {
97 return std::vector<int>({ EventTypes... });
99 papi_common::get_events<common_type>() = { EventTypes... };
100 papi_common::initialize<common_type>();
106 papi_common::finalize<common_type>();
110 static void finalize() { papi_common::finalize<common_type>(); }
116 if(is_configured<common_type>())
117 tim::papi::read(event_set<common_type>(), get_read_values().
data());
118 return get_read_values();
124 static thread_local value_type _instance = []() {
133 using base_type::accum;
137 using base_type::value;
141 trait::uses_value_storage<this_type, value_type>::value>;
150 TIMEMORY_DEFAULT_OBJECT(papi_tuple)
159 if(tracker_type::get_thread_started() == 0)
162 events = get_events<common_type>();
173 if(tracker_type::get_thread_started() == 0 ||
events.size() == 0)
176 events = get_events<common_type>();
190 value = (
record() - value);
200 accum[i] += rhs.accum[i];
202 value[i] += rhs.value[i];
209 accum[i] -= rhs.accum[i];
211 value[i] -= rhs.value[i];
227 return "papi" + std::to_string(event_set<common_type>());
231 static int64_t
unit() {
return 1; }
236 template <
typename Archive>
245 _value[i] = value[i];
246 _accum[i] = accum[i];
248 ar(cereal::make_nvp(
"laps",
laps), cereal::make_nvp(
"repr_data", _disp),
249 cereal::make_nvp(
"value", _value), cereal::make_nvp(
"accum", _accum),
250 cereal::make_nvp(
"display", _disp));
258 auto _get_display = [&](std::ostream&
os,
size_type idx) {
259 auto _obj_value = val[idx];
260 auto _evt_type = std::vector<int>({ EventTypes... }).
at(idx);
261 string_t _label = papi::get_event_info(_evt_type).short_descr;
262 string_t _disp = papi::get_event_info(_evt_type).units;
267 std::stringstream ss;
268 std::stringstream ssv;
269 std::stringstream ssi;
271 ssv << std::setw(_width) << std::setprecision(_prec) << _obj_value;
276 else if(!_label.empty())
278 ssi <<
" " << _label;
280 ss << ssv.str() << ssi.str();
283 std::stringstream ss;
293 template <
typename Lhs,
typename Rhs,
size_t N,
size_t... Idx>
294 static void convert(std::array<Lhs, N>& lhs,
const std::array<Rhs, N>& rhs,
295 std::index_sequence<Idx...>)
298 static_cast<Lhs
>(std::get<Idx>(rhs)));
300 template <
typename Tp =
double>
303 std::array<Tp, num_events> values;
304 auto& _data =
load();
305 convert(values, _data, std::make_index_sequence<num_events>{});
316 arr[i] = papi::get_event_info(get_events<common_type>().
at(i)).short_descr;
327 arr[i] = papi::get_event_info(get_events<common_type>().
at(i)).long_descr;
338 arr[i] = papi::get_event_info(get_events<common_type>().
at(i)).units;
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()
void set_stopped()
store that stop has been called
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.
static common_data & data()
typename value_type::value_type entry_type
std::array< Tp, N > array_t
static bool finalize_papi()
vector_t< long long > value_type
This component is useful for bundling together a fixed set of hardware counter identifiers which requ...
std::array< long long, sizeof...(EventTypes)> value_type
papi_tuple< EventTypes... > this_type
static std::string label()
static void convert(std::array< Lhs, N > &lhs, const std::array< Rhs, N > &rhs, std::index_sequence< Idx... >)
static void thread_init()
entry_type get_display(int evt_type) const
static array_t< std::string > description_array()
static value_type record()
void serialize(Archive &ar, const unsigned int)
static const short precision
static array_t< std::string > display_unit_array()
this_type & operator-=(const this_type &rhs)
this_type & operator+=(const this_type &rhs)
static std::string description()
static array_t< std::string > label_array()
static const size_type num_events
string_t get_display() const
static std::string display_unit()
static void thread_finalize()
static array_t< int64_t > unit_array()
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...
#define TIMEMORY_FOLD_EXPRESSION(...)