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