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 
23 
24 #include <memory>
25 
26 #include <string>
27 #include <vector>
28 #include <map>
29 #include <exception>
30 #include <sstream>
31 
32 namespace edm {
33  class EventTransitionInfo;
34  class ModuleDescription;
35  class PathStatusInserter;
36  class EarlyDeleteHelper;
37  class StreamContext;
38  class StreamID;
39  class WaitingTask;
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 
71  WaitingTask*, EventTransitionInfo const&, ServiceToken const&, StreamID const&, StreamContext const*);
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  void runNextWorkerAsync(unsigned int iNextModuleIndex,
153  EventTransitionInfo const&,
154  ServiceToken const&,
155  StreamID const&,
156  StreamContext const*);
157  };
158 
159  namespace {
160  template <typename T>
161  class PathSignalSentry {
162  public:
163  PathSignalSentry(ActivityRegistry* a,
164  int const& nwrwue,
165  hlt::HLTState const& state,
166  PathContext const* pathContext)
167  : a_(a), nwrwue_(nwrwue), state_(state), pathContext_(pathContext) {
168  if (a_)
169  T::prePathSignal(a_, pathContext_);
170  }
171  ~PathSignalSentry() {
172  HLTPathStatus status(state_, nwrwue_);
173  if (a_)
174  T::postPathSignal(a_, status, pathContext_);
175  }
176 
177  private:
178  ActivityRegistry* a_; // We do not use propagate_const because the registry itself is mutable.
179  int const& nwrwue_;
180  hlt::HLTState const& state_;
181  PathContext const* pathContext_;
182  };
183  } // namespace
184 
185  template <typename T>
187  typename T::TransitionInfoType const& info,
188  ServiceToken const& token,
189  StreamID const& streamID,
190  typename T::Context const* context) {
191  for (auto& worker : workers_) {
192  worker.runWorkerAsync<T>(task, info, token, streamID, context);
193  }
194  }
195 
196 } // namespace edm
197 
198 #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::runAllModulesAsync
void runAllModulesAsync(WaitingTask *, typename T::TransitionInfoType const &, ServiceToken const &, StreamID const &, typename T::Context const *)
Definition: Path.h:186
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:69
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::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:101
edm::Path::timesExcept
int timesExcept(size_type i) const
Definition: Path.h:88
edm::ServiceToken
Definition: ServiceToken.h:40
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
WaitingTask
edm::Path::pathContext_
PathContext pathContext_
Definition: Path.h:115
TrackValidation_cff.task
task
Definition: TrackValidation_cff.py:252
edm::PathContext::PathType
PathType
Definition: PathContext.h:26
edm::ActivityRegistry
Definition: ActivityRegistry.h:133
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:88
edm::Path::timesVisited
int timesVisited(size_type i) const
Definition: Path.h:85
edm::Path::trptr_
const TrigResPtr trptr_
Definition: Path.h:108
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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:317
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::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::runNextWorkerAsync
void runNextWorkerAsync(unsigned int iNextModuleIndex, EventTransitionInfo const &, ServiceToken const &, StreamID const &, StreamContext const *)
Definition: Path.cc:345
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
edm::Path::setEarlyDeleteHelpers
void setEarlyDeleteHelpers(std::map< const Worker *, EarlyDeleteHelper * > const &)
Definition: Path.cc:204
EarlyDeleteHelper
edm::WaitingTask
Definition: WaitingTask.h:36
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
Worker.h
edm::Path::workerFinished
void workerFinished(std::exception_ptr const *, unsigned int iModuleIndex, EventTransitionInfo const &, ServiceToken const &, StreamID const &, StreamContext const *)
Definition: Path.cc:244
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
edm::Path::processOneOccurrenceAsync
void processOneOccurrenceAsync(WaitingTask *, EventTransitionInfo const &, ServiceToken const &, StreamID const &, StreamContext const *)
Definition: Path.cc:218
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:318
edm::Path::timesPassed_
int timesPassed_
Definition: Path.h:97