CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
edm::SystemTimeKeeper Class Reference

#include <SystemTimeKeeper.h>

Classes

struct  ModuleInPathTiming
 
struct  ModuleTiming
 
struct  PathTiming
 

Public Member Functions

void fillTriggerTimingReport (TriggerTimingReport &rep) const
 
SystemTimeKeeperoperator= (const SystemTimeKeeper &)=delete
 
void pauseModuleEvent (StreamContext const &, ModuleCallingContext const &)
 
void restartModuleEvent (StreamContext const &, ModuleCallingContext const &)
 
void startEvent (StreamID)
 
void startModuleEvent (StreamContext const &, ModuleCallingContext const &)
 
void startPath (StreamContext const &, PathContext const &)
 
void startProcessingLoop ()
 
void stopEvent (StreamContext const &)
 
void stopModuleEvent (StreamContext const &, ModuleCallingContext const &)
 
void stopPath (StreamContext const &, PathContext const &, HLTPathStatus const &)
 
void stopProcessingLoop ()
 
 SystemTimeKeeper (const SystemTimeKeeper &)=delete
 
 SystemTimeKeeper (unsigned int iNumStreams, std::vector< const ModuleDescription * > const &iModules, service::TriggerNamesService const &iNameService, ProcessContext const *iProcessContext)
 

Private Member Functions

bool checkBounds (unsigned int id) const
 
PathTimingpathTiming (StreamContext const &, PathContext const &)
 

Private Attributes

unsigned int m_endPathOffset
 
unsigned int m_minModuleID
 
std::vector< const ModuleDescription * > m_modules
 
std::vector< std::vector< std::string > > m_modulesOnPaths
 
std::atomic< unsigned int > m_numberOfEvents
 
std::vector< std::string > m_pathNames
 
ProcessContext const * m_processContext
 
CPUTimer m_processingLoopTimer
 
std::vector< WallclockTimerm_streamEventTimer
 
std::vector< std::vector< ModuleTiming > > m_streamModuleTiming
 
std::vector< std::vector< PathTiming > > m_streamPathTiming
 

Detailed Description

Definition at line 46 of file SystemTimeKeeper.h.

Constructor & Destructor Documentation

◆ SystemTimeKeeper() [1/2]

SystemTimeKeeper::SystemTimeKeeper ( unsigned int  iNumStreams,
std::vector< const ModuleDescription * > const &  iModules,
service::TriggerNamesService const &  iNameService,
ProcessContext const *  iProcessContext 
)

Definition at line 41 of file SystemTimeKeeper.cc.

45  : m_streamEventTimer(iNumStreams),
46  m_streamPathTiming(iNumStreams),
47  m_modules(iModules),
48  m_processContext(iProcessContext),
49  m_minModuleID(0),
50  m_numberOfEvents(0) {
51  std::sort(
52  m_modules.begin(), m_modules.end(), [](const ModuleDescription* iLHS, const ModuleDescription* iRHS) -> bool {
53  return iLHS->id() < iRHS->id();
54  });
55  if (not m_modules.empty()) {
56  m_minModuleID = m_modules.front()->id();
57  unsigned int numModuleSlots = m_modules.back()->id() - m_minModuleID + 1;
58  m_streamModuleTiming.resize(iNumStreams);
59  for (auto& stream : m_streamModuleTiming) {
60  stream.resize(numModuleSlots);
61  }
62  }
63 
64  std::vector<unsigned int> numModulesInPath;
65  std::vector<unsigned int> numModulesInEndPath;
66 
67  const unsigned int numPaths = iNamesService.getTrigPaths().size();
68  const unsigned int numEndPaths = iNamesService.getEndPaths().size();
69  m_pathNames.reserve(numPaths + numEndPaths);
70  std::copy(iNamesService.getTrigPaths().begin(), iNamesService.getTrigPaths().end(), std::back_inserter(m_pathNames));
71  std::copy(iNamesService.getEndPaths().begin(), iNamesService.getEndPaths().end(), std::back_inserter(m_pathNames));
72 
73  numModulesInPath.reserve(numPaths);
74  numModulesInEndPath.reserve(numEndPaths);
75 
76  m_modulesOnPaths.reserve(numPaths + numEndPaths);
77 
78  for (unsigned int i = 0; i < numPaths; ++i) {
79  numModulesInPath.push_back(iNamesService.getTrigPathModules(i).size());
80  m_modulesOnPaths.push_back(iNamesService.getTrigPathModules(i));
81  }
82  for (unsigned int i = 0; i < numEndPaths; ++i) {
83  numModulesInEndPath.push_back(iNamesService.getEndPathModules(i).size());
84  m_modulesOnPaths.push_back(iNamesService.getEndPathModules(i));
85  }
86 
87  m_endPathOffset = numModulesInPath.size();
88 
89  for (auto& stream : m_streamPathTiming) {
90  unsigned int index = 0;
91  stream.resize(numModulesInPath.size() + numModulesInEndPath.size());
92  for (unsigned int numMods : numModulesInPath) {
93  stream[index].m_moduleTiming.resize(numMods);
94  ++index;
95  }
96  for (unsigned int numMods : numModulesInEndPath) {
97  stream[index].m_moduleTiming.resize(numMods);
98  ++index;
99  }
100  }
101 }

