CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
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 stopEvent (StreamContext const &)
 
void stopModuleEvent (StreamContext const &, ModuleCallingContext const &)
 
void stopPath (StreamContext const &, PathContext const &, HLTPathStatus const &)
 
 SystemTimeKeeper (unsigned int iNumStreams, std::vector< const ModuleDescription * > const &iModules, service::TriggerNamesService const &iNameService)
 

Private Member Functions

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
 
std::vector< CPUTimerm_streamEventTimer
 
std::vector< std::vector
< ModuleTiming > > 
m_streamModuleTiming
 
std::vector< std::vector
< PathTiming > > 
m_streamPathTiming
 

Detailed Description

Definition at line 44 of file SystemTimeKeeper.h.

Constructor & Destructor Documentation

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

Definition at line 40 of file SystemTimeKeeper.cc.

References filterCSVwithJSON::copy, edm::service::TriggerNamesService::getEndPathModules(), edm::service::TriggerNamesService::getEndPaths(), edm::service::TriggerNamesService::getTrigPathModules(), edm::service::TriggerNamesService::getTrigPaths(), i, edm::ModuleDescription::id(), cmsHarvester::index, m_endPathOffset, m_minModuleID, m_modules, m_modulesOnPaths, m_pathNames, m_streamModuleTiming, m_streamPathTiming, python.multivaluedict::sort(), and edmStreamStallGrapher::stream.

42  :
43 m_streamEventTimer(iNumStreams),
44 m_streamPathTiming(iNumStreams),
45 m_modules(iModules),
46 m_minModuleID(0),
48 {
49  std::sort(m_modules.begin(),m_modules.end(),
50  [] (const ModuleDescription* iLHS,
51  const ModuleDescription* iRHS) -> bool {
52  return iLHS->id() < iRHS->id();
53  });
54  if(not m_modules.empty()) {
55  m_minModuleID = m_modules.front()->id();
56  unsigned int numModuleSlots = m_modules.back()->id() - m_minModuleID + 1;
57  m_streamModuleTiming.resize(iNumStreams);
58  for(auto& stream: m_streamModuleTiming) {
59  stream.resize(numModuleSlots);
60  }
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(),
71  iNamesService.getTrigPaths().end(),
72  std::back_inserter(m_pathNames));
73  std::copy(iNamesService.getEndPaths().begin(),
74  iNamesService.getEndPaths().end(),
75  std::back_inserter(m_pathNames));
76 
77  numModulesInPath.reserve(numPaths);
78  numModulesInEndPath.reserve(numEndPaths);
79 
80  m_modulesOnPaths.reserve(numPaths+numEndPaths);
81 
82  for(unsigned int i =0; i<numPaths;++i) {
83  numModulesInPath.push_back(iNamesService.getTrigPathModules(i).size());
84  m_modulesOnPaths.push_back(iNamesService.getTrigPathModules(i));
85  }
86  for(unsigned int i =0; i<numEndPaths;++i) {
87  numModulesInEndPath.push_back(iNamesService.getEndPathModules(i).size());
88  m_modulesOnPaths.push_back(iNamesService.getEndPathModules(i));
89  }
90 
91  m_endPathOffset =numModulesInPath.size();
92 
93  for( auto& stream: m_streamPathTiming) {
94  unsigned int index = 0;
95  stream.resize(numModulesInPath.size()+numModulesInEndPath.size());
96  for(unsigned int numMods : numModulesInPath) {
97  stream[index].m_moduleTiming.resize(numMods);
98  ++index;
99  }
100  for(unsigned int numMods : numModulesInEndPath) {
101  stream[index].m_moduleTiming.resize(numMods);
102  ++index;
103  }
104 
105  }
106 }
std::vector< std::vector< std::string > > m_modulesOnPaths
int i
Definition: DBlmapReader.cc:9
std::atomic< unsigned int > m_numberOfEvents
std::vector< std::vector< ModuleTiming > > m_streamModuleTiming
std::vector< CPUTimer > m_streamEventTimer
std::vector< std::string > m_pathNames
std::vector< const ModuleDescription * > m_modules
unsigned int m_endPathOffset
std::vector< std::vector< PathTiming > > m_streamPathTiming
unsigned int id() const
edm::SystemTimeKeeper::SystemTimeKeeper ( const SystemTimeKeeper )
privatedelete

