7#ifndef CALORECGPU_CALOGPUTIMED_H
8#define CALORECGPU_CALOGPUTIMED_H
11#include <shared_mutex>
16#include <GaudiKernel/IProperty.h>
56 m_measureTimes(ptr,
"MeasureTimes", false,
"Save time measurements"),
57 m_timeFileName(ptr,
"TimeFileOutput",
"times.txt",
"File to which time measurements should be saved")
73 m_times[
index] = std::forward<Arg>(arg);
78 template <
class ...
Args>
86 inline void record_times(
const size_t event_num,
const std::vector<size_t> & times)
const
90 std::unique_lock<std::shared_mutex> lock(
m_timeMutex);
91 old_size = m_times.size();
92 m_times.resize(old_size + times.size());
93 m_eventNumbers.push_back(event_num);
96 std::shared_lock<std::shared_mutex> lock(
m_timeMutex);
97 for (
size_t i = 0; i < times.size(); ++i)
99 m_times[old_size + i] = times[i];
104 template <
class ...
Args>
105 inline void record_times(
const size_t event_num,
const size_t & value)
const
107 const size_t time_size = 1;
112 std::unique_lock<std::shared_mutex> lock(
m_timeMutex);
113 old_size = m_times.size();
114 m_times.resize(old_size + time_size);
115 m_eventNumbers.push_back(event_num);
118 std::shared_lock<std::shared_mutex> lock(
m_timeMutex);
123 template <
class ...
Args>
124 inline void record_times(
const size_t event_num,
const size_t & value,
Args && ... args)
const
126 const size_t time_size =
sizeof...(args) + 1;
131 std::unique_lock<std::shared_mutex> lock(
m_timeMutex);
132 old_size = m_times.size();
133 m_times.resize(old_size + time_size);
134 m_eventNumbers.push_back(event_num);
137 std::shared_lock<std::shared_mutex> lock(
m_timeMutex);
145 std::shared_lock<std::shared_mutex> lock(
m_timeMutex);
152 std::vector<size_t> indices(m_eventNumbers.size());
154 std::iota(indices.begin(), indices.end(), 0);
155 std::sort(indices.begin(), indices.end(), [&](
size_t a,
size_t b)
157 return m_eventNumbers[a] < m_eventNumbers[b];
162 out <<
"Event_Number Total " <<
header <<
"\n";
164 for (
const size_t idx : indices)
166 out << m_eventNumbers[idx] <<
" ";
170 for (
size_t i = 0; i < time_size; ++i)
172 total += m_times[idx * time_size + i];
177 for (
size_t i = 0; i < time_size; ++i)
179 out << m_times[idx * time_size + i] <<
" ";
Define macros for attributes used to control the static checker.
void record_times(const size_t event_num, const size_t &value) const
Gaudi::Property< bool > m_measureTimes
If true, times are recorded to the file given by m_timeFileName.
Gaudi::Property< std::string > m_timeFileName
File to which times should be saved.
std::vector< size_t > m_times ATLAS_THREAD_SAFE
Vector to hold execution times to be recorded if necessary.
void record_times(const size_t event_num, const size_t &value, Args &&... args) const
std::shared_mutex m_timeMutex
Mutex that is locked when recording times.
void print_times(const std::string &header, const size_t time_size) const
void record_times_helper(const size_t index, Arg &&arg) const
void record_times_helper(size_t index, Args &&... args) const
void record_times_helper(const size_t) const
void record_times(const size_t event_num, const std::vector< size_t > ×) const
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.