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::ert::executor< DeviceT, Tp, CounterT > Struct Template Reference

#include "timemory/ert/configuration.hpp"

+ Collaboration diagram for tim::ert::executor< DeviceT, Tp, CounterT >:

Public Types

using device_type = DeviceT
 
using value_type = Tp
 
using configuration_type = configuration< device_type, value_type, CounterT >
 
using counter_type = counter< device_type, value_type, CounterT >
 
using this_type = executor< device_type, value_type, CounterT >
 
using callback_type = std::function< void(counter_type &)>
 
using ert_data_t = exec_data< CounterT >
 

Public Member Functions

 executor (configuration_type &config, std::shared_ptr< ert_data_t > _data)
 
template<typename FuncT >
 executor (configuration_type &config, std::shared_ptr< ert_data_t > _data, FuncT &&_counter_callback)
 
template<typename FuncT = std::function<void(uint64_t, counter_type&)>>
auto operator() (configuration_type &config, std::shared_ptr< ert_data_t > _data={}, FuncT &&_counter_callback=FuncT{})
 

Static Public Member Functions

static callback_typeget_callback ()
 
static void execute (counter_type &_counter)
 
template<size_t... Flops, enable_if_t<(sizeof...(Flops) > 0)> = 0>
static bool execute (counter_type &_counter, std::array< std::string, sizeof...(Flops)> _labels)
 

Public Attributes

callback_type callback = get_callback()
 

Detailed Description

template<typename DeviceT, typename Tp, typename CounterT>
struct tim::ert::executor< DeviceT, Tp, CounterT >

Definition at line 281 of file configuration.hpp.

Member Typedef Documentation

◆ callback_type

template<typename DeviceT , typename Tp , typename CounterT >
using tim::ert::executor< DeviceT, Tp, CounterT >::callback_type = std::function<void(counter_type&)>

Definition at line 294 of file configuration.hpp.

◆ configuration_type

template<typename DeviceT , typename Tp , typename CounterT >
using tim::ert::executor< DeviceT, Tp, CounterT >::configuration_type = configuration<device_type, value_type, CounterT>

Definition at line 291 of file configuration.hpp.

◆ counter_type

template<typename DeviceT , typename Tp , typename CounterT >
using tim::ert::executor< DeviceT, Tp, CounterT >::counter_type = counter<device_type, value_type, CounterT>

Definition at line 292 of file configuration.hpp.

◆ device_type

template<typename DeviceT , typename Tp , typename CounterT >
using tim::ert::executor< DeviceT, Tp, CounterT >::device_type = DeviceT

Definition at line 289 of file configuration.hpp.

◆ ert_data_t

template<typename DeviceT , typename Tp , typename CounterT >
using tim::ert::executor< DeviceT, Tp, CounterT >::ert_data_t = exec_data<CounterT>

Definition at line 295 of file configuration.hpp.

◆ this_type

template<typename DeviceT , typename Tp , typename CounterT >
using tim::ert::executor< DeviceT, Tp, CounterT >::this_type = executor<device_type, value_type, CounterT>

Definition at line 293 of file configuration.hpp.

◆ value_type

template<typename DeviceT , typename Tp , typename CounterT >
using tim::ert::executor< DeviceT, Tp, CounterT >::value_type = Tp

Definition at line 290 of file configuration.hpp.

Constructor & Destructor Documentation

◆ executor() [1/2]

template<typename DeviceT , typename Tp , typename CounterT >
tim::ert::executor< DeviceT, Tp, CounterT >::executor ( configuration_type config,
std::shared_ptr< ert_data_t _data 
)
inline

Definition at line 303 of file configuration.hpp.

304 {
305 (*this)(config, _data);
306 }

◆ executor() [2/2]

template<typename DeviceT , typename Tp , typename CounterT >
template<typename FuncT >
tim::ert::executor< DeviceT, Tp, CounterT >::executor ( configuration_type config,
std::shared_ptr< ert_data_t _data,
FuncT &&  _counter_callback 
)
inline

Definition at line 312 of file configuration.hpp.

314 {
315 (*this)(config, _data, std::forward<FuncT>(_counter_callback));
316 }

Member Function Documentation

◆ execute() [1/2]

template<typename DeviceT , typename Tp , typename CounterT >
static void tim::ert::executor< DeviceT, Tp, CounterT >::execute ( counter_type _counter)
inlinestatic

Definition at line 361 of file configuration.hpp.