References filterCSVwithJSON::copy, edm::service::TriggerNamesService::getEndPathModules(), edm::service::TriggerNamesService::getEndPaths(), edm::service::TriggerNamesService::getTrigPathModules(), edm::service::TriggerNamesService::getTrigPaths(), mps_fire::i, edm::ModuleDescription::id(), m_endPathOffset, m_minModuleID, m_modules, m_modulesOnPaths, m_pathNames, m_streamModuleTiming, m_streamPathTiming, and cms::cuda::stream.

◆ SystemTimeKeeper() [2/2]

edm::SystemTimeKeeper::SystemTimeKeeper ( const SystemTimeKeeper )
delete

Member Function Documentation

◆ checkBounds()

bool SystemTimeKeeper::checkBounds ( unsigned int  id) const
inlineprivate

Definition at line 120 of file SystemTimeKeeper.cc.

120  {
121  return id >= m_minModuleID and id < m_streamModuleTiming.front().size() + m_minModuleID;
122 }

References m_minModuleID, and m_streamModuleTiming.

Referenced by pauseModuleEvent(), restartModuleEvent(), startModuleEvent(), and stopModuleEvent().

◆ fillTriggerTimingReport()

void SystemTimeKeeper::fillTriggerTimingReport ( TriggerTimingReport rep) const

Definition at line 231 of file SystemTimeKeeper.cc.

231  {
232  {
233  rep.eventSummary.totalEvents = m_numberOfEvents;
234  double sumEventTime = 0.;
235  for (auto const& stream : m_streamEventTimer) {
236  sumEventTime += stream.realTime();
237  }
238  rep.eventSummary.realTime = m_processingLoopTimer.realTime();
239  rep.eventSummary.cpuTime = m_processingLoopTimer.cpuTime();
240  rep.eventSummary.sumStreamRealTime = sumEventTime;
241  }
242 
243  //Per module summary
244  {
245  auto& summary = rep.workerSummaries;
246  summary.resize(m_modules.size());
247  //Figure out how often a module was visited
248  std::map<std::string, unsigned int> visited;
249  for (auto const& stream : m_streamPathTiming) {
250  unsigned int pathIndex = 0;
251  for (auto const& path : stream) {
252  unsigned int modIndex = 0;
253  for (auto const& mod : path.m_moduleTiming) {
254  visited[m_modulesOnPaths[pathIndex][modIndex]] += mod.m_timesVisited;
255  ++modIndex;
256  }
257  ++pathIndex;
258  }
259  }
260 
261  unsigned int modIndex = 0;
262  for (auto const& mod : m_modules) {
263  auto& outMod = summary[modIndex];
264  outMod.moduleLabel = mod->moduleLabel();
265  outMod.realTime = 0.;
266 
267  auto moduleId = mod->id() - m_minModuleID;
268  for (auto const& stream : m_streamModuleTiming) {
269  auto const& timing = stream[moduleId];
270  outMod.realTime += timing.m_timer.realTime();
271  outMod.timesRun += timing.m_timesRun;
272  }
273  outMod.timesVisited = visited[mod->moduleLabel()];
274  if (0 == outMod.timesVisited) {
275  outMod.timesVisited = outMod.timesRun;
276  }
277  ++modIndex;
278  }
279  }
280  sort_all(rep.workerSummaries);
281 
282  //Per path summary
283  {
287  m_pathNames,
290  rep.endPathSummaries);
291  }
292 }

