timemory  3.2.1
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::cpu_roofline< Types > Struct Template Reference

Combines hardware counters and timers and executes the empirical roofline toolkit during application termination to estimate the peak possible performance for the machine. More...

#include "timemory/components/roofline/cpu_roofline.hpp"

+ Collaboration diagram for tim::component::cpu_roofline< Types >:

Public Types

enum class  MODE {
  OP ,
  AI
}
 
using size_type = std::size_t
 
using event_type = std::vector< int >
 
using array_type = std::vector< long long >
 
using data_type = long long *
 
using value_type = std::pair< array_type, double >
 
using this_type = cpu_roofline< Types... >
 
using base_type = base< this_type, value_type >
 
using storage_type = typename base_type::storage_type
 
using record_type = std::function< value_type()>
 
using unit_type = typename trait::units< this_type >::type
 
using display_unit_type = typename trait::units< this_type >::display_type
 
using device_t = device::cpu
 
using count_type = wall_clock
 
using ratio_t = typename count_type::ratio_t
 
using types_tuple = std::tuple< Types... >
 
using ert_data_t = ert::exec_data< count_type >
 
using ert_data_ptr_t = std::shared_ptr< ert_data_t >
 
template<typename Tp >
using ert_config_type = ert::configuration< device_t, Tp, count_type >
 
template<typename Tp >
using ert_counter_type = ert::counter< device_t, Tp, count_type >
 
template<typename Tp >
using ert_executor_type = ert::executor< device_t, Tp, count_type >
 
template<typename Tp >
using ert_callback_type = ert::callback< ert_executor_type< Tp > >
 
using ert_config_t = std::tuple< ert_config_type< Types >... >
 
using ert_counter_t = std::tuple< ert_counter_type< Types >... >
 
using ert_executor_t = std::tuple< ert_executor_type< Types >... >
 
using ert_callback_t = std::tuple< ert_callback_type< Types >... >
 
using iterator = typename array_type::iterator
 
using const_iterator = typename array_type::const_iterator
 
using strvec_t = std::vector< std::string >
 
using intvec_t = std::vector< int >
 
using events_callback_t = std::function< intvec_t(const MODE &)>
 

Public Member Functions

display_unit_type display_unit ()
 
unit_type get_unit ()
 
display_unit_type get_display_unit ()
 
value_type record ()
 
 cpu_roofline ()
 
 ~cpu_roofline ()=default
 
 cpu_roofline (const cpu_roofline &rhs)=default
 
 cpu_roofline (cpu_roofline &&rhs) noexcept=default
 
cpu_rooflineoperator= (const cpu_roofline &)=default
 
cpu_rooflineoperator= (cpu_roofline &&) noexcept=default
 
std::vector< double > get () const
 
void start ()
 
void stop ()
 
this_typeoperator+= (const this_type &rhs)
 
this_typeoperator-= (const this_type &rhs)
 
std::vector< double > get_display () const
 
template<typename Archive >
void load (Archive &ar, const unsigned int)
 
template<typename Archive >
void save (Archive &ar, const unsigned int) const
 
strvec_t label_array () const
 
strvec_t description_array () const
 
strvec_t display_unit_array () const
 
std::vector< int64_t > unit_array () const
 

Static Public Member Functions

static events_callback_tget_events_callback ()
 replace this callback to add in custom HW counters More...
 
static bool & use_predefined_enums ()
 set to false to suppress adding predefined enumerations More...
 
static MODEevent_mode ()
 
static ert_config_tget_finalizer ()
 
static ert_data_ptr_t get_ert_data ()
 
static event_type get_events ()
 
static void configure ()
 
static void global_init ()
 
static void thread_init ()
 
static void thread_finalize ()
 
template<typename Tp , typename FuncT >
static void set_executor_callback (FuncT &&f)
 
static void global_finalize (storage_type *_store)
 
template<typename Archive >
static void extra_serialization (Archive &ar)
 
static std::string get_mode_string ()
 
static std::string get_type_string ()
 
static unit_type unit ()
 
static std::string label ()
 
static std::string description ()
 
static void cleanup ()
 

Static Public Attributes

static const short precision = 3
 
static const short width = 8
 

Friends

struct operation::record< this_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... Types>
struct tim::component::cpu_roofline< Types >

Combines hardware counters and timers and executes the empirical roofline toolkit during application termination to estimate the peak possible performance for the machine.

Template Parameters
TypesVariadic list of data types for roofline analysis