362 {
363 // vectorization number of ops
364 static constexpr const int SIZE_BITS = sizeof(Tp) * 8;
365 static_assert(SIZE_BITS > 0, "Calculated bits size is not greater than zero");
366 static constexpr const int VEC = TIMEMORY_VEC / SIZE_BITS;
367 static_assert(VEC > 0, "Calculated vector size is zero");
368
369 // functions
370 auto store_func = [](Tp& a, const Tp& b) { a = b; };
371 auto add_func = [](Tp& a, const Tp& b, const Tp& c) { a = b + c; };
372 auto fma_func = [](Tp& a, const Tp& b, const Tp& c) { a = a * b + c; };
373
374 // set bytes per element
375 _counter.bytes_per_element = sizeof(Tp);
376 // set number of memory accesses per element from two functions
377 _counter.memory_accesses_per_element = 2;
378
379 // set the label
380 _counter.label = "scalar_add";
381 // run the kernels
382 ops_main<1>(_counter, add_func, store_func);
383
384 // set the label
385 _counter.label = "vector_fma";
386 // run the kernels
387 if(!ops_main<TIMEMORY_USER_ERT_FLOPS>(_counter, fma_func, store_func))
388 ops_main<VEC / 2, VEC, 2 * VEC, 4 * VEC>(_counter, fma_func, store_func);
389 }
#define TIMEMORY_VEC
bool ops_main(counter< DeviceT, Tp, CounterT > &_counter, OpsFuncT &&ops_func, StoreFuncT &&store_func)
This is the "main" function for ERT.
Definition: kernels.hpp:159

References tim::ert::counter< DeviceT, Tp, Counter >::bytes_per_element, tim::ert::counter< DeviceT, Tp, Counter >::label, tim::ert::counter< DeviceT, Tp, Counter >::memory_accesses_per_element, tim::ert::ops_main(), and TIMEMORY_VEC.

Referenced by tim::ert::executor< DeviceT, Tp, CounterT >::get_callback(), and tim::ert::executor< device::gpu, Tp, CounterT >::get_callback().

◆ execute() [2/2]

template<typename DeviceT , typename Tp , typename CounterT >
template<size_t... Flops, enable_if_t<(sizeof...(Flops) > 0)> = 0>
static bool tim::ert::executor< DeviceT, Tp, CounterT >::execute ( counter_type _counter,
std::array< std::string, sizeof...(Flops)>  _labels 
)
inlinestatic

Definition at line 394 of file configuration.hpp.

396 {
397 bool _executed = false;
398 auto itr = _labels.begin();
399 TIMEMORY_FOLD_EXPRESSION(_executed |= execute_impl<Flops>(_counter, *(itr++)));
400 return _executed;
401 }
#define TIMEMORY_FOLD_EXPRESSION(...)
Definition: types.hpp:56

References TIMEMORY_FOLD_EXPRESSION.

◆ get_callback()

template<typename DeviceT , typename Tp , typename CounterT >
static callback_type & tim::ert::executor< DeviceT, Tp, CounterT >::get_callback ( )
inlinestatic

Definition at line 351 of file configuration.hpp.

352 {
353 static callback_type _instance = [](counter_type& _counter) {
354 this_type::execute(_counter);
355 };
356 return _instance;
357 }
std::function< void(counter_type &)> callback_type
counter< device_type, value_type, CounterT > counter_type
static void execute(counter_type &_counter)

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

Referenced by tim::component::cpu_roofline< Types >::set_executor_callback(), and tim::component::gpu_roofline< Types >::set_executor_callback().

◆ operator()()

template<typename DeviceT , typename Tp , typename CounterT >
template<typename FuncT = std::function<void(uint64_t, counter_type&)>>
auto tim::ert::executor< DeviceT, Tp, CounterT >::operator() ( configuration_type config,
std::shared_ptr< ert_data_t _data = {},
FuncT &&  _counter_callback = FuncT{} 
)
inline

Definition at line 322 of file configuration.hpp.

322 {},
323 FuncT&& _counter_callback = FuncT{})
324 {
325 std::function<void(uint64_t, counter_type&)> _cb =
326 std::forward<FuncT>(_counter_callback);
327 try
328 {
329 if(!_data)
330 _data.reset(new ert_data_t);
331 auto _counter = config.executor(_data);
332 if(_cb)
333 _counter.set_callback(std::move(_cb));
334 callback(_counter);
335 } catch(std::exception& e)
336 {
337 std::cerr << "\n\nEXCEPTION:\n";
338 std::cerr << "\t" << e.what() << "\n\n" << std::endl;
339 }
340 return _data;
341 }
callback_type callback
exec_data< CounterT > ert_data_t

Member Data Documentation

◆ callback

template<typename DeviceT , typename Tp , typename CounterT >
callback_type tim::ert::executor< DeviceT, Tp, CounterT >::callback = get_callback()

Definition at line 346 of file configuration.hpp.


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