References edm::CPUTimer::cpuTime(), edm::fillPathSummary(), m_endPathOffset, m_minModuleID, m_modules, m_modulesOnPaths, m_numberOfEvents, m_pathNames, m_processingLoopTimer, m_streamEventTimer, m_streamModuleTiming, m_streamPathTiming, mod(), castor_dqm_sourceclient_file_cfg::path, edm::CPUTimer::realTime(), cuy::rep, findQualityFiles::size, edm::sort_all(), cms::cuda::stream, edmLumisInFiles::summary, ecalMatacq_cfi::timing, and class-composition::visited.

◆ operator=()

SystemTimeKeeper& edm::SystemTimeKeeper::operator= ( const SystemTimeKeeper )
delete

◆ pathTiming()

SystemTimeKeeper::PathTiming & SystemTimeKeeper::pathTiming ( StreamContext const &  iStream,
PathContext const &  iPath 
)
private

Definition at line 106 of file SystemTimeKeeper.cc.

106  {
107  unsigned int offset = 0;
108  if (iPath.isEndPath()) {
110  }
111  assert(iPath.pathID() + offset < m_streamPathTiming[iStream.streamID().value()].size());
112  return m_streamPathTiming[iStream.streamID().value()][iPath.pathID() + offset];
113 }

References cms::cuda::assert(), edm::PathContext::isEndPath(), m_endPathOffset, m_streamPathTiming, hltrates_dqm_sourceclient-live_cfg::offset, edm::PathContext::pathID(), edm::StreamContext::streamID(), and edm::StreamID::value().

Referenced by pauseModuleEvent(), startPath(), stopModuleEvent(), and stopPath().

◆ pauseModuleEvent()

void SystemTimeKeeper::pauseModuleEvent ( StreamContext const &  iStream,
ModuleCallingContext const &  iModule 
)

Definition at line 173 of file SystemTimeKeeper.cc.

173  {
174  if (checkBounds(iModule.moduleDescription()->id())) {
175  auto& mod = m_streamModuleTiming[iStream.streamID().value()][iModule.moduleDescription()->id() - m_minModuleID];
176  auto times = mod.m_timer.stop();
177 
178  if (iModule.type() == ParentContext::Type::kPlaceInPath) {
179  auto place = iModule.placeInPathContext();
180 
181  auto& modTiming = pathTiming(iStream, *(place->pathContext())).m_moduleTiming[place->placeInPath()];
182  modTiming.m_realTime += times;
183  }
184  }
185 }

References checkBounds(), edm::ModuleDescription::id(), edm::ParentContext::kPlaceInPath, m_minModuleID, edm::SystemTimeKeeper::PathTiming::m_moduleTiming, m_streamModuleTiming, mod(), edm::ModuleCallingContext::moduleDescription(), pathTiming(), edm::ModuleCallingContext::placeInPathContext(), edm::StreamContext::streamID(), edm::ModuleCallingContext::type(), and edm::StreamID::value().

◆ restartModuleEvent()

void SystemTimeKeeper::restartModuleEvent ( StreamContext const &  iStream,
ModuleCallingContext const &  iModule 
)

Definition at line 186 of file SystemTimeKeeper.cc.

186  {
187  if (checkBounds(iModule.moduleDescription()->id())) {
188  auto& mod = m_streamModuleTiming[iStream.streamID().value()][iModule.moduleDescription()->id() - m_minModuleID];
189  mod.m_timer.start();
190  }
191 }

References checkBounds(), edm::ModuleDescription::id(), m_minModuleID, m_streamModuleTiming, mod(), edm::ModuleCallingContext::moduleDescription(), edm::StreamContext::streamID(), and edm::StreamID::value().

◆ startEvent()

void SystemTimeKeeper::startEvent ( StreamID  iID)

Definition at line 124 of file SystemTimeKeeper.cc.

124  {
126  m_streamEventTimer[iID.value()].start();
127 }

References m_numberOfEvents, m_streamEventTimer, and edm::StreamID::value().

◆ startModuleEvent()

void SystemTimeKeeper::startModuleEvent ( StreamContext const &  iStream,
ModuleCallingContext const &  iModule 
)

Definition at line 153 of file SystemTimeKeeper.cc.

153  {
154  if (checkBounds(iModule.moduleDescription()->id())) {
155  auto& mod = m_streamModuleTiming[iStream.streamID().value()][iModule.moduleDescription()->id() - m_minModuleID];
156  mod.m_timer.start();
157  ++(mod.m_timesRun);
158  }
159 }

References checkBounds(), edm::ModuleDescription::id(), m_minModuleID, m_streamModuleTiming, mod(), edm::ModuleCallingContext::moduleDescription(), edm::StreamContext::streamID(), and edm::StreamID::value().

