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::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 ()
 
template<typename... Args>
static opaque get_opaque (Args &&...)
 

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 70 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 78 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 82 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 124 of file cpu_roofline.hpp.

◆ count_type

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

Definition at line 96 of file cpu_roofline.hpp.

◆ data_type

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

Definition at line 79 of file cpu_roofline.hpp.

◆ device_t

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

Definition at line 95 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 93 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 117 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 111 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 114 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 105 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 115 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 107 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 101 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 100 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 116 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 109 of file cpu_roofline.hpp.

◆ event_type

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

Definition at line 77 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 142 of file cpu_roofline.hpp.

◆ intvec_t

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

Definition at line 141 of file cpu_roofline.hpp.

◆ iterator

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

Definition at line 123 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 97 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 84 of file cpu_roofline.hpp.

◆ size_type

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

Definition at line 76 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 83 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 140 of file cpu_roofline.hpp.

◆ this_type

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

Definition at line 81 of file cpu_roofline.hpp.

◆ types_tuple

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

Definition at line 98 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 92 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 80 of file cpu_roofline.hpp.

Member Enumeration Documentation

◆ MODE

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

Definition at line 132 of file cpu_roofline.hpp.

133 {
134 OP,
135 AI
136 };

Constructor & Destructor Documentation

◆ cpu_roofline() [1/3]

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

Definition at line 412 of file cpu_roofline.hpp.

413 : base_type()
414 {
415 configure();
416 m_papi_vector = std::make_shared<papi_vector>();
417 m_wall_clock = std::make_shared<wall_clock>();
418 std::tie(value.second, accum.second) = std::make_pair(0, 0);
419 }
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 662 of file cpu_roofline.hpp.

662{}

◆ configure()

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

Definition at line 267 of file cpu_roofline.hpp.

268 {
269 if(!is_configured())
270 {
272 PRINT_HERE("%s", "configuring cpu_roofline");
273
274 // do this BEFORE setting is_configured to true to ensure mode is updated
275 // properly
276 auto _events = get_events();
277 is_configured() = true;
278 for(auto&& itr : _events)
281 }
282 }
static event_type get_events()
static void add_event(int evt)
#define PRINT_HERE(...)
Definition: macros.hpp:152

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 396 of file cpu_roofline.hpp.

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

◆ description_array()

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

Definition at line 626 of file cpu_roofline.hpp.

627 {
628 strvec_t arr = m_papi_vector->description_array();
629 arr.push_back("Runtime");
630 return arr;
631 }
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 365 of file cpu_roofline.hpp.

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

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 635 of file cpu_roofline.hpp.

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

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 162 of file cpu_roofline.hpp.

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

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 334 of file cpu_roofline.hpp.

335 {
336 auto _ert_data = get_ert_data();
337 if(!_ert_data) // for input
338 _ert_data = std::make_shared<ert_data_t>();
339 ar(cereal::make_nvp("roofline", *_ert_data));
340 }
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 429 of file cpu_roofline.hpp.

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

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 378 of file cpu_roofline.hpp.

378{ 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 204 of file cpu_roofline.hpp.

205 {
206 static ert_data_ptr_t _instance = std::make_shared<ert_data_t>();
207 return _instance;
208 }
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 212 of file cpu_roofline.hpp.

213 {
214 static auto _instance = []() {
215 event_type _events;
216 auto _mode = event_mode();
217 if(_mode == MODE::OP)
218 {
219 //
220 // add in user callback events BEFORE presets based on type so that
221 // the user can override the counters being used
222 //
223 auto _extra_events = get_events_callback()(_mode);
224 for(const auto& itr : _extra_events)
225 _events.push_back(itr);
226
227 //
228 // add some presets based on data types
229 //
231 {
232 if(is_one_of<float, types_tuple>::value)
233 _events.push_back(PAPI_SP_OPS);
234 if(is_one_of<double, types_tuple>::value)
235 _events.push_back(PAPI_DP_OPS);
236 }
237 }
238 else if(_mode == MODE::AI)
239 {
240 //
241 // add the load/store hardware counter
242 //
244 {
245 _events.push_back(PAPI_LD_INS);
246 _events.push_back(PAPI_SR_INS);
247 _events.push_back(PAPI_LST_INS);
248 _events.push_back(PAPI_TOT_INS);
249 }
250 //
251 // add in user callback events AFTER load/store so that load/store
252 // instructions are always counted
253 //
254 auto _extra_events = get_events_callback()(_mode);
255 for(const auto& itr : _extra_events)
256 _events.push_back(itr);
257 }
258
259 return _events;
260 }();
261
262 return _instance;
263 }
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 146 of file cpu_roofline.hpp.

147 {
148 static events_callback_t _instance = [](const MODE&) { return intvec_t{}; };
149 return _instance;
150 }
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 196 of file cpu_roofline.hpp.

197 {
198 static ert_config_t _instance;
199 return _instance;
200 }
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_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 }

