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::craypat_counters Struct Reference

#include "timemory/components/craypat/components.hpp"

+ Collaboration diagram for tim::component::craypat_counters:

Public Types

using value_type = std::vector< unsigned long >
 
using this_type = craypat_counters
 
using base_type = base< this_type, value_type >
 
using storage_type = typename base_type::storage_type
 
using strvector_t = std::vector< std::string >
 

Public Member Functions

value_type get () const
 
value_type get_display () const
 
void start ()
 
void stop ()
 

Static Public Member Functions

static std::string label ()
 
static std::string description ()
 
static void configure ()
 
static void global_init ()
 
static value_type record ()
 
static strvector_t label_array ()
 
static strvector_t description_array ()
 
static std::vector< unsigned long > unit_array ()
 
static strvector_t display_unit_array ()
 

Detailed Description

Definition at line 125 of file components.hpp.

Member Typedef Documentation

◆ base_type

◆ storage_type

Definition at line 130 of file components.hpp.

◆ strvector_t

using tim::component::craypat_counters::strvector_t = std::vector<std::string>

Definition at line 131 of file components.hpp.

◆ this_type

◆ value_type

using tim::component::craypat_counters::value_type = std::vector<unsigned long>

Definition at line 127 of file components.hpp.

Member Function Documentation

◆ configure()

static void tim::component::craypat_counters::configure ( )
inlinestatic

Definition at line 141 of file components.hpp.

142  {
143  std::set<int> _empty;
144  int _idx = 0;
145  for(auto& citr : get_persistent_data().m_categories)
146  {
147  int _category = std::get<0>(citr);
148  // temporary data
149  const char** _names = nullptr;
150  unsigned long* _values = nullptr;
151  int* _nevents = nullptr;
152  // get data from craypat
153  backend::craypat::counters(_category, _names, _values, _nevents);
154  if(_names && _values && _nevents)
155  {
156  std::get<1>(citr) = *_nevents;
157  for(int i = 0; i < *_nevents; ++i)
158  {
159  std::get<2>(citr).push_back(_names[i]);
160  get_persistent_data().m_labels.push_back(_names[i]);
161  }
162  }
163  else
164  {
165  _empty.insert(_idx);
166  }
167  ++_idx;
168  }
169 
170  get_persistent_data().m_events = get_persistent_data().m_labels.size();
171 
172  // erase the unused categories
173  for(auto ritr = _empty.rbegin(); ritr != _empty.rend(); ++ritr)
174  {
175  auto itr = get_persistent_data().m_categories.begin();
176  std::advance(itr, *ritr);
177  get_persistent_data().m_categories.erase(itr);
178  }
179  }

Referenced by global_init().

◆ description()

static std::string tim::component::craypat_counters::description ( )
inlinestatic

Definition at line 135 of file components.hpp.

136  {
137  return "Names and value of any counter events that have been set to count on the "
138  "hardware category";
139  }

◆ description_array()

static strvector_t tim::component::craypat_counters::description_array ( )
inlinestatic

Definition at line 212 of file components.hpp.

213  {
214  return strvector_t(get_persistent_data().m_events, "");
215  }
std::vector< std::string > strvector_t
Definition: components.hpp:131

◆ display_unit_array()

static strvector_t tim::component::craypat_counters::display_unit_array ( )
inlinestatic

Definition at line 222 of file components.hpp.

223  {
224  return strvector_t(get_persistent_data().m_events, "");
225  }

◆ get()

value_type tim::component::craypat_counters::get ( ) const
inline

Definition at line 227 of file components.hpp.

227 { return base_type::load(); }
decltype(auto) load()

References tim::component::base< Tp, Value >::load().

Referenced by tim::component::craypat_flush_buffer::get_display().

◆ get_display()

value_type tim::component::craypat_counters::get_display ( ) const
inline

Definition at line 228 of file components.hpp.

228 { return base_type::load(); }

References tim::component::base< Tp, Value >::load().

◆ global_init()

static void tim::component::craypat_counters::global_init ( )
inlinestatic

Definition at line 181 of file components.hpp.

181 { configure(); }

References configure().

◆ label()

static std::string tim::component::craypat_counters::label ( )
inlinestatic

Definition at line 133 of file components.hpp.

133 { return "craypat_counters"; }

◆ label_array()

static strvector_t tim::component::craypat_counters::label_array ( )
inlinestatic

Definition at line 210 of file components.hpp.

210 { return get_persistent_data().m_labels; }

◆ record()

static value_type tim::component::craypat_counters::record ( )
inlinestatic

Definition at line 183 of file components.hpp.

184  {
185  value_type _data;
186  for(const auto& citr : get_persistent_data().m_categories)
187  {
188  int _category = std::get<0>(citr);
189  // temporary data
190  const char** _names = nullptr;
191  unsigned long* _values = nullptr;
192  int* _nevents = nullptr;
193  // get data from craypat
194  backend::craypat::counters(_category, _names, _values, _nevents);
195  if(_names && _values && _nevents)
196  {
197  // current beginning index
198  auto _off = _data.size();
199  // make sure data size is consistent
200  _data.resize(_off + std::get<1>(citr), 0);
201  // compute the size of loop
202  int _n = std::min(std::get<1>(citr), *_nevents);
203  for(int i = 0; i < _n; ++i)
204  _data[_off + i] = _values[i];
205  }
206  }
207  return _data;
208  }
::tim::statistics< Tp > min(::tim::statistics< Tp > lhs, const Tp &rhs)
Definition: statistics.hpp:319
std::vector< unsigned long > value_type
Definition: components.hpp:127

Referenced by start(), stop(), and tim::component::craypat_flush_buffer::stop().

◆ start()

void tim::component::craypat_counters::start ( )
inline

Definition at line 230 of file components.hpp.

230 { value = record(); }

References record().

◆ stop()

void tim::component::craypat_counters::stop ( )
inline

Definition at line 232 of file components.hpp.

233  {
234  using namespace tim::component::operators;
235  value = (record() - value);
236  accum += value;
237  }

References record().

◆ unit_array()

static std::vector<unsigned long> tim::component::craypat_counters::unit_array ( )
inlinestatic

Definition at line 217 of file components.hpp.

218  {
219  return std::vector<unsigned long>(get_persistent_data().m_events, 1);
220  }

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