Member Function Documentation

void SystemTimeKeeper::fillTriggerTimingReport ( TriggerTimingReport rep)

Definition at line 241 of file SystemTimeKeeper.cc.

References edm::EventTimingSummary::cpuTime, edm::TriggerTimingReport::endPathSummaries, edm::TriggerTimingReport::eventSummary, edm::fillPathSummary(), m_endPathOffset, m_minModuleID, m_modules, m_modulesOnPaths, m_numberOfEvents, m_pathNames, m_streamEventTimer, m_streamModuleTiming, m_streamPathTiming, mod(), cmsHarvester::path, edm::EventTimingSummary::realTime, findQualityFiles::size, edmStreamStallGrapher::stream, edmLumisInFiles::summary, edm::EventTimingSummary::totalEvents, edm::TriggerTimingReport::trigPathSummaries, and edm::TriggerTimingReport::workerSummaries.

241  {
242  {
244  double cpuTime = 0.;
245  double realTime = 0.;
246  for(auto const& stream: m_streamEventTimer) {
247  realTime += stream.realTime();
248  cpuTime += stream.cpuTime();
249  }
250  rep.eventSummary.realTime = realTime;
251  rep.eventSummary.cpuTime = cpuTime;
252  }
253 
254  //Per module summary
255  {
256  auto& summary = rep.workerSummaries;
257  summary.resize(m_modules.size());
258  //Figure out how often a module was visited
259  std::map<std::string,unsigned int> visited;
260  for(auto const& stream: m_streamPathTiming) {
261  unsigned int pathIndex = 0;
262  for(auto const& path: stream) {
263  unsigned int modIndex = 0;
264  for(auto const& mod: path.m_moduleTiming) {
265  visited[m_modulesOnPaths[pathIndex][modIndex]] += mod.m_timesVisited;
266  ++modIndex;
267  }
268  ++pathIndex;
269  }
270  }
271 
272  unsigned int modIndex=0;
273  for(auto const& mod: m_modules) {
274  auto& outMod = summary[modIndex];
275  outMod.moduleLabel = mod->moduleLabel();
276  outMod.realTime = 0.;
277  outMod.cpuTime = 0.;
278 
279  auto moduleId =mod->id()-m_minModuleID;
280  for(auto const& stream: m_streamModuleTiming) {
281  auto const& timing = stream[moduleId];
282  outMod.realTime += timing.m_timer.realTime();
283  outMod.cpuTime += timing.m_timer.cpuTime();
284  outMod.timesRun += timing.m_timesRun;
285  }
286  outMod.timesVisited = visited[mod->moduleLabel()];
287  if(0 == outMod.timesVisited) {
288  outMod.timesVisited = outMod.timesRun;
289  }
290  ++modIndex;
291  }
292  }
293 
294  //Per path summary
295  {
297  fillPathSummary(m_endPathOffset, m_streamPathTiming[0].size(), m_pathNames, m_modulesOnPaths, m_streamPathTiming, rep.endPathSummaries);
298  }
299 }
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< CPUTimer > m_streamEventTimer
std::vector< std::string > m_pathNames
tuple path
else: Piece not in the list, fine.
std::vector< const ModuleDescription * > m_modules
EventTimingSummary eventSummary
static void fillPathSummary(Path const &path, PathSummary &sum)
std::vector< PathTimingSummary > trigPathSummaries
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
tuple size
Write out results.
const SystemTimeKeeper& edm::SystemTimeKeeper::operator= ( const SystemTimeKeeper )
privatedelete
SystemTimeKeeper::PathTiming & SystemTimeKeeper::pathTiming ( StreamContext const &  iStream,
PathContext const &  iPath 
)
private

Definition at line 112 of file SystemTimeKeeper.cc.

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

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

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

Definition at line 180 of file SystemTimeKeeper.cc.

References 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::endpathsAreActive_().

