CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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) const
 
SystemTimeKeeperoperator= (const SystemTimeKeeper &)=delete
 
void pauseModuleEvent (StreamContext const &, ModuleCallingContext const &)
 
void removeModuleIfExists (ModuleDescription const &module)
 
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)
 
 SystemTimeKeeper (const SystemTimeKeeper &)=delete
 

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
 
ChildrenCPUTimer m_processingLoopChildrenTimer
 
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 47 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 47 of file SystemTimeKeeper.cc.

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

51  : m_streamEventTimer(iNumStreams),
52  m_streamPathTiming(iNumStreams),
53  m_modules(iModules),
54  m_processContext(iProcessContext),
55  m_minModuleID(0),
56  m_numberOfEvents(0) {
57  std::sort(m_modules.begin(), m_modules.end(), lessModuleDescription);
58  if (not m_modules.empty()) {
59  m_minModuleID = m_modules.front()->id();
60  unsigned int numModuleSlots = m_modules.back()->id() - m_minModuleID + 1;
61  m_streamModuleTiming.resize(iNumStreams);
62  for (auto& stream : m_streamModuleTiming) {
63  stream.resize(numModuleSlots);
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(), iNamesService.getTrigPaths().end(), std::back_inserter(m_pathNames));
74  std::copy(iNamesService.getEndPaths().begin(), iNamesService.getEndPaths().end(), std::back_inserter(m_pathNames));
75 
76  numModulesInPath.reserve(numPaths);
77  numModulesInEndPath.reserve(numEndPaths);
78 
79  m_modulesOnPaths.reserve(numPaths + numEndPaths);
80 
81  for (unsigned int i = 0; i < numPaths; ++i) {
82  numModulesInPath.push_back(iNamesService.getTrigPathModules(i).size());
83  m_modulesOnPaths.push_back(iNamesService.getTrigPathModules(i));
84  }
85  for (unsigned int i = 0; i < numEndPaths; ++i) {
86  numModulesInEndPath.push_back(iNamesService.getEndPathModules(i).size());
87  m_modulesOnPaths.push_back(iNamesService.getEndPathModules(i));
88  }
89 
90  m_endPathOffset = numModulesInPath.size();
91 
92  for (auto& stream : m_streamPathTiming) {
93  unsigned int index = 0;
94  stream.resize(numModulesInPath.size() + numModulesInEndPath.size());
95  for (unsigned int numMods : numModulesInPath) {
96  stream[index].m_moduleTiming.resize(numMods);
97  ++index;
98  }
99  for (unsigned int numMods : numModulesInEndPath) {
100  stream[index].m_moduleTiming.resize(numMods);
101  ++index;
102  }
103  }
104 }
std::vector< std::vector< std::string > > m_modulesOnPaths
std::atomic< unsigned int > m_numberOfEvents
std::vector< std::vector< ModuleTiming > > m_streamModuleTiming
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
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
edm::SystemTimeKeeper::SystemTimeKeeper ( const SystemTimeKeeper )
delete

Member Function Documentation

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

Definition at line 132 of file SystemTimeKeeper.cc.

References m_minModuleID, and m_streamModuleTiming.

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

132  {
133  return id >= m_minModuleID and id < m_streamModuleTiming.front().size() + m_minModuleID;
134 }
std::vector< std::vector< ModuleTiming > > m_streamModuleTiming
void SystemTimeKeeper::fillTriggerTimingReport ( TriggerTimingReport rep) const

Definition at line 249 of file SystemTimeKeeper.cc.

References edm::EventTimingSummary::cpuTime, edm::ChildrenCPUTimer::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_processingLoopChildrenTimer, m_processingLoopTimer, m_streamEventTimer, m_streamModuleTiming, m_streamPathTiming, mod(), gpuClustering::moduleId, fed_dqm_sourceclient-live_cfg::path, edm::EventTimingSummary::realTime, edm::CPUTimer::realTime(), findQualityFiles::size, edm::sort_all(), cms::cuda::stream, edmLumisInFiles::summary, edm::EventTimingSummary::sumStreamRealTime, edm::EventTimingSummary::totalEvents, edm::TriggerTimingReport::trigPathSummaries, class-composition::visited, and edm::TriggerTimingReport::workerSummaries.

249  {
250  {
252  double sumEventTime = 0.;
253  for (auto const& stream : m_streamEventTimer) {
254  sumEventTime += stream.realTime();
255  }
258  rep.eventSummary.sumStreamRealTime = sumEventTime;
259  }
260 
261  //Per module summary
262  {
263  auto& summary = rep.workerSummaries;
264  summary.resize(m_modules.size());
265  //Figure out how often a module was visited
266  std::map<std::string, unsigned int> visited;
267  for (auto const& stream : m_streamPathTiming) {
268  unsigned int pathIndex = 0;
269  for (auto const& path : stream) {
270  unsigned int modIndex = 0;
271  for (auto const& mod : path.m_moduleTiming) {
272  visited[m_modulesOnPaths[pathIndex][modIndex]] += mod.m_timesVisited;
273  ++modIndex;
274  }
275  ++pathIndex;
276  }
277  }
278 
279  unsigned int modIndex = 0;
280  for (auto const& mod : m_modules) {
281  auto& outMod = summary[modIndex];
282  outMod.moduleLabel = mod->moduleLabel();
283  outMod.realTime = 0.;
284 
285  auto moduleId = mod->id() - m_minModuleID;
286  for (auto const& stream : m_streamModuleTiming) {
287  auto const& timing = stream[moduleId];
288  outMod.realTime += timing.m_timer.realTime();
289  outMod.timesRun += timing.m_timesRun;
290  }
291  outMod.timesVisited = visited[mod->moduleLabel()];
292  if (0 == outMod.timesVisited) {
293  outMod.timesVisited = outMod.timesRun;
294  }
295  ++modIndex;
296  }
297  }
299 
300  //Per path summary
301  {
304  m_streamPathTiming[0].size(),
305  m_pathNames,
307  m_streamPathTiming,
308  rep.endPathSummaries);
309  }
310 }
std::vector< std::vector< std::string > > m_modulesOnPaths
std::vector< PathTimingSummary > endPathSummaries
ChildrenCPUTimer m_processingLoopChildrenTimer
std::atomic< unsigned int > m_numberOfEvents
std::vector< std::vector< ModuleTiming > > m_streamModuleTiming
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
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
uint16_t *__restrict__ uint16_t const *__restrict__ uint32_t const *__restrict__ uint32_t *__restrict__ uint32_t const *__restrict__ moduleId
double cpuTime() const
Definition: CPUTimer.cc:146
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
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:139
tuple size
Write out results.
SystemTimeKeeper& edm::SystemTimeKeeper::operator= ( const SystemTimeKeeper )
delete
SystemTimeKeeper::PathTiming & SystemTimeKeeper::pathTiming ( StreamContext const &  iStream,
PathContext const &  iPath 
)
private