Definition at line 72 of file cpu_roofline.hpp.

Member Typedef Documentation

◆ array_type

template<typename... Types>
using tim::component::cpu_roofline< Types >::array_type = std::vector<long long>

Definition at line 80 of file cpu_roofline.hpp.

◆ base_type

template<typename... Types>
using tim::component::cpu_roofline< Types >::base_type = base<this_type, value_type>

Definition at line 84 of file cpu_roofline.hpp.

◆ const_iterator

template<typename... Types>
using tim::component::cpu_roofline< Types >::const_iterator = typename array_type::const_iterator

Definition at line 126 of file cpu_roofline.hpp.

◆ count_type

template<typename... Types>
using tim::component::cpu_roofline< Types >::count_type = wall_clock

Definition at line 98 of file cpu_roofline.hpp.

◆ data_type

template<typename... Types>
using tim::component::cpu_roofline< Types >::data_type = long long*

Definition at line 81 of file cpu_roofline.hpp.

◆ device_t

template<typename... Types>
using tim::component::cpu_roofline< Types >::device_t = device::cpu

Definition at line 97 of file cpu_roofline.hpp.

◆ display_unit_type

template<typename... Types>
using tim::component::cpu_roofline< Types >::display_unit_type = typename trait::units<this_type>::display_type

Definition at line 95 of file cpu_roofline.hpp.

◆ ert_callback_t

template<typename... Types>
using tim::component::cpu_roofline< Types >::ert_callback_t = std::tuple<ert_callback_type<Types>...>

Definition at line 119 of file cpu_roofline.hpp.

◆ ert_callback_type

template<typename... Types>
template<typename Tp >
using tim::component::cpu_roofline< Types >::ert_callback_type = ert::callback<ert_executor_type<Tp> >

Definition at line 113 of file cpu_roofline.hpp.

◆ ert_config_t

template<typename... Types>
using tim::component::cpu_roofline< Types >::ert_config_t = std::tuple<ert_config_type<Types>...>

Definition at line 116 of file cpu_roofline.hpp.

◆ ert_config_type

template<typename... Types>
template<typename Tp >
using tim::component::cpu_roofline< Types >::ert_config_type = ert::configuration<device_t, Tp, count_type>

Definition at line 107 of file cpu_roofline.hpp.

◆ ert_counter_t

template<typename... Types>
using tim::component::cpu_roofline< Types >::ert_counter_t = std::tuple<ert_counter_type<Types>...>

Definition at line 117 of file cpu_roofline.hpp.

◆ ert_counter_type

template<typename... Types>
template<typename Tp >
using tim::component::cpu_roofline< Types >::ert_counter_type = ert::counter<device_t, Tp, count_type>

Definition at line 109 of file cpu_roofline.hpp.

◆ ert_data_ptr_t

template<typename... Types>
using tim::component::cpu_roofline< Types >::ert_data_ptr_t = std::shared_ptr<ert_data_t>

Definition at line 103 of file cpu_roofline.hpp.

◆ ert_data_t

template<typename... Types>
using tim::component::cpu_roofline< Types >::ert_data_t = ert::exec_data<count_type>

Definition at line 102 of file cpu_roofline.hpp.

◆ ert_executor_t

template<typename... Types>
using tim::component::cpu_roofline< Types >::ert_executor_t = std::tuple<ert_executor_type<Types>...>

Definition at line 118 of file cpu_roofline.hpp.

◆ ert_executor_type

template<typename... Types>
template<typename Tp >
using tim::component::cpu_roofline< Types >::ert_executor_type = ert::executor<device_t, Tp, count_type>

Definition at line 111 of file cpu_roofline.hpp.

◆ event_type

template<typename... Types>
using tim::component::cpu_roofline< Types >::event_type = std::vector<int>

Definition at line 79 of file cpu_roofline.hpp.

◆ events_callback_t

template<typename... Types>
using tim::component::cpu_roofline< Types >::events_callback_t = std::function<intvec_t(const MODE&)>

Definition at line 144 of file cpu_roofline.hpp.

◆ intvec_t

template<typename... Types>
using tim::component::cpu_roofline< Types >::intvec_t = std::vector<int>

Definition at line 143 of file cpu_roofline.hpp.

◆ iterator

template<typename... Types>
using tim::component::cpu_roofline< Types >::iterator = typename array_type::iterator

Definition at line 125 of file cpu_roofline.hpp.

◆ ratio_t

template<typename... Types>
using tim::component::cpu_roofline< Types >::ratio_t = typename count_type::ratio_t

