34#include "timemory/components/craypat/backends.hpp"
54:
base<craypat_record, void>
65 return "Toggles CrayPAT recording on calling thread";
75 if(tracker_type::m_thr == 0)
82 if(tracker_type::m_thr == 0)
93:
base<craypat_region, void>
104 backend::craypat::region_begin(tracker_type::m_tot, m_label.c_str());
109 backend::craypat::region_end(tracker_type::m_tot);
137 return "Names and value of any counter events that have been set to count on the "
143 std::set<int> _empty;
145 for(
auto& citr : get_persistent_data().m_categories)
147 int _category = std::get<0>(citr);
149 const char** _names =
nullptr;
150 unsigned long* _values =
nullptr;
151 int* _nevents =
nullptr;
153 backend::craypat::counters(_category, _names, _values, _nevents);
154 if(_names && _values && _nevents)
156 std::get<1>(citr) = *_nevents;
157 for(
int i = 0; i < *_nevents; ++i)
159 std::get<2>(citr).push_back(_names[i]);
160 get_persistent_data().m_labels.push_back(_names[i]);
170 get_persistent_data().m_events = get_persistent_data().m_labels.size();
173 for(
auto ritr = _empty.rbegin(); ritr != _empty.rend(); ++ritr)
175 auto itr = get_persistent_data().m_categories.begin();
176 std::advance(itr, *ritr);
177 get_persistent_data().m_categories.erase(itr);
186 for(
const auto& citr : get_persistent_data().m_categories)
188 int _category = std::get<0>(citr);
190 const char** _names =
nullptr;
191 unsigned long* _values =
nullptr;
192 int* _nevents =
nullptr;
194 backend::craypat::counters(_category, _names, _values, _nevents);
195 if(_names && _values && _nevents)
198 auto _off = _data.size();
200 _data.resize(_off + std::get<1>(citr), 0);
202 int _n =
std::min(std::get<1>(citr), *_nevents);
203 for(
int i = 0; i < _n; ++i)
204 _data[_off + i] = _values[i];
214 return strvector_t(get_persistent_data().m_events,
"");
219 return std::vector<unsigned long>(get_persistent_data().m_events, 1);
224 return strvector_t(get_persistent_data().m_events,
"");
235 value = (
record() - value);
240 struct persistent_data
242 using category_tuple_t = std::tuple<int, int, strvector_t>;
243 using category_vector_t = std::vector<category_tuple_t>;
244 category_vector_t m_categories =
245 category_vector_t({ category_tuple_t{ PAT_CTRS_CPU, 0,
strvector_t{} },
246 category_tuple_t{ PAT_CTRS_NETWORK, 0,
strvector_t{} },
247 category_tuple_t{ PAT_CTRS_ACCEL, 0,
strvector_t{} },
248 category_tuple_t{ PAT_CTRS_RAPL, 0,
strvector_t{} },
250 category_tuple_t{ PAT_CTRS_UNCORE, 0,
strvector_t{} } });
255 static persistent_data& get_persistent_data()
257 static persistent_data _instance;
273 static void stop() { backend::craypat::heap_stats(); }
291 return "Writes all the recorded contents in the data buffer. Returns the number "
297 unsigned long _nbytes;
298 backend::craypat::flush_buffer(&_nbytes);
302 TIMEMORY_NODISCARD
double get()
const {
return m_nbytes; }
312 unsigned long m_nbytes = 0;
Declare the craypat component types.
::tim::statistics< Tp > min(::tim::statistics< Tp > lhs, const Tp &rhs)
void record(TupleT< Tp... > &obj, Args &&... args)
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
storage< Tp, Value > storage_type
std::vector< unsigned long > value_type
static void global_init()
static strvector_t display_unit_array()
value_type get_display() const
static std::vector< unsigned long > unit_array()
static strvector_t label_array()
static std::string description()
std::vector< std::string > strvector_t
static value_type record()
static strvector_t description_array()
static std::string label()
Writes all the recorded contents in the data buffer. Returns the number of bytes flushed.
static std::string description()
static value_type record()
static std::string label()
Dumps the craypat heap statistics.
static std::string description()
static std::string label()
Provides scoping the CrayPAT profiler. Global initialization stops the profiler, the first call to st...
static std::string description()
static void global_finalize()
static std::string label()
static void global_init()
Adds a region label to the CrayPAT profiling output.
void set_prefix(const std::string &_label)
static std::string description()
static std::string label()
A very lightweight storage class which provides nothing.