Definition at line 118 of file SystemTimeKeeper.cc.

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().

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

Definition at line 185 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(), edm::ModuleCallingContext::type(), and edm::StreamID::value().

Referenced by edm::tns().

185  {
186  if (checkBounds(iModule.moduleDescription()->id())) {
187  auto& mod = m_streamModuleTiming[iStream.streamID().value()][iModule.moduleDescription()->id() - m_minModuleID];
188  auto times = mod.m_timer.stop();
189 
190  if (iModule.type() == ParentContext::Type::kPlaceInPath) {
191  auto place = iModule.placeInPathContext();
192 
193  auto& modTiming = pathTiming(iStream, *(place->pathContext())).m_moduleTiming[place->placeInPath()];
194  modTiming.m_realTime += times;
195  }
196  }
197 }
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::removeModuleIfExists ( ModuleDescription const &  module)

Definition at line 109 of file SystemTimeKeeper.cc.

References newFWLiteAna::found, cuda_std::lower_bound(), m_modules, and callgraph::module.

Referenced by edm::tns().

109  {
110  // The deletion of a module is signaled to all (Sub)Processes, even
111  // though the module exists in only one of them.
112  auto found = std::lower_bound(m_modules.begin(), m_modules.end(), &module, lessModuleDescription);
113  if (*found == &module) {
114  m_modules.erase(found);
115  }
116 }
std::vector< const ModuleDescription * > m_modules
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
tuple module
Definition: callgraph.py:69
void SystemTimeKeeper::restartModuleEvent ( StreamContext const &  iStream,
ModuleCallingContext const &  iModule 
)

Definition at line 198 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::tns().

198  {
199  if (checkBounds(iModule.moduleDescription()->id())) {
200  auto& mod = m_streamModuleTiming[iStream.streamID().value()][iModule.moduleDescription()->id() - m_minModuleID];
201  mod.m_timer.start();
202  }
203 }
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 136 of file SystemTimeKeeper.cc.

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

Referenced by edm::tns().

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

Definition at line 165 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::tns().

165  {
166  if (checkBounds(iModule.moduleDescription()->id())) {
167  auto& mod = m_streamModuleTiming[iStream.streamID().value()][iModule.moduleDescription()->id() - m_minModuleID];
168  mod.m_timer.start();
169  ++(mod.m_timesRun);
170  }
171 }
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 145 of file SystemTimeKeeper.cc.

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

Referenced by edm::tns().

145  {
146  if (m_processContext == iStream.processContext()) {
147  auto& timing = pathTiming(iStream, iPath);
148  timing.m_timer.start();
149  }
150 }
ProcessContext const * m_processContext
PathTiming & pathTiming(StreamContext const &, PathContext const &)
void SystemTimeKeeper::startProcessingLoop ( )
void SystemTimeKeeper::stopEvent ( StreamContext const &  iContext)

Definition at line 141 of file SystemTimeKeeper.cc.

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

Referenced by edm::tns().

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

Definition at line 172 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(), edm::ModuleCallingContext::type(), and edm::StreamID::value().

Referenced by edm::tns().

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

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

Referenced by edm::tns().

152  {
153  if (m_processContext == iStream.processContext()) {
154  auto& timing = pathTiming(iStream, iPath);
155  timing.m_timer.stop();
156 
157  //mark all modules up to and including the decision module as being visited
158  auto& modsOnPath = timing.m_moduleTiming;
159  for (unsigned int i = 0; i < iStatus.index() + 1; ++i) {
160  ++modsOnPath[i].m_timesVisited;
161  }
162  }
163 }
ProcessContext const * m_processContext
PathTiming & pathTiming(StreamContext const &, PathContext const &)
void SystemTimeKeeper::stopProcessingLoop ( )

Member Data Documentation

unsigned int edm::SystemTimeKeeper::m_endPathOffset
private

Definition at line 114 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
std::vector<std::vector<std::string> > edm::SystemTimeKeeper::m_modulesOnPaths
private

Definition at line 107 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), and SystemTimeKeeper().

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

Definition at line 115 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), and startEvent().

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

Definition at line 106 of file SystemTimeKeeper.h.

Referenced by fillTriggerTimingReport(), and SystemTimeKeeper().

ProcessContext const* edm::SystemTimeKeeper::m_processContext
private

Definition at line 111 of file SystemTimeKeeper.h.

Referenced by startPath(), and stopPath().

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

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

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