Definition at line 99 of file cpu_roofline.hpp.

◆ record_type

template<typename... Types>
using tim::component::cpu_roofline< Types >::record_type = std::function<value_type()>

Definition at line 86 of file cpu_roofline.hpp.

◆ size_type

template<typename... Types>
using tim::component::cpu_roofline< Types >::size_type = std::size_t

Definition at line 78 of file cpu_roofline.hpp.

◆ storage_type

template<typename... Types>
using tim::component::cpu_roofline< Types >::storage_type = typename base_type::storage_type

Definition at line 85 of file cpu_roofline.hpp.

◆ strvec_t

template<typename... Types>
using tim::component::cpu_roofline< Types >::strvec_t = std::vector<std::string>

Definition at line 142 of file cpu_roofline.hpp.

◆ this_type

template<typename... Types>
using tim::component::cpu_roofline< Types >::this_type = cpu_roofline<Types...>

Definition at line 83 of file cpu_roofline.hpp.

◆ types_tuple

template<typename... Types>
using tim::component::cpu_roofline< Types >::types_tuple = std::tuple<Types...>

Definition at line 100 of file cpu_roofline.hpp.

◆ unit_type

template<typename... Types>
using tim::component::cpu_roofline< Types >::unit_type = typename trait::units<this_type>::type

Definition at line 94 of file cpu_roofline.hpp.

◆ value_type

template<typename... Types>
using tim::component::cpu_roofline< Types >::value_type = std::pair<array_type, double>

Definition at line 82 of file cpu_roofline.hpp.

Member Enumeration Documentation

◆ MODE

template<typename... Types>
enum tim::component::cpu_roofline::MODE
strong
Enumerator
OP 
AI 

Definition at line 134 of file cpu_roofline.hpp.

135  {
136  OP,
137  AI
138  };

Constructor & Destructor Documentation

◆ cpu_roofline() [1/3]

template<typename... Types>
tim::component::cpu_roofline< Types >::cpu_roofline ( )
inline

Definition at line 414 of file cpu_roofline.hpp.

415  : base_type()
416  {
417  configure();
418  m_papi_vector = std::make_shared<papi_vector>();
419  m_wall_clock = std::make_shared<wall_clock>();
420  std::tie(value.second, accum.second) = std::make_pair(0, 0);
421  }
base< this_type, value_type > base_type

References tim::component::cpu_roofline< Types >::configure().

◆ ~cpu_roofline()

template<typename... Types>
tim::component::cpu_roofline< Types >::~cpu_roofline ( )
default

◆ cpu_roofline() [2/3]

template<typename... Types>
tim::component::cpu_roofline< Types >::cpu_roofline ( const cpu_roofline< Types > &  rhs)
default

◆ cpu_roofline() [3/3]

template<typename... Types>
tim::component::cpu_roofline< Types >::cpu_roofline ( cpu_roofline< Types > &&  rhs)
defaultnoexcept

Member Function Documentation

◆ cleanup()

template<typename... Types>
static void tim::component::cpu_roofline< Types >::cleanup ( )
inlinestatic

Definition at line 664 of file cpu_roofline.hpp.

664 {}

◆ configure()

template<typename... Types>
static void tim::component::cpu_roofline< Types >::configure ( )
inlinestatic

Definition at line 269 of file cpu_roofline.hpp.

270  {
271  if(!is_configured())
272  {
273  if(settings::debug() || settings::verbose() > 1)
274  PRINT_HERE("%s", "configuring cpu_roofline");
275 
276  // do this BEFORE setting is_configured to true to ensure mode is updated
277  // properly
278  auto _events = get_events();
279  is_configured() = true;
280  for(auto&& itr : _events)
283  }
284  }
static event_type get_events()
static void add_event(int evt)
#define PRINT_HERE(...)
Definition: macros.hpp:147

References tim::component::papi_common::add_event(), tim::component::papi_vector::configure(), tim::debug, tim::component::cpu_roofline< Types >::get_events(), PRINT_HERE, and tim::verbose.

Referenced by tim::component::cpu_roofline< Types >::cpu_roofline(), tim::component::cpu_roofline< Types >::global_init(), and tim::component::cpu_roofline< Types >::thread_init().

◆ description()

template<typename... Types>
static std::string tim::component::cpu_roofline< Types >::description ( )
inlinestatic

Definition at line 398 of file cpu_roofline.hpp.

399  {
400  return "Model used to provide performance relative to the peak possible "
401  "performance on a CPU architecture.";
402  }