◆ get_type_string()

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

Definition at line 351 of file cpu_roofline.hpp.

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

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 374 of file cpu_roofline.hpp.

374{ 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 316 of file cpu_roofline.hpp.

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

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

◆ global_init()

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

Definition at line 286 of file cpu_roofline.hpp.

287 {
289 PRINT_HERE("%s", "global initialization of cpu_roofline");
290 configure();
291 }

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 382 of file cpu_roofline.hpp.

383 {
385 {
386 return std::string("cpu_roofline_") + get_type_string() + "_" +
388 }
389 {
390 return std::string("cpu_roofline_") + get_mode_string();
391 }
392 }
roofline_type_labels
Definition: settings.cpp:1742
roofline_type_labels_cpu
Definition: settings.cpp:1744
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 616 of file cpu_roofline.hpp.

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

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 573 of file cpu_roofline.hpp.

574 {
575 auto _disp = get_display();
576 auto labels = label_array();
577
578 ar(cereal::make_nvp("laps", laps), cereal::make_nvp("labels", labels),
579 cereal::make_nvp("papi_vector", m_papi_vector));
580 ar(cereal::make_nvp("value", value));
581 ar(cereal::make_nvp("accum", accum));
582 }
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 457 of file cpu_roofline.hpp.

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

◆ operator-=()

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

Definition at line 470 of file cpu_roofline.hpp.

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

◆ 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 404 of file cpu_roofline.hpp.

405 {
406 auto hwcount = m_papi_vector->record();
407 auto duration = m_wall_clock->record();
408 return value_type(hwcount, duration);
409 }
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 587 of file cpu_roofline.hpp.

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

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 309 of file cpu_roofline.hpp.

310 {
311 ert_executor_type<Tp>::get_callback() = std::forward<FuncT>(f);
312 }
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 438 of file cpu_roofline.hpp.

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

◆ stop()

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

Definition at line 447 of file cpu_roofline.hpp.

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

◆ thread_finalize()

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

Definition at line 304 of file cpu_roofline.hpp.

304{}

◆ thread_init()

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

Definition at line 295 of file cpu_roofline.hpp.

296 {
298 PRINT_HERE("%s", "thread initialization of cpu_roofline");
299 configure();
300 }

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 645 of file cpu_roofline.hpp.

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

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 154 of file cpu_roofline.hpp.

155 {
156 static bool _instance = true;
157 return _instance;
158 }

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 470 of file cpu_roofline.hpp.

◆ operation::record< this_type >

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

Definition at line 73 of file cpu_roofline.hpp.

◆ operation::set_started< this_type >

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

Definition at line 73 of file cpu_roofline.hpp.

◆ operation::set_stopped< this_type >

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

Definition at line 73 of file cpu_roofline.hpp.

◆ operation::start< this_type >

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

Definition at line 73 of file cpu_roofline.hpp.

◆ operation::stop< this_type >

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

Definition at line 73 of file cpu_roofline.hpp.

◆ operator<<

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

Definition at line 505 of file cpu_roofline.hpp.

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

Member Data Documentation

◆ precision

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

Definition at line 126 of file cpu_roofline.hpp.

◆ width

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

Definition at line 127 of file cpu_roofline.hpp.


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