CMS 3D CMS Logo

WorkerInPath.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_WorkerInPath_h
2 #define FWCore_Framework_WorkerInPath_h
3 
4 /*
5 
6  Author: Jim Kowalkowski 28-01-06
7 
8 
9  A wrapper around a Worker, so that statistics can be managed
10  per path. A Path holds Workers as these things.
11 
12 */
13 
17 
18 namespace edm {
19 
20  class PathContext;
21  class StreamID;
22  class WaitingTask;
23  class ServiceToken;
24 
25  class WorkerInPath {
26  public:
27  enum FilterAction { Normal = 0, Ignore, Veto };
28 
29  WorkerInPath(Worker*, FilterAction theAction, unsigned int placeInPath, bool runConcurrently);
30 
31  template <typename T>
32  void runWorkerAsync(WaitingTask* iTask,
33  typename T::MyPrincipal const&,
34  EventSetupImpl const&,
35  ServiceToken const&,
36  StreamID streamID,
37  typename T::Context const* context);
38 
39  bool checkResultsOfRunWorker(bool wasEvent);
40 
41  void skipWorker(EventPrincipal const& iPrincipal) { worker_->skipOnPath(iPrincipal); }
42  void skipWorker(RunPrincipal const&) {}
44 
46 
47  int timesVisited() const { return timesVisited_; }
48  int timesPassed() const { return timesPassed_; }
49  int timesFailed() const { return timesFailed_; }
50  int timesExcept() const { return timesExcept_; }
51 
53  Worker* getWorker() const { return worker_; }
54  bool runConcurrently() const noexcept { return runConcurrently_; }
55 
57 
58  private:
63 
66 
69  };
70 
71  inline bool WorkerInPath::checkResultsOfRunWorker(bool wasEvent) {
72  if (not wasEvent) {
73  return true;
74  }
75  auto state = worker_->state();
76  bool rc = true;
77  switch (state) {
78  case Worker::Fail: {
79  rc = false;
80  break;
81  }
82  case Worker::Pass:
83  break;
84  case Worker::Exception: {
85  ++timesExcept_;
86  return true;
87  }
88 
89  default:
90  assert(false);
91  }
92 
93  if (Ignore == filterAction()) {
94  rc = true;
95  } else if (Veto == filterAction()) {
96  rc = !rc;
97  }
98 
99  if (rc) {
100  ++timesPassed_;
101  } else {
102  ++timesFailed_;
103  }
104  return rc;
105  }
106 
107  template <typename T>
109  typename T::MyPrincipal const& ep,
110  EventSetupImpl const& es,
111  ServiceToken const& token,
112  StreamID streamID,
113  typename T::Context const* context) {
114  if constexpr (T::isEvent_) {
115  ++timesVisited_;
116  }
117 
118  if constexpr (T::isEvent_) {
119  ParentContext parentContext(&placeInPathContext_);
120  worker_->doWorkAsync<T>(iTask, ep, es, token, streamID, parentContext, context);
121  } else {
122  ParentContext parentContext(context);
123 
124  // We do not need to run prefetching here because this only handles
125  // stream transitions for runs and lumis. There are no products put
126  // into the runs or lumis in stream transitions, so there can be
127  // no data dependencies which require prefetching. Prefetching is
128  // needed for global transitions, but they are run elsewhere.
129  worker_->doWorkNoPrefetchingAsync<T>(iTask, ep, es, token, streamID, parentContext, context);
130  }
131  }
132 } // namespace edm
133 
134 #endif
edm::StreamID
Definition: StreamID.h:30
edm::WorkerInPath::timesExcept
int timesExcept() const
Definition: WorkerInPath.h:50
edm::WorkerInPath::timesExcept_
int timesExcept_
Definition: WorkerInPath.h:62
edm::WorkerInPath::getWorker
Worker * getWorker() const
Definition: WorkerInPath.h:53
edm::WorkerInPath::WorkerInPath
WorkerInPath(Worker *, FilterAction theAction, unsigned int placeInPath, bool runConcurrently)
Definition: WorkerInPath.cc:6
edm::EventSetupImpl
Definition: EventSetupImpl.h:44
edm::WorkerInPath::skipWorker
void skipWorker(EventPrincipal const &iPrincipal)
Definition: WorkerInPath.h:41
PlaceInPathContext.h
edm::Worker::Fail
Definition: Worker.h:85
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::Worker::Exception
Definition: Worker.h:85
edm::WorkerInPath::filterAction_
FilterAction filterAction_
Definition: WorkerInPath.h:64
edm::WorkerInPath::skipWorker
void skipWorker(LuminosityBlockPrincipal const &)
Definition: WorkerInPath.h:43
edm::LuminosityBlockPrincipal
Definition: LuminosityBlockPrincipal.h:31
cms::cuda::assert
assert(be >=bs)
findQualityFiles.v
v
Definition: findQualityFiles.py:179
edm::WorkerInPath::timesVisited
int timesVisited() const
Definition: WorkerInPath.h:47
watchdog.const
const
Definition: watchdog.py:83
edm::WorkerInPath::runConcurrently
bool runConcurrently() const noexcept
Definition: WorkerInPath.h:54
edm::WorkerInPath::runConcurrently_
bool runConcurrently_
Definition: WorkerInPath.h:68
edm::WorkerInPath::timesFailed
int timesFailed() const
Definition: WorkerInPath.h:49
edm::ServiceToken
Definition: ServiceToken.h:40
edm::WorkerInPath::timesPassed_
int timesPassed_
Definition: WorkerInPath.h:60
edm::EventPrincipal
Definition: EventPrincipal.h:46
edm::WorkerInPath::placeInPathContext_
PlaceInPathContext placeInPathContext_
Definition: WorkerInPath.h:67
WaitingTask
edm::WorkerInPath::Ignore
Definition: WorkerInPath.h:27
edm::Worker::Pass
Definition: Worker.h:85
edm::Worker
Definition: Worker.h:83
edm::WorkerInPath::Normal
Definition: WorkerInPath.h:27
edm::ParentContext
Definition: ParentContext.h:27
edm::WorkerInPath::FilterAction
FilterAction
Definition: WorkerInPath.h:27
edm::PlaceInPathContext::setPathContext
void setPathContext(PathContext const *v)
Definition: PlaceInPathContext.h:26
edm::PathContext
Definition: PathContext.h:24
edm::Worker::doWorkAsync
void doWorkAsync(WaitingTask *task, typename T::MyPrincipal const &, EventSetupImpl const &c, ServiceToken const &token, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
Definition: Worker.h:831
edm::WorkerInPath::checkResultsOfRunWorker
bool checkResultsOfRunWorker(bool wasEvent)
Definition: WorkerInPath.h:71
edm::WorkerInPath::filterAction
FilterAction filterAction() const
Definition: WorkerInPath.h:52
edm::Worker::state
State state() const
Definition: Worker.h:232
ServiceToken
edm::WorkerInPath::clearCounters
void clearCounters()
Definition: WorkerInPath.h:45
edm::WorkerInPath::worker_
Worker * worker_
Definition: WorkerInPath.h:65
ParentContext.h
edm::WaitingTask
Definition: WaitingTask.h:36
T
long double T
Definition: Basic3DVectorLD.h:48
edm::Worker::skipOnPath
void skipOnPath(EventPrincipal const &iEvent)
Definition: Worker.cc:363
Worker.h
edm::WorkerInPath
Definition: WorkerInPath.h:25
edm::WorkerInPath::Veto
Definition: WorkerInPath.h:27
edm::Worker::doWorkNoPrefetchingAsync
void doWorkNoPrefetchingAsync(WaitingTask *task, typename T::MyPrincipal const &, EventSetupImpl const &c, ServiceToken const &token, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
Definition: Worker.h:934
edm::WorkerInPath::timesFailed_
int timesFailed_
Definition: WorkerInPath.h:61
edm::WorkerInPath::timesVisited_
int timesVisited_
Definition: WorkerInPath.h:59
edm::RunPrincipal
Definition: RunPrincipal.h:34
edm::WorkerInPath::setPathContext
void setPathContext(PathContext const *v)
Definition: WorkerInPath.h:56
edm::PlaceInPathContext
Definition: PlaceInPathContext.h:19
SiStripBadComponentsDQMServiceTemplate_cfg.ep
ep
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:86
edm::WorkerInPath::timesPassed
int timesPassed() const
Definition: WorkerInPath.h:48
edm::WorkerInPath::skipWorker
void skipWorker(RunPrincipal const &)
Definition: WorkerInPath.h:42
edm::WorkerInPath::runWorkerAsync
void runWorkerAsync(WaitingTask *iTask, typename T::MyPrincipal const &, EventSetupImpl const &, ServiceToken const &, StreamID streamID, typename T::Context const *context)
Definition: WorkerInPath.h:108
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316