CMS 3D CMS Logo

WorkerT.cc
Go to the documentation of this file.
3 
16 
20 
25 
26 #include <type_traits>
27 
28 namespace edm{
29  namespace workerimpl {
30  template<typename T>
32  static bool constexpr value = false;
33  };
34 
35  template<>
37  static bool constexpr value = true;
38  };
39 
40  template<>
42  static bool constexpr value = true;
43  };
44 
45  template<>
47  static bool constexpr value = true;
48  };
49 
50  template<>
52  static bool constexpr value = true;
53  };
54 
55  template<>
57  static bool constexpr value = true;
58  };
59 
60  template<>
62  static bool constexpr value = true;
63  };
64 
65  template<>
67  static bool constexpr value = true;
68  };
69 
70  template<>
72  static bool constexpr value = true;
73  };
74 
75  template<>
77  static bool constexpr value = true;
78  };
79 
80  struct DoNothing {
81  template< typename... T>
82  inline void operator()(const T&...) {}
83  };
84 
85  template<typename T>
86  struct DoBeginStream {
87  inline void operator()(WorkerT<T>* iWorker, StreamID id) {
88  iWorker->callWorkerBeginStream(0,id);
89  }
90  };
91 
92  template<typename T>
93  struct DoEndStream {
94  inline void operator()(WorkerT<T>* iWorker, StreamID id) {
95  iWorker->callWorkerEndStream(0,id);
96  }
97  };
98 
99  template<typename T, typename P>
101  inline void operator() (WorkerT<T>* iWorker, StreamID id, P const& rp,
102  EventSetup const& c,
103  ModuleCallingContext const* mcc) {
104  iWorker->callWorkerStreamBegin(0,id,rp,c, mcc);
105  }
106  };
107 
108  template<typename T, typename P>
110  inline void operator() (WorkerT<T>* iWorker, StreamID id, P const& rp,
111  EventSetup const& c,
112  ModuleCallingContext const* mcc) {
113  iWorker->callWorkerStreamEnd(0,id,rp,c, mcc);
114  }
115  };
116  }
117 
118  template<typename T>
119  inline
120  WorkerT<T>::WorkerT(std::shared_ptr<T> ed, ModuleDescription const& md, ExceptionToActionTable const* actions) :
121  Worker(md, actions),
122  module_(ed) {
123  assert(module_ != nullptr);
124  }
125 
126  template<typename T>
128  }
129 
130  template<typename T>
131  inline
132  bool
134  std::shared_ptr<Worker> sentry(this,[&ep](Worker* obj) {obj->postDoEvent(ep);});
135  return module_->doEvent(ep, c, activityRegistry(), mcc);
136  }
137 
138  template<typename T>
139  inline
140  bool
142  EventPrincipal const& ep,
143  ModuleCallingContext const* mcc) {
144  return true;
145  }
146 
147  template<>
148  inline
149  bool
151  EventPrincipal const& ep,
152  ModuleCallingContext const* mcc) {
153  return module_->prePrefetchSelection(id,ep,mcc);
154  }
155 
156  template<>
157  inline
158  bool
160  EventPrincipal const& ep,
161  ModuleCallingContext const* mcc) {
162  return module_->prePrefetchSelection(id,ep,mcc);
163  }
164 
165  template<>
166  inline
167  bool
169  EventPrincipal const& ep,
170  ModuleCallingContext const* mcc) {
171  return module_->prePrefetchSelection(id,ep,mcc);
172  }
173 
174  template<>
175  inline
176  bool
178  EventPrincipal const& ep,
179  ModuleCallingContext const* mcc) {
180  return module_->prePrefetchSelection(id,ep,mcc);
181  }
182 
183  template<typename T>
184  inline
185  bool
187  module_->doBeginRun(rp, c, mcc);
188  return true;
189  }
190 
191  template<typename T>
192  template<typename D>
193  void
195  EventSetup const& c,
196  ModuleCallingContext const* mcc) {
197  module_->doStreamBeginRun(id, rp, c, mcc);
198  }
199 
200  template<typename T>
201  template<typename D>
202  void
204  EventSetup const& c,
205  ModuleCallingContext const* mcc) {
206  module_->doStreamEndRun(id, rp, c, mcc);
207  }
208 
209 
210  template<typename T>
211  inline
212  bool
214  ModuleCallingContext const* mcc) {
217  workerimpl::DoNothing> might_call;
218  might_call(this,id,rp,c, mcc);
219  return true;
220  }
221 
222  template<typename T>
223  inline
224  bool
226  ModuleCallingContext const* mcc) {
229  workerimpl::DoNothing> might_call;
230  might_call(this,id,rp,c, mcc);
231  return true;
232  }
233 
234  template<typename T>
235  inline
236  bool
238  ModuleCallingContext const* mcc) {
239  module_->doEndRun(rp, c, mcc);
240  return true;
241  }
242 
243  template<typename T>
244  inline
245  bool
247  ModuleCallingContext const* mcc) {
248  module_->doBeginLuminosityBlock(lbp, c, mcc);
249  return true;
250  }
251 
252  template<typename T>
253  template<typename D>
254  void
256  EventSetup const& c,
257  ModuleCallingContext const* mcc) {
258  module_->doStreamBeginLuminosityBlock(id, rp, c, mcc);
259  }
260 
261  template<typename T>
262  template<typename D>
263  void
265  EventSetup const& c,
266  ModuleCallingContext const* mcc) {
267  module_->doStreamEndLuminosityBlock(id, rp, c, mcc);
268  }
269 
270 
271  template<typename T>
272  inline
273  bool
275  ModuleCallingContext const* mcc) {
278  workerimpl::DoNothing> might_call;
279  might_call(this,id,lbp,c, mcc);
280  return true;
281  }
282 
283  template<typename T>
284  inline
285  bool
287  ModuleCallingContext const* mcc) {
290  workerimpl::DoNothing> might_call;
291  might_call(this,id,lbp,c,mcc);
292 
293  return true;
294  }
295 
296  template<typename T>
297  inline
298  bool
300  ModuleCallingContext const* mcc) {
301  module_->doEndLuminosityBlock(lbp, c, mcc);
302  return true;
303  }
304 
305  template<typename T>
306  inline
309  return module_->workerType();
310  }
311 
312  template<typename T>
313  inline
314  void
316  module_->doBeginJob();
317  }
318 
319  template<typename T>
320  inline
321  void
323  module_->doEndJob();
324  }
325 
326  template<typename T>
327  template<typename D>
329  module_->doBeginStream(id);
330  }
331 
332  template<typename T>
333  inline
334  void
338  workerimpl::DoNothing> might_call;
339  might_call(this,id);
340  }
341 
342  template<typename T>
343  template<typename D>
345  module_->doEndStream(id);
346  }
347 
348  template<typename T>
349  inline
350  void
354  workerimpl::DoNothing> might_call;
355  might_call(this,id);
356  }
357 
358  template<typename T>
359  inline
360  void
362  module_->doRespondToOpenInputFile(fb);
363  }
364 
365  template<typename T>
366  inline
367  void
369  module_->doRespondToCloseInputFile(fb);
370  }
371 
372  template<typename T>
373  inline
374  void
377  module_->doRegisterThinnedAssociations(registry, helper);
378  }
379 
380  template<typename T>
381  inline
383  return Worker::TaskQueueAdaptor{};
384  }
386  return &(module_->sharedResourcesAcquirer().serialQueueChain());
387  }
389  return &(module_->sharedResourcesAcquirer().serialQueueChain());
390  }
392  return &(module_->sharedResourcesAcquirer().serialQueueChain());
393  }
395  return &(module_->sharedResourcesAcquirer().serialQueueChain());
396  }
398  return &(module_->sharedResourcesAcquirer().serialQueueChain());
399  }
401  return &(module_->sharedResourcesAcquirer().serialQueueChain());
402  }
404  return &(module_->sharedResourcesAcquirer().serialQueueChain());
405  }
407  return &(module_->sharedResourcesAcquirer().serialQueueChain());
408  }
410  return &(module_->queue());
411  }
413  return &(module_->queue());
414  }
416  return &(module_->queue());
417  }
419  return &(module_->queue());
420  }
421 
422 
423  namespace {
424  template <typename T> bool mustPrefetchMayGet();
425 
426  template<> bool mustPrefetchMayGet<EDAnalyzer>() { return true;}
427  template<> bool mustPrefetchMayGet<EDProducer>() { return true;}
428  template<> bool mustPrefetchMayGet<EDFilter>() { return true;}
429  template<> bool mustPrefetchMayGet<OutputModule>() { return true;}
430 
431  template<> bool mustPrefetchMayGet<edm::one::EDProducerBase>() { return true;}
432  template<> bool mustPrefetchMayGet<edm::one::EDFilterBase>() { return true;}
433  template<> bool mustPrefetchMayGet<edm::one::EDAnalyzerBase>() { return true;}
434  template<> bool mustPrefetchMayGet<edm::one::OutputModuleBase>() { return true;}
435 
436  template<> bool mustPrefetchMayGet<edm::global::EDProducerBase>() { return true;}
437  template<> bool mustPrefetchMayGet<edm::global::EDFilterBase>() { return true;}
438  template<> bool mustPrefetchMayGet<edm::global::EDAnalyzerBase>() { return true;}
439  template<> bool mustPrefetchMayGet<edm::global::OutputModuleBase>() { return true;}
440 
441  template<> bool mustPrefetchMayGet<edm::limited::EDProducerBase>() { return true;}
442  template<> bool mustPrefetchMayGet<edm::limited::EDFilterBase>() { return true;}
443  template<> bool mustPrefetchMayGet<edm::limited::EDAnalyzerBase>() { return true;}
444  template<> bool mustPrefetchMayGet<edm::limited::OutputModuleBase>() { return true;}
445 
446  template<> bool mustPrefetchMayGet<edm::stream::EDProducerAdaptorBase>() { return true;}
447  template<> bool mustPrefetchMayGet<edm::stream::EDFilterAdaptorBase>() { return true;}
448  template<> bool mustPrefetchMayGet<edm::stream::EDAnalyzerAdaptorBase>() { return true;}
449 
450  }
451 
452 
453  template<typename T>
455  ProductResolverIndexHelper const& iHelper) {
456  module_->updateLookup(iBranchType,iHelper,mustPrefetchMayGet<T>());
457  }
458 
459  namespace {
460  using ModuleToResolverIndicies = std::unordered_multimap<std::string,
461  std::tuple<edm::TypeID const*, const char*, edm::ProductResolverIndex>>;
462  void resolvePutIndiciesImpl(void*,
463  BranchType iBranchType,
464  ModuleToResolverIndicies const& iIndicies,
465  std::string const& iModuleLabel) {
466  //Do nothing
467  }
468 
469  void resolvePutIndiciesImpl(ProducerBase* iProd,
470  BranchType iBranchType,
471  ModuleToResolverIndicies const& iIndicies,
472  std::string const& iModuleLabel) {
473  iProd->resolvePutIndicies(iBranchType, iIndicies, iModuleLabel);
474  }
475 
476  void resolvePutIndiciesImpl(edm::stream::EDProducerAdaptorBase* iProd,
477  BranchType iBranchType,
478  ModuleToResolverIndicies const& iIndicies,
479  std::string const& iModuleLabel) {
480  iProd->resolvePutIndicies(iBranchType, iIndicies, iModuleLabel);
481  }
482  void resolvePutIndiciesImpl(edm::stream::EDFilterAdaptorBase* iProd,
483  BranchType iBranchType,
484  ModuleToResolverIndicies const& iIndicies,
485  std::string const& iModuleLabel) {
486  iProd->resolvePutIndicies(iBranchType, iIndicies, iModuleLabel);
487  }
488 
489  std::vector<ProductResolverIndex> s_emptyIndexList;
490 
491  std::vector<ProductResolverIndex> const& itemsShouldPutInEventImpl(void const*) {
492  return s_emptyIndexList;
493  }
494 
495  std::vector<ProductResolverIndex> const& itemsShouldPutInEventImpl(ProducerBase const* iProd) {
496  return iProd->indiciesForPutProducts(edm::InEvent);
497  }
498 
499  std::vector<ProductResolverIndex> const& itemsShouldPutInEventImpl(edm::stream::EDProducerAdaptorBase const* iProd) {
500  return iProd->indiciesForPutProducts(edm::InEvent);
501  }
502 
503  std::vector<ProductResolverIndex> const& itemsShouldPutInEventImpl(edm::stream::EDFilterAdaptorBase const* iProd) {
504  return iProd->indiciesForPutProducts(edm::InEvent);
505  }
506 
507  }
508 
509  template<typename T>
511  std::unordered_multimap<std::string,
512  std::tuple<TypeID const*, const char*, edm::ProductResolverIndex>> const& iIndicies) {
513  resolvePutIndiciesImpl(&module(), iBranchType,iIndicies, description().moduleLabel());
514  }
515 
516 
517  template<typename T>
518  std::vector<ProductResolverIndex> const&
520  return itemsShouldPutInEventImpl(&module());
521  }
522 
523 
524  template<>
526  template<>
528  template<>
530  template<>
532  template<>
534  template<>
536  template<>
538  template<>
540 
541  template<>
543  template<>
545  template<>
547  template<>
549 
550  template<>
552  template<>
554  template<>
556  template<>
558 
559 
560  template<>
562  template<>
564  template<>
566 
567  //Explicitly instantiate our needed templates to avoid having the compiler
568  // instantiate them in all of our libraries
569  template class WorkerT<EDProducer>;
570  template class WorkerT<EDFilter>;
571  template class WorkerT<EDAnalyzer>;
572  template class WorkerT<OutputModule>;
573  template class WorkerT<one::EDProducerBase>;
574  template class WorkerT<one::EDFilterBase>;
575  template class WorkerT<one::EDAnalyzerBase>;
576  template class WorkerT<one::OutputModuleBase>;
577  template class WorkerT<global::EDProducerBase>;
578  template class WorkerT<global::EDFilterBase>;
579  template class WorkerT<global::EDAnalyzerBase>;
580  template class WorkerT<global::OutputModuleBase>;
584  template class WorkerT<limited::EDProducerBase>;
585  template class WorkerT<limited::EDFilterBase>;
586  template class WorkerT<limited::EDAnalyzerBase>;
587  template class WorkerT<limited::OutputModuleBase>;
588 }
bool implDoStreamEnd(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:225
static const char module_[]
ModuleDescription const & description() const
Definition: Worker.h:167
Definition: helper.py:1
roAction_t actions[nactions]
Definition: GenABIO.cc:187
void callWorkerStreamEnd(D, StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:203
void implEndJob() override
Definition: WorkerT.cc:322
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &) override
Definition: WorkerT.cc:454
T & module()
Definition: WorkerT.h:74
bool implDoStreamBegin(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:213
ActivityRegistry * activityRegistry()
Definition: Worker.h:243
bool implDo(EventPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:133
#define constexpr
BranchType
Definition: BranchType.h:11
Types moduleType() const override
void resolvePutIndicies(BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
Definition: ProducerBase.cc:85
edm::propagate_const< std::shared_ptr< T > > module_
Definition: WorkerT.h:141
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts(BranchType iBranchType) const
Definition: ProducerBase.h:86
void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:361
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts(BranchType iBranchType) const
bool implDoPrePrefetchSelection(StreamID id, EventPrincipal const &ep, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:141
void callWorkerEndStream(D, StreamID)
Definition: WorkerT.cc:344
void operator()(WorkerT< T > *iWorker, StreamID id)
Definition: WorkerT.cc:87
void operator()(const T &...)
Definition: WorkerT.cc:82
void implBeginStream(StreamID) override
Definition: WorkerT.cc:335
Definition: value.py:1
TaskQueueAdaptor serializeRunModule() override
Definition: WorkerT.cc:382
void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, std::tuple< TypeID const *, const char *, edm::ProductResolverIndex >> const &iIndicies) override
Definition: WorkerT.cc:510
void operator()(WorkerT< T > *iWorker, StreamID id)
Definition: WorkerT.cc:94
void callWorkerStreamBegin(D, StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:194
bool implDoBegin(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:186
~WorkerT() override
Definition: WorkerT.cc:127
std::vector< ProductResolverIndex > const & itemsShouldPutInEvent() const override
Definition: WorkerT.cc:519
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:151
void implEndStream(StreamID) override
Definition: WorkerT.cc:351
void implBeginJob() override
Definition: WorkerT.cc:315
void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:368
std::pair< OmniClusterRef, TrackingParticleRef > P
void resolvePutIndicies(BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
void callWorkerBeginStream(D, StreamID)
Definition: WorkerT.cc:328
HLT enums.
void postDoEvent(EventPrincipal const &)
Definition: Worker.cc:331
void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &) override
Definition: WorkerT.cc:375
bool implDoEnd(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:237
static Interceptor::Registry registry("Interceptor")
long double T
std::string workerType() const override
Definition: WorkerT.cc:308
WorkerT(std::shared_ptr< T >, ModuleDescription const &, ExceptionToActionTable const *actions)
Definition: WorkerT.cc:120