Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-20 02:14:50

0001 #ifndef FWCore_Framework_SystemTimeKeeper_h
0002 #define FWCore_Framework_SystemTimeKeeper_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/Framework
0006 // Class  :     SystemTimeKeeper
0007 //
0008 /**\class SystemTimeKeeper SystemTimeKeeper.h "SystemTimeKeeper.h"
0009 
0010  Description: Runs timers for system components
0011 
0012  Usage:
0013     This class is used to keep the time that is used to generate
0014  the system time report.
0015 
0016 */
0017 //
0018 // Original Author:  Chris Jones
0019 //         Created:  Mon, 07 Jul 2014 14:37:31 GMT
0020 //
0021 
0022 // system include files
0023 #include <atomic>
0024 #include <vector>
0025 #include <string>
0026 
0027 // user include files
0028 #include "FWCore/Utilities/interface/CPUTimer.h"
0029 #include "FWCore/Utilities/interface/ChildrenCPUTimer.h"
0030 #include "FWCore/Utilities/interface/WallclockTimer.h"
0031 
0032 // forward declarations
0033 
0034 namespace edm {
0035   class ModuleDescription;
0036   class StreamID;
0037   class StreamContext;
0038   class PathContext;
0039   class HLTPathStatus;
0040   class ModuleCallingContext;
0041   class ProcessContext;
0042   struct TriggerTimingReport;
0043   namespace service {
0044     class TriggerNamesService;
0045   }
0046 
0047   class SystemTimeKeeper {
0048   public:
0049     SystemTimeKeeper(unsigned int iNumStreams,
0050                      std::vector<const ModuleDescription*> const& iModules,
0051                      service::TriggerNamesService const& iNameService,
0052                      ProcessContext const* iProcessContext);
0053 
0054     SystemTimeKeeper(const SystemTimeKeeper&) = delete;
0055     SystemTimeKeeper& operator=(const SystemTimeKeeper&) = delete;
0056 
0057     // ---------- const member functions ---------------------
0058 
0059     // ---------- static member functions --------------------
0060 
0061     // ---------- member functions ---------------------------
0062     void removeModuleIfExists(ModuleDescription const& module);
0063 
0064     void startProcessingLoop();
0065     void stopProcessingLoop();
0066 
0067     void startEvent(StreamID);
0068     void stopEvent(StreamContext const&);
0069 
0070     void startPath(StreamContext const&, PathContext const&);
0071     void stopPath(StreamContext const&, PathContext const&, HLTPathStatus const&);
0072 
0073     void startModuleEvent(StreamContext const&, ModuleCallingContext const&);
0074     void stopModuleEvent(StreamContext const&, ModuleCallingContext const&);
0075     void pauseModuleEvent(StreamContext const&, ModuleCallingContext const&);
0076     void restartModuleEvent(StreamContext const&, ModuleCallingContext const&);
0077 
0078     struct ModuleInPathTiming {
0079       double m_realTime = 0.;
0080       unsigned int m_timesVisited = 0;
0081     };
0082     struct PathTiming {
0083       WallclockTimer m_timer;
0084       std::vector<ModuleInPathTiming> m_moduleTiming;
0085     };
0086 
0087     struct ModuleTiming {
0088       WallclockTimer m_timer;
0089       unsigned int m_timesRun = 0;
0090     };
0091 
0092     void fillTriggerTimingReport(TriggerTimingReport& rep) const;
0093 
0094   private:
0095     PathTiming& pathTiming(StreamContext const&, PathContext const&);
0096     bool checkBounds(unsigned int id) const;
0097 
0098     // ---------- member data --------------------------------
0099     std::vector<WallclockTimer> m_streamEventTimer;
0100 
0101     std::vector<std::vector<PathTiming>> m_streamPathTiming;
0102 
0103     std::vector<std::vector<ModuleTiming>> m_streamModuleTiming;
0104 
0105     std::vector<const ModuleDescription*> m_modules;
0106     std::vector<std::string> m_pathNames;
0107     std::vector<std::vector<std::string>> m_modulesOnPaths;
0108 
0109     CPUTimer m_processingLoopTimer;
0110     ChildrenCPUTimer m_processingLoopChildrenTimer;
0111     ProcessContext const* m_processContext;
0112 
0113     unsigned int m_minModuleID;
0114     unsigned int m_endPathOffset;
0115     std::atomic<unsigned int> m_numberOfEvents;
0116   };
0117 }  // namespace edm
0118 
0119 #endif