181  {
182  auto& mod =
183  m_streamModuleTiming[iStream.streamID().value()][iModule.moduleDescription()->id()-m_minModuleID];
184  auto times = mod.m_timer.stop();
185 
186  if(iModule.type() == ParentContext::Type::kPlaceInPath ) {
187  auto place = iModule.placeInPathContext();
188 
189  auto& modTiming = pathTiming(iStream,*(place->pathContext())).m_moduleTiming[place->placeInPath()];
190  modTiming.m_cpuTime += times.cpu_;
191  modTiming.m_realTime += times.real_;
192  }
193 
194 }
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
void SystemTimeKeeper::restartModuleEvent ( StreamContext const &  iStream,
ModuleCallingContext const &  iModule 
)

Definition at line 196 of file SystemTimeKeeper.cc.

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

Referenced by edm::endpathsAreActive_().

197  {
198  auto& mod =
199  m_streamModuleTiming[iStream.streamID().value()][iModule.moduleDescription()->id()-m_minModuleID];
200  mod.m_timer.start();
201 }
std::vector< std::vector< ModuleTiming > > m_streamModuleTiming
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
void SystemTimeKeeper::startEvent ( StreamID  iID)

Definition at line 125 of file SystemTimeKeeper.cc.

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

Referenced by edm::endpathsAreActive_().

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

Definition at line 158 of file SystemTimeKeeper.cc.

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

Referenced by edm::endpathsAreActive_().

158  {
159  auto& mod =
160  m_streamModuleTiming[iStream.streamID().value()][iModule.moduleDescription()->id()-m_minModuleID];
161  mod.m_timer.start();
162  ++(mod.m_timesRun);
163 
164 }
std::vector< std::vector< ModuleTiming > > m_streamModuleTiming
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
void SystemTimeKeeper::startPath ( StreamContext const &  iStream,
PathContext const &  iPath 
)

Definition at line 136 of file SystemTimeKeeper.cc.

References pathTiming().

Referenced by edm::endpathsAreActive_().

137  {
138  auto& timing = pathTiming(iStream,iPath);
139  timing.m_timer.start();
140 }
PathTiming & pathTiming(StreamContext const &, PathContext const &)
void SystemTimeKeeper::stopEvent ( StreamContext const &  iContext)

Definition at line 131 of file SystemTimeKeeper.cc.

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

Referenced by edm::endpathsAreActive_().

131  {
132  m_streamEventTimer[iContext.streamID().value()].stop();
133 }
std::vector< CPUTimer > m_streamEventTimer
void SystemTimeKeeper::stopModuleEvent ( StreamContext const &  iStream,
ModuleCallingContext const &  iModule 
)

Definition at line 165 of file SystemTimeKeeper.cc.

References 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::endpathsAreActive_().

166  {
167  auto& mod =
168  m_streamModuleTiming[iStream.streamID().value()][iModule.moduleDescription()->id()-m_minModuleID];
169  auto times = mod.m_timer.stop();
170 
171  if(iModule.type() == ParentContext::Type::kPlaceInPath ) {
172  auto place = iModule.placeInPathContext();
173 
174  auto& modTiming = pathTiming(iStream,*(place->pathContext())).m_moduleTiming[place->placeInPath()];
175  modTiming.m_cpuTime += times.cpu_;
176  modTiming.m_realTime += times.real_;
177  }
178 
179 }
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
void SystemTimeKeeper::stopPath ( StreamContext const &  iStream,
PathContext const &  iPath,
HLTPathStatus const &  iStatus 
)

Definition at line 143 of file SystemTimeKeeper.cc.

References i, edm::HLTPathStatus::index(), and pathTiming().

Referenced by edm::endpathsAreActive_().

145  {
146  auto& timing = pathTiming(iStream,iPath);
147  timing.m_timer.stop();
148 
149  //mark all modules up to and including the decision module as being visited
150  auto& modsOnPath = timing.m_moduleTiming;
151  for(unsigned int i = 0; i< iStatus.index()+1;++i) {
152  ++modsOnPath[i].m_timesVisited;
153  }
154 }
int i
Definition: DBlmapReader.cc:9
PathTiming & pathTiming(StreamContext const &, PathContext const &)

Member Data Documentation

unsigned int edm::SystemTimeKeeper::m_endPathOffset
private

Definition at line 103 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 98 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), and SystemTimeKeeper().

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

Definition at line 100 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), and SystemTimeKeeper().

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

Definition at line 104 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), and startEvent().

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

Definition at line 99 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), and SystemTimeKeeper().

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

Definition at line 92 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 94 of file SystemTimeKeeper.h.

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