◆ description_array()

template<typename... Types>
strvec_t tim::component::cpu_roofline< Types >::description_array ( ) const
inline

Definition at line 628 of file cpu_roofline.hpp.

629  {
630  strvec_t arr = m_papi_vector->description_array();
631  arr.push_back("Runtime");
632  return arr;
633  }
std::vector< std::string > strvec_t

◆ display_unit()

template<typename... Types>
display_unit_type tim::component::cpu_roofline< Types >::display_unit ( )
inline

Definition at line 367 of file cpu_roofline.hpp.

368  {
369  auto _units = m_papi_vector->display_unit_array();
370  _units.push_back(m_wall_clock->display_unit());
371  return _units;
372  }

Referenced by tim::component::cpu_roofline< Types >::get_display_unit().

◆ display_unit_array()

template<typename... Types>
strvec_t tim::component::cpu_roofline< Types >::display_unit_array ( ) const
inline

Definition at line 637 of file cpu_roofline.hpp.

638  {
639  strvec_t arr = m_papi_vector->display_unit_array();
640  arr.push_back(count_type::get_display_unit());
641  return arr;
642  }

References tim::component::base< wall_clock, int64_t >::get_display_unit().

◆ event_mode()

template<typename... Types>
static MODE& tim::component::cpu_roofline< Types >::event_mode ( )
inlinestatic

Definition at line 164 of file cpu_roofline.hpp.

165  {
166  auto&& _get = []() {
167  auto&& aslc = [](std::string str) {
168  for(auto& itr : str)
169  itr = tolower(itr);
170  return str;
171  };
172  // check the standard variable
174  if(_env.empty())
175  _env = aslc(settings::roofline_mode());
176  auto _val =
177  (_env == "op" || _env == "hw" || _env == "counters")
178  ? MODE::OP
179  : ((_env == "ai" || _env == "ac" || _env == "activity") ? MODE::AI
180  : MODE::OP);
181  if(settings::verbose() > 1 || settings::debug())
182  {
183  std::cerr << "[" << demangle<this_type>()
184  << "]> roofline mode: " << ((_val == MODE::OP) ? "op" : "ai")
185  << std::endl;
186  }
187  return _val;
188  };
189 
190  static MODE _instance = _get();
191  if(!is_configured())
192  _instance = _get();
193  return _instance;
194  }
roofline_mode
Definition: settings.cpp:1426
cpu_roofline_mode
Definition: settings.cpp:1428
tim::mpl::apply< std::string > string
Definition: macros.hpp:52

References tim::component::cpu_roofline< Types >::AI, tim::cpu_roofline_mode, tim::debug, tim::component::cpu_roofline< Types >::OP, tim::roofline_mode, and tim::verbose.

Referenced by tim::component::cpu_roofline< Types >::get_events(), tim::component::cpu_roofline< Types >::get_mode_string(), and tim::component::cpu_roofline< Types >::unit().

◆ extra_serialization()

template<typename... Types>
template<typename Archive >
static void tim::component::cpu_roofline< Types >::extra_serialization ( Archive &  ar)
inlinestatic

Definition at line 336 of file cpu_roofline.hpp.

337  {
338  auto _ert_data = get_ert_data();
339  if(!_ert_data) // for input
340  _ert_data = std::make_shared<ert_data_t>();
341  ar(cereal::make_nvp("roofline", *_ert_data));
342  }
static ert_data_ptr_t get_ert_data()

References tim::component::cpu_roofline< Types >::get_ert_data().

◆ get()

template<typename... Types>
std::vector<double> tim::component::cpu_roofline< Types >::get ( ) const
inline

Definition at line 431 of file cpu_roofline.hpp.

432  {
433  auto _data = m_papi_vector->get();
434  _data.push_back(m_wall_clock->get());
435  return _data;
436  }

Referenced by tim::component::cpu_roofline< Types >::get_display(), and tim::component::cpu_roofline< Types >::save().

◆ get_display()

template<typename... Types>
std::vector<double> tim::component::cpu_roofline< Types >::get_display ( ) const
inline

◆ get_display_unit()

template<typename... Types>
display_unit_type tim::component::cpu_roofline< Types >::get_display_unit ( )
inline

Definition at line 380 of file cpu_roofline.hpp.

380 { return display_unit(); }
display_unit_type display_unit()

References tim::component::cpu_roofline< Types >::display_unit().

◆ get_ert_data()

