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 EventPrincipal;
34  class EventSetupImpl;
35  class ModuleDescription;
36  class PathStatusInserter;
37  class RunPrincipal;
38  class LuminosityBlockPrincipal;
39  class EarlyDeleteHelper;
40  class StreamContext;
41  class StreamID;
42  class WaitingTask;
43 
44  class Path {
45  public:
47 
48  typedef std::vector<WorkerInPath> WorkersInPath;
50  typedef std::shared_ptr<HLTGlobalStatus> TrigResPtr;
51 
52  Path(int bitpos,
53  std::string const& path_name,
54  WorkersInPath const& workers,
55  TrigResPtr trptr,
57  std::shared_ptr<ActivityRegistry> reg,
58  StreamContext const* streamContext,
59  std::atomic<bool>* stopProcessEvent,
60  PathContext::PathType pathType);
61 
62  Path(Path const&);
63 
64  template <typename T>
66  typename T::MyPrincipal const&,
67  EventSetupImpl const&,
68  ServiceToken const&,
69  StreamID const&,
70  typename T::Context const*);
71 
73  EventPrincipal const&,
74  EventSetupImpl const&,
75  ServiceToken const&,
76  StreamID const&,
77  StreamContext const*);
78 
79  int bitPosition() const { return bitpos_; }
80  std::string const& name() const { return pathContext_.pathName(); }
81 
82  void clearCounters();
83 
84  int timesRun() const { return timesRun_; }
85  int timesPassed() const { return timesPassed_; }
86  int timesFailed() const { return timesFailed_; }
87  int timesExcept() const { return timesExcept_; }
88  //int abortWorker() const { return abortWorker_; }
89 
90  size_type size() const { return workers_.size(); }
91  int timesVisited(size_type i) const { return workers_.at(i).timesVisited(); }
92  int timesPassed(size_type i) const { return workers_.at(i).timesPassed(); }
93  int timesFailed(size_type i) const { return workers_.at(i).timesFailed(); }
94  int timesExcept(size_type i) const { return workers_.at(i).timesExcept(); }
95  Worker const* getWorker(size_type i) const { return workers_.at(i).getWorker(); }
96 
97  void setEarlyDeleteHelpers(std::map<const Worker*, EarlyDeleteHelper*> const&);
98 
99  void setPathStatusInserter(PathStatusInserter* pathStatusInserter, Worker* pathStatusInserterWorker);
100 
101  private:
102  // If you define this be careful about the pointer in the
103  // PlaceInPathContext object in the contained WorkerInPath objects.
104  Path const& operator=(Path const&) = delete; // stop default
105 
110  //int abortWorker_;
111  //When an exception happens, it is possible for multiple modules in a path to fail
112  // and then try to change the state concurrently.
113  std::atomic<bool> stateLock_ = false;
116 
117  int const bitpos_;
119  // We do not use propagate_const because the registry itself is mutable.
120  std::shared_ptr<ActivityRegistry> const actReg_;
122 
124 
127  std::atomic<bool>* const stopProcessingEvent_;
128  std::atomic<unsigned int> modulesToRun_;
129 
132 
133  // Helper functions
134  // nwrwue = numWorkersRunWithoutUnhandledException (really!)
136  int nwrwue,
137  bool isEvent,
138  bool begin,
139  BranchType branchType,
140  ModuleDescription const&,
141  std::string const& id) const;
142  static void exceptionContext(cms::Exception& ex,
143  bool isEvent,
144  bool begin,
145  BranchType branchType,
146  ModuleDescription const&,
147  std::string const& id,
148  PathContext const&);
149  void threadsafe_setFailedModuleInfo(int nwrwue, std::exception_ptr);
150  void recordStatus(int nwrwue, hlt::HLTState state);
151  void updateCounters(hlt::HLTState state);
152 
153  void finished(std::exception_ptr,
154  StreamContext const*,
155  EventPrincipal const& iEP,
156  EventSetupImpl const& iES,
157  StreamID const& streamID);
158 
159  //Handle asynchronous processing
160  void workerFinished(std::exception_ptr const* iException,
161  unsigned int iModuleIndex,
162  EventPrincipal const& iEP,
163  EventSetupImpl const& iES,
164  ServiceToken const& iToken,
165  StreamID const& iID,
166  StreamContext const* iContext);
167  void runNextWorkerAsync(unsigned int iNextModuleIndex,
168  EventPrincipal const&,
169  EventSetupImpl const&,
170  ServiceToken const&,
171  StreamID const&,
172  StreamContext const*);
173  };
174 
175  namespace {
176  template <typename T>
177  class PathSignalSentry {
178  public:
179  PathSignalSentry(ActivityRegistry* a,
180  int const& nwrwue,
181  hlt::HLTState const& state,
182  PathContext const* pathContext)
183  : a_(a), nwrwue_(nwrwue), state_(state), pathContext_(pathContext) {
184  if (a_)
185  T::prePathSignal(a_, pathContext_);
186  }
187  ~PathSignalSentry() {
188  HLTPathStatus status(state_, nwrwue_);
189  if (a_)
190  T::postPathSignal(a_, status, pathContext_);
191  }
192 
193  private:
194  ActivityRegistry* a_; // We do not use propagate_const because the registry itself is mutable.
195  int const& nwrwue_;
196  hlt::HLTState const& state_;
197  PathContext const* pathContext_;
198  };
199  } // namespace
200 
201  template <typename T>
203  typename T::MyPrincipal const& p,
204  EventSetupImpl const& es,
205  ServiceToken const& token,
206  StreamID const& streamID,
207  typename T::Context const* context) {
208  for (auto& worker : workers_) {
209  worker.runWorkerAsync<T>(task, p, es, token, streamID, context);
210  }
211  }
212 
213 } // namespace edm
214 
215 #endif
edm::Path::size_type
WorkersInPath::size_type size_type
Definition: Path.h:49
edm::hlt::HLTState
HLTState
status of a trigger path
Definition: HLTenums.h:16
edm::Path::pathStatusInserterWorker_
Worker * pathStatusInserterWorker_
Definition: Path.h:131
edm::StreamID
Definition: StreamID.h:30
edm::Path::pathStatusInserter_
PathStatusInserter * pathStatusInserter_
Definition: Path.h:130
mps_fire.i
i
Definition: mps_fire.py:355
edm::Path::getWorker
Worker const * getWorker(size_type i) const
Definition: Path.h:95
edm::Path::stateLock_
std::atomic< bool > stateLock_
Definition: Path.h:113
edm::Path::runAllModulesAsync
void runAllModulesAsync(WaitingTask *, typename T::MyPrincipal const &, EventSetupImpl const &, ServiceToken const &, StreamID const &, typename T::Context const *)
Definition: Path.h:202
BranchType.h
TriggerResults.h
ActivityRegistry
edm::Path::threadsafe_setFailedModuleInfo
void threadsafe_setFailedModuleInfo(int nwrwue, std::exception_ptr)
Definition: Path.cc:147
edm::Path::waitingTasks_
WaitingTaskList waitingTasks_
Definition: Path.h:126
edm::EventSetupImpl
Definition: EventSetupImpl.h:44
mps_update.status
status
Definition: mps_update.py:69
edm::Path::modulesToRun_
std::atomic< unsigned int > modulesToRun_
Definition: Path.h:128
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::Path::timesExcept
int timesExcept() const
Definition: Path.h:87
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::Path::WorkersInPath
std::vector< WorkerInPath > WorkersInPath
Definition: Path.h:48
edm::Path::bitpos_
const int bitpos_
Definition: Path.h:117
WorkerInPath.h
edm::Path::TrigResPtr
std::shared_ptr< HLTGlobalStatus > TrigResPtr
Definition: Path.h:50
edm::Path::processOneOccurrenceAsync
void processOneOccurrenceAsync(WaitingTask *, EventPrincipal const &, EventSetupImpl const &, ServiceToken const &, StreamID const &, StreamContext const *)
Definition: Path.cc:216
edm::Path::timesFailed_
int timesFailed_
Definition: Path.h:108
edm::Path::finished
void finished(std::exception_ptr, StreamContext const *, EventPrincipal const &iEP, EventSetupImpl const &iES, StreamID const &streamID)
Definition: Path.cc:316
edm::BranchType
BranchType
Definition: BranchType.h:11
edm::ModuleDescription
Definition: ModuleDescription.h:21
edm::Path::State
hlt::HLTState State
Definition: Path.h:46
edm::Path::timesExcept_
int timesExcept_
Definition: Path.h:109
edm::WaitingTaskList
Definition: WaitingTaskList.h:101
edm::Path::timesExcept
int timesExcept(size_type i) const
Definition: Path.h:94
edm::ServiceToken
Definition: ServiceToken.h:40
edm::Path::stopProcessingEvent_
std::atomic< bool > *const stopProcessingEvent_
Definition: Path.h:127
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
edm::Path::updateCounters
void updateCounters(hlt::HLTState state)
Definition: Path.cc:179
edm::EventPrincipal
Definition: EventPrincipal.h:46
edm::StreamContext
Definition: StreamContext.h:31
edm::Path::setPathStatusInserter
void setPathStatusInserter(PathStatusInserter *pathStatusInserter, Worker *pathStatusInserterWorker)
Definition: Path.cc:211
WaitingTask
edm::Path::pathContext_
PathContext pathContext_
Definition: Path.h:125
TrackValidation_cff.task
task
Definition: TrackValidation_cff.py:252
edm::PathContext::PathType
PathType
Definition: PathContext.h:26
edm::ActivityRegistry
Definition: ActivityRegistry.h:132
edm::Path::timesFailed
int timesFailed() const
Definition: Path.h:86
make_sentry.h
ConvertException.h
edm::Worker
Definition: Worker.h:83
edm::Path::timesVisited
int timesVisited(size_type i) const
Definition: Path.h:91
edm::Path::trptr_
const TrigResPtr trptr_
Definition: Path.h:118
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Path::timesFailed
int timesFailed(size_type i) const
Definition: Path.h:93
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:16
edm::Path::size
size_type size() const
Definition: Path.h:90
edm::PathContext
Definition: PathContext.h:24
edm::Path::act_table_
ExceptionToActionTable const *const act_table_
Definition: Path.h:121
edm::Path::workers_
WorkersInPath workers_
Definition: Path.h:123
edm::PathStatusInserter
Definition: PathStatusInserter.h:15
edm::Path
Definition: Path.h:44
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:117
edm::Path::actReg_
const std::shared_ptr< ActivityRegistry > actReg_
Definition: Path.h:120
edm::Path::failedModuleIndex_
int failedModuleIndex_
Definition: Path.h:114
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:202
edm::Path::operator=
Path const & operator=(Path const &)=delete
EarlyDeleteHelper
edm::WaitingTask
Definition: WaitingTask.h:36
edm::Path::name
std::string const & name() const
Definition: Path.h:80
T
long double T
Definition: Basic3DVectorLD.h:48
Worker.h
Exception.h
edm::Path::timesPassed
int timesPassed() const
Definition: Path.h:85
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:79
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:68
edm::Path::timesRun_
int timesRun_
Definition: Path.h:106
edm::Path::timesPassed
int timesPassed(size_type i) const
Definition: Path.h:92
edm::Path::clearCounters
void clearCounters()
Definition: Path.cc:196
edm::Path::recordStatus
void recordStatus(int nwrwue, hlt::HLTState state)
Definition: Path.cc:173
edm::Path::workerFinished
void workerFinished(std::exception_ptr const *iException, unsigned int iModuleIndex, EventPrincipal const &iEP, EventSetupImpl const &iES, ServiceToken const &iToken, StreamID const &iID, StreamContext const *iContext)
Definition: Path.cc:243
CMS_THREAD_GUARD
#define CMS_THREAD_GUARD(_var_)
Definition: thread_safety_macros.h:6
edm::Path::state_
State state_
Definition: Path.h:115
EcalCalibMonitorClient_cfi.workers
workers
Definition: EcalCalibMonitorClient_cfi.py:19
edm::Path::timesRun
int timesRun() const
Definition: Path.h:84
begin
#define begin
Definition: vmac.h:32
edm::Path::runNextWorkerAsync
void runNextWorkerAsync(unsigned int iNextModuleIndex, EventPrincipal const &, EventSetupImpl const &, ServiceToken const &, StreamID const &, StreamContext const *)
Definition: Path.cc:345
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:107