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(
33  WaitingTask*, typename T::TransitionInfoType const&, ServiceToken const&, StreamID, typename T::Context const*);
34 
35  bool checkResultsOfRunWorker(bool wasEvent);
36 
37  void skipWorker(EventPrincipal const& iPrincipal) { worker_->skipOnPath(iPrincipal); }
38  void skipWorker(RunPrincipal const&) {}
40 
42 
43  int timesVisited() const { return timesVisited_; }
44  int timesPassed() const { return timesPassed_; }
45  int timesFailed() const { return timesFailed_; }
46  int timesExcept() const { return timesExcept_; }
47 
49  Worker* getWorker() const { return worker_; }
50  bool runConcurrently() const noexcept { return runConcurrently_; }
51 
53 
54  private:
59 
62 
65  };
66 
67  inline bool WorkerInPath::checkResultsOfRunWorker(bool wasEvent) {
68  if (not wasEvent) {
69  return true;
70  }
71  auto state = worker_->state();
72  bool rc = true;
73  switch (state) {
74  case Worker::Fail: {
75  rc = false;
76  break;
77  }
78  case Worker::Pass:
79  break;
80  case Worker::Exception: {
81  ++timesExcept_;
82  return true;
83  }
84 
85  default:
86  assert(false);
87  }
88 
89  if (Ignore == filterAction()) {
90  rc = true;
91  } else if (Veto == filterAction()) {
92  rc = !rc;
93  }
94 
95  if (rc) {
96  ++timesPassed_;
97  } else {
98  ++timesFailed_;
99  }
100  return rc;
101  }
102 
103  template <typename T>
105  typename T::TransitionInfoType const& info,
106  ServiceToken const& token,
107  StreamID streamID,
108  typename T::Context const* context) {
109  if constexpr (T::isEvent_) {
110  ++timesVisited_;
111  }
112 
113  if constexpr (T::isEvent_) {
114  ParentContext parentContext(&placeInPathContext_);
115  worker_->doWorkAsync<T>(iTask, info, token, streamID, parentContext, context);
116  } else {
117  ParentContext parentContext(context);
118 
119  // We do not need to run prefetching here because this only handles
120  // stream transitions for runs and lumis. There are no products put
121  // into the runs or lumis in stream transitions, so there can be
122  // no data dependencies which require prefetching. Prefetching is
123  // needed for global transitions, but they are run elsewhere.
124  worker_->doWorkNoPrefetchingAsync<T>(iTask, info, token, streamID, parentContext, context);
125  }
126  }
127 } // namespace edm
128 
129 #endif
edm::StreamID
Definition: StreamID.h:30
edm::WorkerInPath::timesExcept
int timesExcept() const
Definition: WorkerInPath.h:46
edm::WorkerInPath::timesExcept_
int timesExcept_
Definition: WorkerInPath.h:58
edm::Worker::doWorkAsync
void doWorkAsync(WaitingTask *, typename T::TransitionInfoType const &, ServiceToken const &, StreamID, ParentContext const &, typename T::Context const *)
Definition: Worker.h:920
edm::WorkerInPath::getWorker
Worker * getWorker() const
Definition: WorkerInPath.h:49
edm::WorkerInPath::WorkerInPath
WorkerInPath(Worker *, FilterAction theAction, unsigned int placeInPath, bool runConcurrently)
Definition: WorkerInPath.cc:6
edm::WorkerInPath::skipWorker
void skipWorker(EventPrincipal const &iPrincipal)
Definition: WorkerInPath.h:37
PlaceInPathContext.h
edm::Worker::Fail
Definition: Worker.h:90
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::Worker::Exception
Definition: Worker.h:90
edm::WorkerInPath::filterAction_
FilterAction filterAction_
Definition: WorkerInPath.h:60
edm::WorkerInPath::skipWorker
void skipWorker(LuminosityBlockPrincipal const &)
Definition: WorkerInPath.h:39
edm::LuminosityBlockPrincipal
Definition: LuminosityBlockPrincipal.h:31
cms::cuda::assert
assert(be >=bs)
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
findQualityFiles.v
v
Definition: findQualityFiles.py:179
edm::WorkerInPath::timesVisited
int timesVisited() const
Definition: WorkerInPath.h:43
watchdog.const
const
Definition: watchdog.py:83
edm::WorkerInPath::runConcurrently
bool runConcurrently() const noexcept
Definition: WorkerInPath.h:50
edm::WorkerInPath::runConcurrently_
bool runConcurrently_
Definition: WorkerInPath.h:64
edm::WorkerInPath::timesFailed
int timesFailed() const
Definition: WorkerInPath.h:45
edm::ServiceToken
Definition: ServiceToken.h:40
edm::WorkerInPath::timesPassed_
int timesPassed_
Definition: WorkerInPath.h:56
edm::EventPrincipal
Definition: EventPrincipal.h:46
edm::WorkerInPath::placeInPathContext_
PlaceInPathContext placeInPathContext_
Definition: WorkerInPath.h:63
WaitingTask
edm::WorkerInPath::Ignore
Definition: WorkerInPath.h:27
edm::Worker::Pass
Definition: Worker.h:90
edm::Worker
Definition: Worker.h:88
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::doWorkNoPrefetchingAsync
void doWorkNoPrefetchingAsync(WaitingTask *, typename T::TransitionInfoType const &, ServiceToken const &, StreamID, ParentContext const &, typename T::Context const *)
Definition: Worker.h:1020
edm::WorkerInPath::checkResultsOfRunWorker
bool checkResultsOfRunWorker(bool wasEvent)
Definition: WorkerInPath.h:67
edm::WorkerInPath::filterAction
FilterAction filterAction() const
Definition: WorkerInPath.h:48
edm::Worker::state
State state() const
Definition: Worker.h:230
ServiceToken
edm::WorkerInPath::clearCounters
void clearCounters()
Definition: WorkerInPath.h:41
edm::WorkerInPath::worker_
Worker * worker_
Definition: WorkerInPath.h:61
ParentContext.h
edm::WaitingTask
Definition: WaitingTask.h:36
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
T
long double T
Definition: Basic3DVectorLD.h:48
edm::Worker::skipOnPath
void skipOnPath(EventPrincipal const &iEvent)
Definition: Worker.cc:436
Worker.h
edm::WorkerInPath
Definition: WorkerInPath.h:25
edm::WorkerInPath::Veto
Definition: WorkerInPath.h:27
edm::WorkerInPath::timesFailed_
int timesFailed_
Definition: WorkerInPath.h:57
edm::WorkerInPath::timesVisited_
int timesVisited_
Definition: WorkerInPath.h:55
edm::WorkerInPath::runWorkerAsync
void runWorkerAsync(WaitingTask *, typename T::TransitionInfoType const &, ServiceToken const &, StreamID, typename T::Context const *)
Definition: WorkerInPath.h:104
edm::RunPrincipal
Definition: RunPrincipal.h:34
edm::WorkerInPath::setPathContext
void setPathContext(PathContext const *v)
Definition: WorkerInPath.h:52
edm::PlaceInPathContext
Definition: PlaceInPathContext.h:19
edm::WorkerInPath::timesPassed
int timesPassed() const
Definition: WorkerInPath.h:44
edm::WorkerInPath::skipWorker
void skipWorker(RunPrincipal const &)
Definition: WorkerInPath.h:38
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:318