template<typename... Types>
static ert_data_ptr_t tim::component::cpu_roofline< Types >::get_ert_data ( )
inlinestatic

Definition at line 206 of file cpu_roofline.hpp.

207  {
208  static ert_data_ptr_t _instance = std::make_shared<ert_data_t>();
209  return _instance;
210  }
std::shared_ptr< ert_data_t > ert_data_ptr_t

Referenced by tim::component::cpu_roofline< Types >::extra_serialization(), and tim::component::cpu_roofline< Types >::global_finalize().

◆ get_events()

template<typename... Types>
static event_type tim::component::cpu_roofline< Types >::get_events ( )
inlinestatic

Definition at line 214 of file cpu_roofline.hpp.

215  {
216  static auto _instance = []() {
217  event_type _events;
218  auto _mode = event_mode();
219  if(_mode == MODE::OP)
220  {
221  //
222  // add in user callback events BEFORE presets based on type so that
223  // the user can override the counters being used
224  //
225  auto _extra_events = get_events_callback()(_mode);
226  for(const auto& itr : _extra_events)
227  _events.push_back(itr);
228 
229  //
230  // add some presets based on data types
231  //
233  {
234  if(is_one_of<float, types_tuple>::value)
235  _events.push_back(PAPI_SP_OPS);
236  if(is_one_of<double, types_tuple>::value)
237  _events.push_back(PAPI_DP_OPS);
238  }
239  }
240  else if(_mode == MODE::AI)
241  {
242  //
243  // add the load/store hardware counter
244  //
246  {
247  _events.push_back(PAPI_LD_INS);
248  _events.push_back(PAPI_SR_INS);
249  _events.push_back(PAPI_LST_INS);
250  _events.push_back(PAPI_TOT_INS);
251  }
252  //
253  // add in user callback events AFTER load/store so that load/store
254  // instructions are always counted
255  //
256  auto _extra_events = get_events_callback()(_mode);
257  for(const auto& itr : _extra_events)
258  _events.push_back(itr);
259  }
260 
261  return _events;
262  }();
263 
264  return _instance;
265  }
std::vector< int > event_type
static events_callback_t & get_events_callback()
replace this callback to add in custom HW counters
static bool & use_predefined_enums()
set to false to suppress adding predefined enumerations

References tim::component::cpu_roofline< Types >::AI, tim::component::cpu_roofline< Types >::event_mode(), tim::component::cpu_roofline< Types >::get_events_callback(), tim::component::cpu_roofline< Types >::OP, and tim::component::cpu_roofline< Types >::use_predefined_enums().

Referenced by tim::component::cpu_roofline< Types >::configure().

◆ get_events_callback()

template<typename... Types>
static events_callback_t& tim::component::cpu_roofline< Types >::get_events_callback ( )
inlinestatic

replace this callback to add in custom HW counters

Definition at line 148 of file cpu_roofline.hpp.

149  {
150  static events_callback_t _instance = [](const MODE&) { return intvec_t{}; };
151  return _instance;
152  }
std::function< intvec_t(const MODE &)> events_callback_t
std::vector< int > intvec_t

Referenced by tim::component::cpu_roofline< Types >::get_events().

◆ get_finalizer()

template<typename... Types>
static ert_config_t& tim::component::cpu_roofline< Types >::get_finalizer ( )
inlinestatic

Definition at line 198 of file cpu_roofline.hpp.

199  {
200  static ert_config_t _instance;
201  return _instance;
202  }
std::tuple< ert_config_type< Types >... > ert_config_t

Referenced by tim::component::cpu_roofline< Types >::global_finalize().

◆ get_mode_string()

template<typename... Types>
static std::string tim::component::cpu_roofline< Types >::get_mode_string ( )
inlinestatic

◆ get_type_string()

template<typename... Types>
static std::string tim::component::cpu_roofline< Types >::get_type_string ( )
inlinestatic

Definition at line 353 of file cpu_roofline.hpp.

354  {
355  return mpl::apply<std::string>::join('_', demangle(typeid(Types).name())...);
356  }
std::string demangle(const char *_mangled_name, int *_status=nullptr)
Definition: utility.hpp:166
static string_t join(SepT &&separator, Tuple &&__tup, index_sequence< Idx... >) noexcept
Definition: apply.hpp:409

References tim::demangle(), and tim::mpl::apply< Ret >::join().

Referenced by tim::component::cpu_roofline< Types >::label(), and tim::component::cpu_roofline< Types >::save().

◆ get_unit()