◆ startPath()

void SystemTimeKeeper::startPath ( StreamContext const &  iStream,
PathContext const &  iPath 
)

Definition at line 133 of file SystemTimeKeeper.cc.

133  {
134  if (m_processContext == iStream.processContext()) {
135  auto& timing = pathTiming(iStream, iPath);
136  timing.m_timer.start();
137  }
138 }

References m_processContext, pathTiming(), edm::StreamContext::processContext(), and ecalMatacq_cfi::timing.

◆ startProcessingLoop()

void SystemTimeKeeper::startProcessingLoop ( )

Definition at line 193 of file SystemTimeKeeper.cc.

References m_processingLoopTimer, and edm::CPUTimer::start().

◆ stopEvent()

void SystemTimeKeeper::stopEvent ( StreamContext const &  iContext)

Definition at line 129 of file SystemTimeKeeper.cc.

129  {
130  m_streamEventTimer[iContext.streamID().value()].stop();
131 }

References m_streamEventTimer, edm::StreamContext::streamID(), and edm::StreamID::value().

◆ stopModuleEvent()

void SystemTimeKeeper::stopModuleEvent ( StreamContext const &  iStream,
ModuleCallingContext const &  iModule 
)

Definition at line 160 of file SystemTimeKeeper.cc.

160  {
161  if (checkBounds(iModule.moduleDescription()->id())) {
162  auto& mod = m_streamModuleTiming[iStream.streamID().value()][iModule.moduleDescription()->id() - m_minModuleID];
163  auto times = mod.m_timer.stop();
164 
165  if (iModule.type() == ParentContext::Type::kPlaceInPath) {
166  auto place = iModule.placeInPathContext();
167 
168  auto& modTiming = pathTiming(iStream, *(place->pathContext())).m_moduleTiming[place->placeInPath()];
169  modTiming.m_realTime += times;
170  }
171  }
172 }

References checkBounds(), edm::ModuleDescription::id(), edm::ParentContext::kPlaceInPath, m_minModuleID, edm::SystemTimeKeeper::PathTiming::m_moduleTiming, m_streamModuleTiming, mod(), edm::ModuleCallingContext::moduleDescription(), pathTiming(), edm::ModuleCallingContext::placeInPathContext(), edm::StreamContext::streamID(), edm::ModuleCallingContext::type(), and edm::StreamID::value().

◆ stopPath()

void SystemTimeKeeper::stopPath ( StreamContext const &  iStream,
PathContext const &  iPath,
HLTPathStatus const &  iStatus 
)

Definition at line 140 of file SystemTimeKeeper.cc.

140  {
141  if (m_processContext == iStream.processContext()) {
142  auto& timing = pathTiming(iStream, iPath);
143  timing.m_timer.stop();
144 
145  //mark all modules up to and including the decision module as being visited
146  auto& modsOnPath = timing.m_moduleTiming;
147  for (unsigned int i = 0; i < iStatus.index() + 1; ++i) {
148  ++modsOnPath[i].m_timesVisited;
149  }
150  }
151 }

References mps_fire::i, edm::HLTPathStatus::index(), m_processContext, pathTiming(), edm::StreamContext::processContext(), and ecalMatacq_cfi::timing.

◆ stopProcessingLoop()

void SystemTimeKeeper::stopProcessingLoop ( )

Definition at line 195 of file SystemTimeKeeper.cc.

References m_processingLoopTimer, and edm::CPUTimer::stop().

Member Data Documentation

◆ m_endPathOffset

unsigned int edm::SystemTimeKeeper::m_endPathOffset
private

Definition at line 110 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), pathTiming(), and SystemTimeKeeper().

◆ m_minModuleID

unsigned int edm::SystemTimeKeeper::m_minModuleID
private

◆ m_modules

std::vector<const ModuleDescription*> edm::SystemTimeKeeper::m_modules
private

Definition at line 102 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), and SystemTimeKeeper().

◆ m_modulesOnPaths

std::vector<std::vector<std::string> > edm::SystemTimeKeeper::m_modulesOnPaths
private

Definition at line 104 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), and SystemTimeKeeper().

◆ m_numberOfEvents

std::atomic<unsigned int> edm::SystemTimeKeeper::m_numberOfEvents
private

Definition at line 111 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), and startEvent().

◆ m_pathNames

std::vector<std::string> edm::SystemTimeKeeper::m_pathNames
private

