CMS 3D CMS Logo

Path.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_Path_h
2 #define FWCore_Framework_Path_h
3 
4 /*
5  Author: Jim Kowalkowski 28-01-06
6 
7  An object of this type represents one path in a job configuration.
8  It holds the assigned bit position and the list of workers that are
9  an event must pass through when this parh is processed. The workers
10  are held in WorkerInPath wrappers so that per path execution statistics
11  can be kept for each worker.
12 */
13 
24 
25 #include <memory>
26 
27 #include <string>
28 #include <vector>
29 #include <map>
30 #include <exception>
31 #include <sstream>
32 
33 namespace edm {
34  class EventTransitionInfo;
35  class ModuleDescription;
36  class PathStatusInserter;
37  class EarlyDeleteHelper;
38  class StreamContext;
39  class StreamID;
40 
41  class Path {
42  public:
44 
45  typedef std::vector<WorkerInPath> WorkersInPath;
47  typedef std::shared_ptr<HLTGlobalStatus> TrigResPtr;
48 
49  Path(int bitpos,
50  std::string const& path_name,
51  WorkersInPath const& workers,
52  TrigResPtr trptr,
54  std::shared_ptr<ActivityRegistry> reg,
55  StreamContext const* streamContext,
56  std::atomic<bool>* stopProcessEvent,
57  PathContext::PathType pathType);
58 
59  Path(Path const&);
60 
61  Path& operator=(Path const&) = delete;
62 
63  template <typename T>
65  typename T::TransitionInfoType const&,
66  ServiceToken const&,
67  StreamID const&,
68  typename T::Context const*);
69 
72 
73  int bitPosition() const { return bitpos_; }
74  std::string const& name() const { return pathContext_.pathName(); }
75 
76  void clearCounters();
77 
78  int timesRun() const { return timesRun_; }
79  int timesPassed() const { return timesPassed_; }
80  int timesFailed() const { return timesFailed_; }
81  int timesExcept() const { return timesExcept_; }
82  //int abortWorker() const { return abortWorker_; }
83 
84  size_type size() const { return workers_.size(); }
85  int timesVisited(size_type i) const { return workers_.at(i).timesVisited(); }
86  int timesPassed(size_type i) const { return workers_.at(i).timesPassed(); }
87  int timesFailed(size_type i) const { return workers_.at(i).timesFailed(); }
88  int timesExcept(size_type i) const { return workers_.at(i).timesExcept(); }
89  Worker const* getWorker(size_type i) const { return workers_.at(i).getWorker(); }
90 
91  void setEarlyDeleteHelpers(std::map<const Worker*, EarlyDeleteHelper*> const&);
92 
93  void setPathStatusInserter(PathStatusInserter* pathStatusInserter, Worker* pathStatusInserterWorker);
94 
95  private:
96  int timesRun_;
100  //int abortWorker_;
101  //When an exception happens, it is possible for multiple modules in a path to fail
102  // and then try to change the state concurrently.
103  std::atomic<bool> stateLock_ = false;
106 
107  int const bitpos_;
109  // We do not use propagate_const because the registry itself is mutable.
110  std::shared_ptr<ActivityRegistry> const actReg_;
112 
114 
117  std::atomic<bool>* const stopProcessingEvent_;
118  std::atomic<unsigned int> modulesToRun_;
119 
122 
123  // Helper functions
124  // nwrwue = numWorkersRunWithoutUnhandledException (really!)
126  int nwrwue,
127  bool isEvent,
128  bool begin,
129  BranchType branchType,
130  ModuleDescription const&,
131  std::string const& id) const;
132  static void exceptionContext(cms::Exception& ex,
133  bool isEvent,
134  bool begin,
135  BranchType branchType,
136  ModuleDescription const&,
137  std::string const& id,
138  PathContext const&);
139  void threadsafe_setFailedModuleInfo(int nwrwue, std::exception_ptr);
140  void recordStatus(int nwrwue, hlt::HLTState state);
142 
143  void finished(std::exception_ptr, StreamContext const*, EventTransitionInfo const&, StreamID const&);
144 
145  //Handle asynchronous processing
146  void workerFinished(std::exception_ptr const*,
147  unsigned int iModuleIndex,
148  EventTransitionInfo const&,
149  ServiceToken const&,
150  StreamID const&,
151  StreamContext const*,
152  tbb::task_group& iGroup);
153  void runNextWorkerAsync(unsigned int iNextModuleIndex,
154  EventTransitionInfo const&,
155  ServiceToken const&,
156  StreamID const&,
157  StreamContext const*,
158  tbb::task_group& iGroup);
159  };
160 
161  namespace {
162  template <typename T>
163  class PathSignalSentry {
164  public:
165  PathSignalSentry(ActivityRegistry* a,
166  int const& nwrwue,
167  hlt::HLTState const& state,
168  PathContext const* pathContext)
169  : a_(a), nwrwue_(nwrwue), state_(state), pathContext_(pathContext) {
170  if (a_)
171  T::prePathSignal(a_, pathContext_);
172  }
173  ~PathSignalSentry() {
174  HLTPathStatus status(state_, nwrwue_);
175  if (a_)
176  T::postPathSignal(a_, status, pathContext_);
177  }
178 
179  private:
180  ActivityRegistry* a_; // We do not use propagate_const because the registry itself is mutable.
181  int const& nwrwue_;
182  hlt::HLTState const& state_;
183  PathContext const* pathContext_;
184  };
185  } // namespace
186 
187  template <typename T>
189  typename T::TransitionInfoType const& info,
190  ServiceToken const& token,
191  StreamID const& streamID,
192  typename T::Context const* context) {
193  for (auto& worker : workers_) {
194  worker.runWorkerAsync<T>(task, info, token, streamID, context);
195  }
196  }
197 
198 } // namespace edm
199 
200 #endif
edm::Path::size_type
WorkersInPath::size_type size_type
Definition: Path.h:46
edm::EventTransitionInfo
Definition: TransitionInfoTypes.h:26
edm::hlt::HLTState
HLTState
status of a trigger path
Definition: HLTenums.h:16
edm::Path::pathStatusInserterWorker_
Worker * pathStatusInserterWorker_
Definition: Path.h:121
edm::StreamID
Definition: StreamID.h:30
edm::Path::pathStatusInserter_
PathStatusInserter * pathStatusInserter_
Definition: Path.h:120
mps_fire.i
i
Definition: mps_fire.py:428
edm::Path::getWorker
Worker const * getWorker(size_type i) const
Definition: Path.h:89
edm::Path::stateLock_
std::atomic< bool > stateLock_
Definition: Path.h:103
BranchType.h
TriggerResults.h
ActivityRegistry
edm::Path::threadsafe_setFailedModuleInfo
void threadsafe_setFailedModuleInfo(int nwrwue, std::exception_ptr)
Definition: Path.cc:149
edm::Path::waitingTasks_
WaitingTaskList waitingTasks_
Definition: Path.h:116
mps_update.status
status
Definition: mps_update.py:68
WaitingTaskHolder.h
edm::Path::modulesToRun_
std::atomic< unsigned int > modulesToRun_
Definition: Path.h:118
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::Path::timesExcept
int timesExcept() const
Definition: Path.h:81
edm::Path::workerFinished
void workerFinished(std::exception_ptr const *, unsigned int iModuleIndex, EventTransitionInfo const &, ServiceToken const &, StreamID const &, StreamContext const *, tbb::task_group &iGroup)
Definition: Path.cc:244
edm::Path::WorkersInPath
std::vector< WorkerInPath > WorkersInPath
Definition: Path.h:45
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
edm::Path::bitpos_
const int bitpos_
Definition: Path.h:107
WorkerInPath.h
edm::Path::TrigResPtr
std::shared_ptr< HLTGlobalStatus > TrigResPtr
Definition: Path.h:47
edm::Path::timesFailed_
int timesFailed_
Definition: Path.h:98
edm::BranchType
BranchType
Definition: BranchType.h:11
edm::ModuleDescription
Definition: ModuleDescription.h:21
edm::Path::State
hlt::HLTState State
Definition: Path.h:43
edm::Path::timesExcept_
int timesExcept_
Definition: Path.h:99
edm::WaitingTaskList
Definition: WaitingTaskList.h:84
visDQMUpload.context
context
Definition: visDQMUpload.py:37
edm::Path::timesExcept
int timesExcept(size_type i) const
Definition: Path.h:88
edm::ServiceToken
Definition: ServiceToken.h:42
edm::Path::stopProcessingEvent_
std::atomic< bool > *const stopProcessingEvent_
Definition: Path.h:117
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
edm::Path::updateCounters
void updateCounters(hlt::HLTState state)
Definition: Path.cc:181
edm::StreamContext
Definition: StreamContext.h:31
edm::Path::setPathStatusInserter
void setPathStatusInserter(PathStatusInserter *pathStatusInserter, Worker *pathStatusInserterWorker)
Definition: Path.cc:213
edm::Path::pathContext_
PathContext pathContext_
Definition: Path.h:115
TrackValidation_cff.task
task
Definition: TrackValidation_cff.py:253
edm::PathContext::PathType
PathType
Definition: PathContext.h:26
edm::ActivityRegistry
Definition: ActivityRegistry.h:134
edm::Path::operator=
Path & operator=(Path const &)=delete
edm::Path::timesFailed
int timesFailed() const
Definition: Path.h:80
make_sentry.h
ConvertException.h
edm::Worker
Definition: Worker.h:91
edm::Path::timesVisited
int timesVisited(size_type i) const
Definition: Path.h:85
edm::Path::trptr_
const TrigResPtr trptr_
Definition: Path.h:108
edm::Path::timesFailed
int timesFailed(size_type i) const
Definition: Path.h:87
edm::Path::finished
void finished(std::exception_ptr, StreamContext const *, EventTransitionInfo const &, StreamID const &)
Definition: Path.cc:320
a
double a
Definition: hdecay.h:119
edm::Path::Path
Path(int bitpos, std::string const &path_name, WorkersInPath const &workers, TrigResPtr trptr, ExceptionToActionTable const &actions, std::shared_ptr< ActivityRegistry > reg, StreamContext const *streamContext, std::atomic< bool > *stopProcessEvent, PathContext::PathType pathType)
Definition: Path.cc:18
edm::Path::size
size_type size() const
Definition: Path.h:84
edm::WaitingTaskHolder
Definition: WaitingTaskHolder.h:32
edm::Path::runNextWorkerAsync
void runNextWorkerAsync(unsigned int iNextModuleIndex, EventTransitionInfo const &, ServiceToken const &, StreamID const &, StreamContext const *, tbb::task_group &iGroup)
Definition: Path.cc:348
edm::PathContext
Definition: PathContext.h:24
edm::Path::act_table_
ExceptionToActionTable const *const act_table_
Definition: Path.h:111
edm::Path::workers_
WorkersInPath workers_
Definition: Path.h:113
edm::PathStatusInserter
Definition: PathStatusInserter.h:15
edm::Path
Definition: Path.h:41
edm::Path::exceptionContext
static void exceptionContext(cms::Exception &ex, bool isEvent, bool begin, BranchType branchType, ModuleDescription const &, std::string const &id, PathContext const &)
Definition: Path.cc:119
edm::Path::actReg_
const std::shared_ptr< ActivityRegistry > actReg_
Definition: Path.h:110
edm::Path::failedModuleIndex_
int failedModuleIndex_
Definition: Path.h:104
edm::ExceptionToActionTable
Definition: ExceptionActions.h:16
PathContext.h
edm::PathContext::pathName
std::string const & pathName() const
Definition: PathContext.h:30
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Path::setEarlyDeleteHelpers
void setEarlyDeleteHelpers(std::map< const Worker *, EarlyDeleteHelper * > const &)
Definition: Path.cc:204
EarlyDeleteHelper
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
edm::Path::name
std::string const & name() const
Definition: Path.h:74
T
long double T
Definition: Basic3DVectorLD.h:48
edm::Path::runAllModulesAsync
void runAllModulesAsync(WaitingTaskHolder, typename T::TransitionInfoType const &, ServiceToken const &, StreamID const &, typename T::Context const *)
Definition: Path.h:188
Worker.h
edm::Path::processOneOccurrenceAsync
void processOneOccurrenceAsync(WaitingTaskHolder, EventTransitionInfo const &, ServiceToken const &, StreamID const &, StreamContext const *)
Definition: Path.cc:218
Exception.h
edm::Path::timesPassed
int timesPassed() const
Definition: Path.h:79
HLTenums.h
actions
roAction_t actions[nactions]
Definition: GenABIO.cc:181
cms::Exception
Definition: Exception.h:70
edm::Path::bitPosition
int bitPosition() const
Definition: Path.h:73
edm::Path::handleWorkerFailure
bool handleWorkerFailure(cms::Exception &e, int nwrwue, bool isEvent, bool begin, BranchType branchType, ModuleDescription const &, std::string const &id) const
Definition: Path.cc:70
edm::Path::timesRun_
int timesRun_
Definition: Path.h:96
edm::Path::timesPassed
int timesPassed(size_type i) const
Definition: Path.h:86
edm::Path::clearCounters
void clearCounters()
Definition: Path.cc:198
edm::Path::recordStatus
void recordStatus(int nwrwue, hlt::HLTState state)
Definition: Path.cc:175
CMS_THREAD_GUARD
#define CMS_THREAD_GUARD(_var_)
Definition: thread_safety_macros.h:6
edm::Path::state_
State state_
Definition: Path.h:105
EcalCalibMonitorClient_cfi.workers
workers
Definition: EcalCalibMonitorClient_cfi.py:19
edm::Path::timesRun
int timesRun() const
Definition: Path.h:78
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316
edm::Path::timesPassed_
int timesPassed_
Definition: Path.h:97