template<typename... Types>
unit_type tim::component::cpu_roofline< Types >::get_unit ( )
inline

Definition at line 376 of file cpu_roofline.hpp.

376 { return unit(); }

References tim::component::cpu_roofline< Types >::unit().

◆ global_finalize()

template<typename... Types>
static void tim::component::cpu_roofline< Types >::global_finalize ( storage_type _store)
inlinestatic

Definition at line 318 of file cpu_roofline.hpp.

319  {
320  // query environment for whether this is part of CI test
321  // auto ci = get_env<bool>("CONTINUOUS_INTEGRATION", false);
322  if(_store && _store->size() > 0)
323  {
324  // run roofline peak generation
325  auto ert_config = get_finalizer();
326  auto ert_data = get_ert_data();
327  mpl::apply<void>::access<ert_executor_t>(ert_config, ert_data);
328  if(ert_data && (settings::verbose() > 1 || settings::debug()))
329  std::cout << *(ert_data) << std::endl;
330  }
331  }
static ert_config_t & get_finalizer()

References tim::debug, tim::component::cpu_roofline< Types >::get_ert_data(), tim::component::cpu_roofline< Types >::get_finalizer(), and tim::verbose.

◆ global_init()

template<typename... Types>
static void tim::component::cpu_roofline< Types >::global_init ( )
inlinestatic

Definition at line 288 of file cpu_roofline.hpp.

289  {
290  if(settings::debug() || settings::verbose() > 2)
291  PRINT_HERE("%s", "global initialization of cpu_roofline");
292  configure();
293  }

References tim::component::cpu_roofline< Types >::configure(), tim::debug, PRINT_HERE, and tim::verbose.

◆ label()

template<typename... Types>
static std::string tim::component::cpu_roofline< Types >::label ( )
inlinestatic

Definition at line 384 of file cpu_roofline.hpp.

385  {
387  {
388  return std::string("cpu_roofline_") + get_type_string() + "_" +
389  get_mode_string();
390  }
391  {
392  return std::string("cpu_roofline_") + get_mode_string();
393  }
394  }
roofline_type_labels
Definition: settings.cpp:1436
roofline_type_labels_cpu
Definition: settings.cpp:1438
static std::string get_type_string()
static std::string get_mode_string()

References tim::component::cpu_roofline< Types >::get_mode_string(), tim::component::cpu_roofline< Types >::get_type_string(), tim::roofline_type_labels, and tim::roofline_type_labels_cpu.

◆ label_array()

template<typename... Types>
strvec_t tim::component::cpu_roofline< Types >::label_array ( ) const
inline

Definition at line 618 of file cpu_roofline.hpp.

619  {
620  strvec_t arr = m_papi_vector->label_array();
621  arr.push_back("Runtime");
622  return arr;
623  }

Referenced by tim::component::cpu_roofline< Types >::load(), and tim::component::cpu_roofline< Types >::save().

◆ load()

template<typename... Types>
template<typename Archive >
void tim::component::cpu_roofline< Types >::load ( Archive &  ar,
const unsigned int   
)
inline

Definition at line 575 of file cpu_roofline.hpp.

576  {
577  auto _disp = get_display();
578  auto labels = label_array();
579 
580  ar(cereal::make_nvp("laps", laps), cereal::make_nvp("labels", labels),
581  cereal::make_nvp("papi_vector", m_papi_vector));
582  ar(cereal::make_nvp("value", value));
583  ar(cereal::make_nvp("accum", accum));
584  }
std::vector< double > get_display() const

References tim::component::cpu_roofline< Types >::get_display(), tim::component::cpu_roofline< Types >::label_array(), and tim::component::base< cpu_roofline< Types... >, std::pair< std::vector< long long >, double > >::laps.

◆ operator+=()

template<typename... Types>
this_type& tim::component::cpu_roofline< Types >::operator+= ( const this_type rhs)
inline

Definition at line 459 of file cpu_roofline.hpp.

460  {
461  if(rhs.value.first.size() > value.first.size())
462  value.first.resize(rhs.value.first.size());
463  if(rhs.accum.first.size() > accum.first.size())
464  accum.first.resize(rhs.accum.first.size());
465  value += rhs.value;
466  accum += rhs.accum;
467  return *this;
468  }

◆ operator-=()

template<typename... Types>
this_type& tim::component::cpu_roofline< Types >::operator-= ( const this_type rhs)
inline

Definition at line 472 of file cpu_roofline.hpp.