Definition at line 103 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), and SystemTimeKeeper().

◆ m_processContext

ProcessContext const* edm::SystemTimeKeeper::m_processContext
private

Definition at line 107 of file SystemTimeKeeper.h.

Referenced by startPath(), and stopPath().

◆ m_processingLoopTimer

CPUTimer edm::SystemTimeKeeper::m_processingLoopTimer
private

◆ m_streamEventTimer

std::vector<WallclockTimer> edm::SystemTimeKeeper::m_streamEventTimer
private

Definition at line 96 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), startEvent(), and stopEvent().

◆ m_streamModuleTiming

std::vector<std::vector<ModuleTiming> > edm::SystemTimeKeeper::m_streamModuleTiming
private

◆ m_streamPathTiming

std::vector<std::vector<PathTiming> > edm::SystemTimeKeeper::m_streamPathTiming
private

Definition at line 98 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), pathTiming(), and SystemTimeKeeper().

mps_fire.i
i
Definition: mps_fire.py:428
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
edm::sort_all
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
edm::SystemTimeKeeper::m_numberOfEvents
std::atomic< unsigned int > m_numberOfEvents
Definition: SystemTimeKeeper.h:111
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
mod
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
edm::SystemTimeKeeper::m_pathNames
std::vector< std::string > m_pathNames
Definition: SystemTimeKeeper.h:103
edm::SystemTimeKeeper::PathTiming::m_moduleTiming
std::vector< ModuleInPathTiming > m_moduleTiming
Definition: SystemTimeKeeper.h:81
cms::cuda::assert
assert(be >=bs)
edm::StreamID::value
unsigned int value() const
Definition: StreamID.h:43
edm::ParentContext::Type::kPlaceInPath
edm::ModuleDescription
Definition: ModuleDescription.h:21
edm::SystemTimeKeeper::m_streamModuleTiming
std::vector< std::vector< ModuleTiming > > m_streamModuleTiming
Definition: SystemTimeKeeper.h:100
edm::SystemTimeKeeper::m_processContext
ProcessContext const * m_processContext
Definition: SystemTimeKeeper.h:107
edm::CPUTimer::start
void start()
Definition: CPUTimer.cc:68
class-composition.visited
visited
Definition: class-composition.py:74
edm::SystemTimeKeeper::m_modules
std::vector< const ModuleDescription * > m_modules
Definition: SystemTimeKeeper.h:102
edm::SystemTimeKeeper::m_processingLoopTimer
CPUTimer m_processingLoopTimer
Definition: SystemTimeKeeper.h:106
edmLumisInFiles.summary
summary
Definition: edmLumisInFiles.py:39
cuy.rep
rep
Definition: cuy.py:1190
edm::CPUTimer::stop
Times stop()
Definition: CPUTimer.cc:87
edm::fillPathSummary
static void fillPathSummary(Path const &path, PathSummary &sum)
Definition: StreamSchedule.cc:842
ecalMatacq_cfi.timing
timing
Definition: ecalMatacq_cfi.py:26
edm::SystemTimeKeeper::m_streamEventTimer
std::vector< WallclockTimer > m_streamEventTimer
Definition: SystemTimeKeeper.h:96
edm::SystemTimeKeeper::pathTiming
PathTiming & pathTiming(StreamContext const &, PathContext const &)
Definition: SystemTimeKeeper.cc:106
edm::CPUTimer::cpuTime
double cpuTime() const
Definition: CPUTimer.cc:146
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::SystemTimeKeeper::checkBounds
bool checkBounds(unsigned int id) const
Definition: SystemTimeKeeper.cc:120
edm::SystemTimeKeeper::m_modulesOnPaths
std::vector< std::vector< std::string > > m_modulesOnPaths
Definition: SystemTimeKeeper.h:104
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
edm::SystemTimeKeeper::m_streamPathTiming
std::vector< std::vector< PathTiming > > m_streamPathTiming
Definition: SystemTimeKeeper.h:98
edm::CPUTimer::realTime
double realTime() const
Definition: CPUTimer.cc:139
edm::SystemTimeKeeper::m_endPathOffset
unsigned int m_endPathOffset
Definition: SystemTimeKeeper.h:110
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
edm::SystemTimeKeeper::m_minModuleID
unsigned int m_minModuleID
Definition: SystemTimeKeeper.h:109
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
edm::ModuleDescription::id
unsigned int id() const
Definition: ModuleDescription.h:46