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
 
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 (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
 
const SystemTimeKeeperoperator= (const SystemTimeKeeper &)=delete
 
PathTimingpathTiming (StreamContext const &, PathContext const &)
 
 SystemTimeKeeper (const SystemTimeKeeper &)=delete
 

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::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.

References popcon2dropbox::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, and m_streamPathTiming.

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

Member Function Documentation

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

Definition at line 131 of file SystemTimeKeeper.cc.

References m_minModuleID, and m_modules.

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

131  {
132  return id >= m_minModuleID and id <m_modules.size()+ m_minModuleID;
133 }
std::vector< const ModuleDescription * > m_modules
void SystemTimeKeeper::fillTriggerTimingReport ( TriggerTimingReport rep) const

Definition at line 271 of file SystemTimeKeeper.cc.

References edm::EventTimingSummary::cpuTime, edm::CPUTimer::cpuTime(), edm::TriggerTimingReport::endPathSummaries, edm::TriggerTimingReport::eventSummary, edm::fillPathSummary(), m_endPathOffset, m_minModuleID, m_modules, m_modulesOnPaths, m_numberOfEvents, m_pathNames, m_processingLoopTimer, m_streamEventTimer, m_streamModuleTiming, m_streamPathTiming, mod(), callgraph::path, edm::EventTimingSummary::realTime, edm::CPUTimer::realTime(), findQualityFiles::size, edm::sort_all(), heppy_report::summary, edm::EventTimingSummary::sumStreamRealTime, edm::EventTimingSummary::totalEvents, edm::TriggerTimingReport::trigPathSummaries, class-composition::visited, and edm::TriggerTimingReport::workerSummaries.

271  {
272  {
274  double sumEventTime = 0.;
275  for(auto const& stream: m_streamEventTimer) {
276  sumEventTime += stream.realTime();
277  }
280  rep.eventSummary.sumStreamRealTime = sumEventTime;
281  }
282 
283  //Per module summary
284  {
285  auto& summary = rep.workerSummaries;
286  summary.resize(m_modules.size());
287  //Figure out how often a module was visited
288  std::map<std::string,unsigned int> visited;
289  for(auto const& stream: m_streamPathTiming) {
290  unsigned int pathIndex = 0;
291  for(auto const& path: stream) {
292  unsigned int modIndex = 0;
293  for(auto const& mod: path.m_moduleTiming) {
294  visited[m_modulesOnPaths[pathIndex][modIndex]] += mod.m_timesVisited;
295  ++modIndex;
296  }
297  ++pathIndex;
298  }
299  }
300 
301  unsigned int modIndex=0;
302  for(auto const& mod: m_modules) {
303  auto& outMod = summary[modIndex];
304  outMod.moduleLabel = mod->moduleLabel();
305  outMod.realTime = 0.;
306 
307  auto moduleId =mod->id()-m_minModuleID;
308  for(auto const& stream: m_streamModuleTiming) {
309  auto const& timing = stream[moduleId];
310  outMod.realTime += timing.m_timer.realTime();
311  outMod.timesRun += timing.m_timesRun;
312  }
313  outMod.timesVisited = visited[mod->moduleLabel()];
314  if(0 == outMod.timesVisited) {
315  outMod.timesVisited = outMod.timesRun;
316  }
317  ++modIndex;
318  }
319  }
321 
322  //Per path summary
323  {
325  fillPathSummary(m_endPathOffset, m_streamPathTiming[0].size(), m_pathNames, m_modulesOnPaths, m_streamPathTiming, rep.endPathSummaries);
326  }
327 }
size
Write out results.
std::vector< std::vector< std::string > > m_modulesOnPaths
std::vector< PathTimingSummary > endPathSummaries
std::atomic< unsigned int > m_numberOfEvents
std::vector< std::vector< ModuleTiming > > m_streamModuleTiming
std::vector< std::string > m_pathNames
std::vector< const ModuleDescription * > m_modules
EventTimingSummary eventSummary
static void fillPathSummary(Path const &path, PathSummary &sum)
std::vector< PathTimingSummary > trigPathSummaries
double cpuTime() const
Definition: CPUTimer.cc:158
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:120
std::vector< WallclockTimer > m_streamEventTimer
unsigned int m_endPathOffset
std::vector< WorkerTimingSummary > workerSummaries
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
std::vector< std::vector< PathTiming > > m_streamPathTiming
double realTime() const
Definition: CPUTimer.cc:150
const SystemTimeKeeper& edm::SystemTimeKeeper::operator= ( const SystemTimeKeeper )
privatedelete
SystemTimeKeeper::PathTiming & SystemTimeKeeper::pathTiming ( StreamContext const &  iStream,
PathContext const &  iPath 
)
private

Definition at line 115 of file SystemTimeKeeper.cc.

References edm::PathContext::isEndPath(), m_endPathOffset, m_streamPathTiming, PFRecoTauDiscriminationByIsolation_cfi::offset, edm::PathContext::pathID(), edm::StreamContext::streamID(), and edm::StreamID::value().

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

116  {
117  unsigned int offset = 0;
118  if(iPath.isEndPath()) {
119  offset = m_endPathOffset;
120  }
121  assert(iPath.pathID()+offset < m_streamPathTiming[iStream.streamID().value()].size());
122  return m_streamPathTiming[iStream.streamID().value()][iPath.pathID()+offset];
123 }
unsigned int m_endPathOffset
std::vector< std::vector< PathTiming > > m_streamPathTiming
void SystemTimeKeeper::pauseModuleEvent ( StreamContext const &  iStream,
ModuleCallingContext const &  iModule 
)

Definition at line 199 of file SystemTimeKeeper.cc.

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(), create_public_lumi_plots::times, edm::ModuleCallingContext::type(), and edm::StreamID::value().

Referenced by edm::Schedule::Schedule().

200  {
201  if(checkBounds(iModule.moduleDescription()->id())) {
202  auto& mod =
203  m_streamModuleTiming[iStream.streamID().value()][iModule.moduleDescription()->id()-m_minModuleID];
204  auto times = mod.m_timer.stop();
205 
206  if(iModule.type() == ParentContext::Type::kPlaceInPath ) {
207  auto place = iModule.placeInPathContext();
208 
209  auto& modTiming = pathTiming(iStream,*(place->pathContext())).m_moduleTiming[place->placeInPath()];
210  modTiming.m_realTime += times;
211  }
212  }
213 }
std::vector< ModuleInPathTiming > m_moduleTiming
std::vector< std::vector< ModuleTiming > > m_streamModuleTiming
PathTiming & pathTiming(StreamContext const &, PathContext const &)
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
bool checkBounds(unsigned int id) const
void SystemTimeKeeper::restartModuleEvent ( StreamContext const &  iStream,
ModuleCallingContext const &  iModule 
)

Definition at line 215 of file SystemTimeKeeper.cc.

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

Referenced by edm::Schedule::Schedule().

216  {
217  if(checkBounds(iModule.moduleDescription()->id())) {
218  auto& mod =
219  m_streamModuleTiming[iStream.streamID().value()][iModule.moduleDescription()->id()-m_minModuleID];
220  mod.m_timer.start();
221  }
222 }
std::vector< std::vector< ModuleTiming > > m_streamModuleTiming
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
bool checkBounds(unsigned int id) const
void SystemTimeKeeper::startEvent ( StreamID  iID)

Definition at line 138 of file SystemTimeKeeper.cc.

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

Referenced by edm::Schedule::Schedule().

138  {
140  m_streamEventTimer[iID.value()].start();
141 }
std::atomic< unsigned int > m_numberOfEvents
unsigned int value() const
Definition: StreamID.h:46
std::vector< WallclockTimer > m_streamEventTimer
void SystemTimeKeeper::startModuleEvent ( StreamContext const &  iStream,
ModuleCallingContext const &  iModule 
)

Definition at line 176 of file SystemTimeKeeper.cc.

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

Referenced by edm::Schedule::Schedule().

176  {
177  if(checkBounds(iModule.moduleDescription()->id())) {
178  auto& mod =
179  m_streamModuleTiming[iStream.streamID().value()][iModule.moduleDescription()->id()-m_minModuleID];
180  mod.m_timer.start();
181  ++(mod.m_timesRun);
182  }
183 }
std::vector< std::vector< ModuleTiming > > m_streamModuleTiming
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
bool checkBounds(unsigned int id) const
void SystemTimeKeeper::startPath ( StreamContext const &  iStream,
PathContext const &  iPath 
)

Definition at line 149 of file SystemTimeKeeper.cc.

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

Referenced by edm::Schedule::Schedule().

150  {
151  if(m_processContext == iStream.processContext()) {
152  auto& timing = pathTiming(iStream,iPath);
153  timing.m_timer.start();
154  }
155 }
ProcessContext const * m_processContext
PathTiming & pathTiming(StreamContext const &, PathContext const &)
void SystemTimeKeeper::startProcessingLoop ( )

Definition at line 225 of file SystemTimeKeeper.cc.

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

Referenced by edm::Schedule::Schedule().

225  {
227 }
void start()
Definition: CPUTimer.cc:74
void SystemTimeKeeper::stopEvent ( StreamContext const &  iContext)

Definition at line 144 of file SystemTimeKeeper.cc.

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

Referenced by edm::Schedule::Schedule().

144  {
145  m_streamEventTimer[iContext.streamID().value()].stop();
146 }
std::vector< WallclockTimer > m_streamEventTimer
void SystemTimeKeeper::stopModuleEvent ( StreamContext const &  iStream,
ModuleCallingContext const &  iModule 
)

Definition at line 184 of file SystemTimeKeeper.cc.

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(), create_public_lumi_plots::times, edm::ModuleCallingContext::type(), and edm::StreamID::value().

Referenced by edm::Schedule::Schedule().

185  {
186  if(checkBounds(iModule.moduleDescription()->id())) {
187  auto& mod =
188  m_streamModuleTiming[iStream.streamID().value()][iModule.moduleDescription()->id()-m_minModuleID];
189  auto times = mod.m_timer.stop();
190 
191  if(iModule.type() == ParentContext::Type::kPlaceInPath ) {
192  auto place = iModule.placeInPathContext();
193 
194  auto& modTiming = pathTiming(iStream,*(place->pathContext())).m_moduleTiming[place->placeInPath()];
195  modTiming.m_realTime += times;
196  }
197  }
198 }
std::vector< ModuleInPathTiming > m_moduleTiming
std::vector< std::vector< ModuleTiming > > m_streamModuleTiming
PathTiming & pathTiming(StreamContext const &, PathContext const &)
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
bool checkBounds(unsigned int id) const
void SystemTimeKeeper::stopPath ( StreamContext const &  iStream,
PathContext const &  iPath,
HLTPathStatus const &  iStatus 
)

Definition at line 158 of file SystemTimeKeeper.cc.

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

Referenced by edm::Schedule::Schedule().

160  {
161  if(m_processContext == iStream.processContext()) {
162 
163  auto& timing = pathTiming(iStream,iPath);
164  timing.m_timer.stop();
165 
166  //mark all modules up to and including the decision module as being visited
167  auto& modsOnPath = timing.m_moduleTiming;
168  for(unsigned int i = 0; i< iStatus.index()+1;++i) {
169  ++modsOnPath[i].m_timesVisited;
170  }
171  }
172 }
ProcessContext const * m_processContext
PathTiming & pathTiming(StreamContext const &, PathContext const &)
void SystemTimeKeeper::stopProcessingLoop ( )

Definition at line 230 of file SystemTimeKeeper.cc.

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

Referenced by edm::Schedule::Schedule().

230  {
232 }
Times stop()
Definition: CPUTimer.cc:94

Member Data Documentation

unsigned int edm::SystemTimeKeeper::m_endPathOffset
private

Definition at line 112 of file SystemTimeKeeper.h.

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

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

Definition at line 104 of file SystemTimeKeeper.h.

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

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

Definition at line 106 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), and SystemTimeKeeper().

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

Definition at line 113 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), and startEvent().

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

Definition at line 105 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), and SystemTimeKeeper().

ProcessContext const* edm::SystemTimeKeeper::m_processContext
private

Definition at line 109 of file SystemTimeKeeper.h.

Referenced by startPath(), and stopPath().

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

Definition at line 98 of file SystemTimeKeeper.h.

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

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

Definition at line 100 of file SystemTimeKeeper.h.

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