473  {
474  if(rhs.value.first.size() > value.first.size())
475  value.first.resize(rhs.value.first.size());
476  if(rhs.accum.first.size() > accum.first.size())
477  accum.first.resize(rhs.accum.first.size());
478  value -= rhs.value;
479  accum -= rhs.accum;
480  return *this;
481  }

◆ operator=() [1/2]

template<typename... Types>
cpu_roofline& tim::component::cpu_roofline< Types >::operator= ( const cpu_roofline< Types > &  )
default

◆ operator=() [2/2]

template<typename... Types>
cpu_roofline& tim::component::cpu_roofline< Types >::operator= ( cpu_roofline< Types > &&  )
defaultnoexcept

◆ record()

template<typename... Types>
value_type tim::component::cpu_roofline< Types >::record ( )
inline

Definition at line 406 of file cpu_roofline.hpp.

407  {
408  auto hwcount = m_papi_vector->record();
409  auto duration = m_wall_clock->record();
410  return value_type(hwcount, duration);
411  }
std::pair< array_type, double > value_type

◆ save()

template<typename... Types>
template<typename Archive >
void tim::component::cpu_roofline< Types >::save ( Archive &  ar,
const unsigned int   
) const
inline

Definition at line 589 of file cpu_roofline.hpp.

590  {
591  auto _disp = get_display();
592  auto labels = label_array();
593 
594  ar(cereal::make_nvp("laps", laps), cereal::make_nvp("display", _disp),
595  cereal::make_nvp("mode", get_mode_string()),
596  cereal::make_nvp("type", get_type_string()),
597  cereal::make_nvp("labels", labels),
598  cereal::make_nvp("papi_vector", m_papi_vector));
599 
600  auto data = get();
601  ar.setNextName("repr_data");
602  ar.startNode();
603  auto litr = labels.begin();
604  auto ditr = data.begin();
605  for(; litr != labels.end() && ditr != data.end(); ++litr, ++ditr)
606  ar(cereal::make_nvp(*litr, double(*ditr)));
607  ar.finishNode();
608 
609  ar(cereal::make_nvp("value", value));
610  ar(cereal::make_nvp("accum", accum));
611  // ar(cereal::make_nvp("units", unit_array()));
612  // ar(cereal::make_nvp("display_units", display_unit_array()));
613  }

References tim::component::cpu_roofline< Types >::get(), tim::component::cpu_roofline< Types >::get_display(), tim::component::cpu_roofline< Types >::get_mode_string(), tim::component::cpu_roofline< Types >::get_type_string(), tim::component::cpu_roofline< Types >::label_array(), and tim::component::base< cpu_roofline< Types... >, std::pair< std::vector< long long >, double > >::laps.

◆ set_executor_callback()

template<typename... Types>
template<typename Tp , typename FuncT >
static void tim::component::cpu_roofline< Types >::set_executor_callback ( FuncT &&  f)
inlinestatic

Definition at line 311 of file cpu_roofline.hpp.

312  {
313  ert_executor_type<Tp>::get_callback() = std::forward<FuncT>(f);
314  }
static callback_type & get_callback()

References tim::ert::executor< DeviceT, Tp, CounterT >::get_callback().

◆ start()

template<typename... Types>
void tim::component::cpu_roofline< Types >::start ( )
inline

Definition at line 440 of file cpu_roofline.hpp.

441  {
442  m_wall_clock->start();
443  m_papi_vector->start();
444  value = value_type{ m_papi_vector->get_value(), m_wall_clock->get_value() };
445  }

◆ stop()

template<typename... Types>
void tim::component::cpu_roofline< Types >::stop ( )
inline

Definition at line 449 of file cpu_roofline.hpp.

450  {
451  m_papi_vector->stop();
452  m_wall_clock->stop();
453  value = value_type{ m_papi_vector->get_value(), m_wall_clock->get_value() };
454  accum += value_type{ m_papi_vector->get_accum(), m_wall_clock->get_accum() };
455  }

◆ thread_finalize()

template<typename... Types>
static void tim::component::cpu_roofline< Types >::thread_finalize ( )
inlinestatic

Definition at line 306 of file cpu_roofline.hpp.

306 {}

◆ thread_init()

template<typename... Types>
static void tim::component::cpu_roofline< Types >::thread_init ( )
inlinestatic

Definition at line 297 of file cpu_roofline.hpp.

298  {
299  if(settings::debug() || settings::verbose() > 2)
300  PRINT_HERE("%s", "thread initialization of cpu_roofline");
301  configure();
302  }

References tim::component::cpu_roofline< Types >::configure(), tim::debug, PRINT_HERE, and tim::verbose.

◆ unit()

◆ unit_array()

template<typename... Types>
std::vector<int64_t> tim::component::cpu_roofline< Types >::unit_array ( ) const
inline

Definition at line 647 of file cpu_roofline.hpp.

648  {
649  auto arr = m_papi_vector->unit_array();
650  arr.push_back(count_type::get_unit());
651  return arr;
652  }

References tim::component::base< wall_clock, int64_t >::get_unit().

◆ use_predefined_enums()

template<typename... Types>
static bool& tim::component::cpu_roofline< Types >::use_predefined_enums ( )
inlinestatic

set to false to suppress adding predefined enumerations

Definition at line 156 of file cpu_roofline.hpp.

157  {
158  static bool _instance = true;
159  return _instance;
160  }

Referenced by tim::component::cpu_roofline< Types >::get_events().

Friends And Related Function Documentation

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

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

Definition at line 472 of file cpu_roofline.hpp.

◆ operation::record< this_type >

template<typename... Types>
friend struct operation::record< this_type >
friend

Definition at line 75 of file cpu_roofline.hpp.

◆ operation::set_started< this_type >

template<typename... Types>
friend struct operation::set_started< this_type >
friend

Definition at line 75 of file cpu_roofline.hpp.

◆ operation::set_stopped< this_type >

template<typename... Types>
friend struct operation::set_stopped< this_type >
friend

Definition at line 75 of file cpu_roofline.hpp.

◆ operation::start< this_type >

template<typename... Types>
friend struct operation::start< this_type >
friend

Definition at line 75 of file cpu_roofline.hpp.

◆ operation::stop< this_type >

template<typename... Types>
friend struct operation::stop< this_type >
friend

Definition at line 75 of file cpu_roofline.hpp.

◆ operator<<

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

Definition at line 507 of file cpu_roofline.hpp.

508  {
509  using namespace tim::stl::ostream;
510 
511  // output the time
512  auto& _obj = obj.load();
513  std::stringstream sst;
514  auto t_value = _obj.second;
515  auto t_label = count_type::get_label();
516  auto t_disp = count_type::get_display_unit();
517  auto t_prec = count_type::get_precision();
518  auto t_width = count_type::get_width();
519  auto t_flags = count_type::get_format_flags();
520 
521  sst.setf(t_flags);
522  sst << std::setw(t_width) << std::setprecision(t_prec) << t_value;
523  if(!t_disp.empty())
524  sst << " " << t_disp;
525  if(!t_label.empty())
526  sst << " " << t_label;
527  sst << ", ";
528 
529  auto _prec = count_type::get_precision();
530  auto _width = this_type::get_width();
531  auto _flags = count_type::get_format_flags();
532 
533  // output the roofline metric
534  auto _value = obj.get();
535  auto _label = obj.label_array();
536  auto _disp = obj.display_unit_array();
537 
538 #if defined(DEBUG)
539  if(settings::debug())
540  {
541  std::cout << "value: " << _value << std::endl;
542  std::cout << "label: " << _label << std::endl;
543  std::cout << "displ: " << _disp << std::endl;
544  }
545 #endif
546  assert(_value.size() <= _label.size());
547  assert(_value.size() <= _disp.size());
548 
549  auto n = _label.size();
550  for(size_t i = 0; i < n; ++i)
551  {
552  std::stringstream ss_value;
553  std::stringstream ss_extra;
554  ss_value.setf(_flags);
555  ss_value << std::setw(_width) << std::setprecision(_prec) << _value.at(i);
556  if(!_disp.at(i).empty())
557  {
558  ss_extra << " " << _disp.at(i);
559  }
560  else if(!_label.at(i).empty())
561  {
562  ss_extra << " " << _label.at(i);
563  }
564  os << sst.str() << ss_value.str() << ss_extra.str();
565  if(i + 1 < n)
566  os << ", ";
567  }
568 
569  return os;
570  }
the namespace provides overloads to output complex data types w/ streams
Definition: stl.hpp:68

Member Data Documentation

◆ precision

template<typename... Types>
const short tim::component::cpu_roofline< Types >::precision = 3
static

Definition at line 128 of file cpu_roofline.hpp.

◆ width

template<typename... Types>
const short tim::component::cpu_roofline< Types >::width = 8
static

Definition at line 129 of file cpu_roofline.hpp.


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