CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
131  template<typename T>
133  return module_->wantsGlobalRuns();
134  }
135 
136  template<typename T>
138  return module_->wantsGlobalLuminosityBlocks();
139  }
140 
141  template<typename T>
143  return module_->wantsStreamRuns();
144  }
145 
146  template<typename T>
148  return module_->wantsStreamLuminosityBlocks();
149  }
150 
151  template<typename T>
152  inline
153  bool
155  std::shared_ptr<Worker> sentry(this,[&ep](Worker* obj) {obj->postDoEvent(ep);});
156  return module_->doEvent(ep, c, activityRegistry(), mcc);
157  }
158 
159  template<typename T>
160  inline
161  void
163  ModuleCallingContext const*,
165  }
166 
167  template<>
168  inline
169  void
171  ModuleCallingContext const* mcc,
172  WaitingTaskWithArenaHolder& holder) {
173  module_->doAcquire(ep, c, activityRegistry(), mcc, holder);
174  }
175 
176  template<>
177  inline
178  void
180  ModuleCallingContext const* mcc,
181  WaitingTaskWithArenaHolder& holder) {
182  module_->doAcquire(ep, c, activityRegistry(), mcc, holder);
183  }
184 
185  template<>
186  inline
187  void
189  ModuleCallingContext const* mcc,
190  WaitingTaskWithArenaHolder& holder) {
191  module_->doAcquire(ep, c, activityRegistry(), mcc, holder);
192  }
193 
194  template<>
195  inline
196  void
198  ModuleCallingContext const* mcc,
199  WaitingTaskWithArenaHolder& holder) {
200  module_->doAcquire(ep, c, activityRegistry(), mcc, holder);
201  }
202 
203  template<typename T>
204  inline
205  bool
206  WorkerT<T>::implNeedToRunSelection() const { return false;}
207 
208  template<typename T>
209  inline
210  bool
212  EventPrincipal const& ep,
213  ModuleCallingContext const* mcc) {
214  return true;
215  }
216  template<typename T>
217  inline
218  void
219  WorkerT<T>::itemsToGetForSelection(std::vector<ProductResolverIndexAndSkipBit>&) const {}
220 
221 
222  template<>
223  inline
224  bool
226  template<>
227  inline
228  bool
230  EventPrincipal const& ep,
231  ModuleCallingContext const* mcc) {
232  return module_->prePrefetchSelection(id,ep,mcc);
233  }
234  template<>
235  inline
236  void
237  WorkerT<OutputModule>::itemsToGetForSelection(std::vector<ProductResolverIndexAndSkipBit>& iItems) const {
238  iItems = module_->productsUsedBySelection();
239  }
240 
241  template<>
242  inline
243  bool
245 
246  template<>
247  inline
248  bool
250  EventPrincipal const& ep,
251  ModuleCallingContext const* mcc) {
252  return module_->prePrefetchSelection(id,ep,mcc);
253  }
254  template<>
255  inline
256  void
257  WorkerT<edm::one::OutputModuleBase>::itemsToGetForSelection(std::vector<ProductResolverIndexAndSkipBit>& iItems) const {
258  iItems = module_->productsUsedBySelection();
259  }
260 
261  template<>
262  inline
263  bool
265  template<>
266  inline
267  bool
269  EventPrincipal const& ep,
270  ModuleCallingContext const* mcc) {
271  return module_->prePrefetchSelection(id,ep,mcc);
272  }
273  template<>
274  inline
275  void
276  WorkerT<edm::global::OutputModuleBase>::itemsToGetForSelection(std::vector<ProductResolverIndexAndSkipBit>& iItems) const {
277  iItems = module_->productsUsedBySelection();
278  }
279 
280  template<>
281  inline
282  bool
284  template<>
285  inline
286  bool
288  EventPrincipal const& ep,
289  ModuleCallingContext const* mcc) {
290  return module_->prePrefetchSelection(id,ep,mcc);
291  }
292  template<>
293  inline
294  void
295  WorkerT<edm::limited::OutputModuleBase>::itemsToGetForSelection(std::vector<ProductResolverIndexAndSkipBit>& iItems) const {
296  iItems = module_->productsUsedBySelection();
297  }
298 
299  template<typename T>
300  inline
301  bool
303  module_->doBeginRun(rp, c, mcc);
304  return true;
305  }
306 
307  template<typename T>
308  template<typename D>
309  void
311  EventSetup const& c,
312  ModuleCallingContext const* mcc) {
313  module_->doStreamBeginRun(id, rp, c, mcc);
314  }
315 
316  template<typename T>
317  template<typename D>
318  void
320  EventSetup const& c,
321  ModuleCallingContext const* mcc) {
322  module_->doStreamEndRun(id, rp, c, mcc);
323  }
324 
325 
326  template<typename T>
327  inline
328  bool
330  ModuleCallingContext const* mcc) {
333  workerimpl::DoNothing> might_call;
334  might_call(this,id,rp,c, mcc);
335  return true;
336  }
337 
338  template<typename T>
339  inline
340  bool
342  ModuleCallingContext const* mcc) {
345  workerimpl::DoNothing> might_call;
346  might_call(this,id,rp,c, mcc);
347  return true;
348  }
349 
350  template<typename T>
351  inline
352  bool
354  ModuleCallingContext const* mcc) {
355  module_->doEndRun(rp, c, mcc);
356  return true;
357  }
358 
359  template<typename T>
360  inline
361  bool
363  ModuleCallingContext const* mcc) {
364  module_->doBeginLuminosityBlock(lbp, c, mcc);
365  return true;
366  }
367 
368  template<typename T>
369  template<typename D>
370  void
372  EventSetup const& c,
373  ModuleCallingContext const* mcc) {
374  module_->doStreamBeginLuminosityBlock(id, rp, c, mcc);
375  }
376 
377  template<typename T>
378  template<typename D>
379  void
381  EventSetup const& c,
382  ModuleCallingContext const* mcc) {
383  module_->doStreamEndLuminosityBlock(id, rp, c, mcc);
384  }
385 
386 
387  template<typename T>
388  inline
389  bool
391  ModuleCallingContext const* mcc) {
394  workerimpl::DoNothing> might_call;
395  might_call(this,id,lbp,c, mcc);
396  return true;
397  }
398 
399  template<typename T>
400  inline
401  bool
403  ModuleCallingContext const* mcc) {
406  workerimpl::DoNothing> might_call;
407  might_call(this,id,lbp,c,mcc);
408 
409  return true;
410  }
411 
412  template<typename T>
413  inline
414  bool
416  ModuleCallingContext const* mcc) {
417  module_->doEndLuminosityBlock(lbp, c, mcc);
418  return true;
419  }
420 
421  template<typename T>
422  inline
425  return module_->workerType();
426  }
427 
428  template<typename T>
429  inline
430  void
432  module_->doBeginJob();
433  }
434 
435  template<typename T>
436  inline
437  void
439  module_->doEndJob();
440  }
441 
442  template<typename T>
443  template<typename D>
445  module_->doBeginStream(id);
446  }
447 
448  template<typename T>
449  inline
450  void
454  workerimpl::DoNothing> might_call;
455  might_call(this,id);
456  }
457 
458  template<typename T>
459  template<typename D>
461  module_->doEndStream(id);
462  }
463 
464  template<typename T>
465  inline
466  void
470  workerimpl::DoNothing> might_call;
471  might_call(this,id);
472  }
473 
474  template<typename T>
475  inline
476  void
478  module_->doRespondToOpenInputFile(fb);
479  }
480 
481  template<typename T>
482  inline
483  void
485  module_->doRespondToCloseInputFile(fb);
486  }
487 
488  template<typename T>
489  inline
490  void
493  module_->doRegisterThinnedAssociations(registry, helper);
494  }
495 
496  template<typename T>
497  inline
499  return Worker::TaskQueueAdaptor{};
500  }
502  return &(module_->sharedResourcesAcquirer().serialQueueChain());
503  }
505  return &(module_->sharedResourcesAcquirer().serialQueueChain());
506  }
508  return &(module_->sharedResourcesAcquirer().serialQueueChain());
509  }
511  return &(module_->sharedResourcesAcquirer().serialQueueChain());
512  }
514  return &(module_->sharedResourcesAcquirer().serialQueueChain());
515  }
517  return &(module_->sharedResourcesAcquirer().serialQueueChain());
518  }
520  return &(module_->sharedResourcesAcquirer().serialQueueChain());
521  }
523  return &(module_->sharedResourcesAcquirer().serialQueueChain());
524  }
526  return &(module_->queue());
527  }
529  return &(module_->queue());
530  }
532  return &(module_->queue());
533  }
535  return &(module_->queue());
536  }
537 
538 
539  namespace {
540  template <typename T> bool mustPrefetchMayGet();
541 
542  template<> bool mustPrefetchMayGet<EDAnalyzer>() { return true;}
543  template<> bool mustPrefetchMayGet<EDProducer>() { return true;}
544  template<> bool mustPrefetchMayGet<EDFilter>() { return true;}
545  template<> bool mustPrefetchMayGet<OutputModule>() { return true;}
546 
547  template<> bool mustPrefetchMayGet<edm::one::EDProducerBase>() { return true;}
548  template<> bool mustPrefetchMayGet<edm::one::EDFilterBase>() { return true;}
549  template<> bool mustPrefetchMayGet<edm::one::EDAnalyzerBase>() { return true;}
550  template<> bool mustPrefetchMayGet<edm::one::OutputModuleBase>() { return true;}
551 
552  template<> bool mustPrefetchMayGet<edm::global::EDProducerBase>() { return true;}
553  template<> bool mustPrefetchMayGet<edm::global::EDFilterBase>() { return true;}
554  template<> bool mustPrefetchMayGet<edm::global::EDAnalyzerBase>() { return true;}
555  template<> bool mustPrefetchMayGet<edm::global::OutputModuleBase>() { return true;}
556 
557  template<> bool mustPrefetchMayGet<edm::limited::EDProducerBase>() { return true;}
558  template<> bool mustPrefetchMayGet<edm::limited::EDFilterBase>() { return true;}
559  template<> bool mustPrefetchMayGet<edm::limited::EDAnalyzerBase>() { return true;}
560  template<> bool mustPrefetchMayGet<edm::limited::OutputModuleBase>() { return true;}
561 
562  template<> bool mustPrefetchMayGet<edm::stream::EDProducerAdaptorBase>() { return true;}
563  template<> bool mustPrefetchMayGet<edm::stream::EDFilterAdaptorBase>() { return true;}
564  template<> bool mustPrefetchMayGet<edm::stream::EDAnalyzerAdaptorBase>() { return true;}
565 
566  }
567 
568 
569  template<typename T>
571  ProductResolverIndexHelper const& iHelper) {
572  module_->updateLookup(iBranchType,iHelper,mustPrefetchMayGet<T>());
573  }
574 
575  namespace {
576  using ModuleToResolverIndicies = std::unordered_multimap<std::string,
577  std::tuple<edm::TypeID const*, const char*, edm::ProductResolverIndex>>;
578  void resolvePutIndiciesImpl(void*,
579  BranchType iBranchType,
580  ModuleToResolverIndicies const& iIndicies,
581  std::string const& iModuleLabel) {
582  //Do nothing
583  }
584 
585  void resolvePutIndiciesImpl(ProducerBase* iProd,
586  BranchType iBranchType,
587  ModuleToResolverIndicies const& iIndicies,
588  std::string const& iModuleLabel) {
589  iProd->resolvePutIndicies(iBranchType, iIndicies, iModuleLabel);
590  }
591 
592  void resolvePutIndiciesImpl(edm::stream::EDProducerAdaptorBase* iProd,
593  BranchType iBranchType,
594  ModuleToResolverIndicies const& iIndicies,
595  std::string const& iModuleLabel) {
596  iProd->resolvePutIndicies(iBranchType, iIndicies, iModuleLabel);
597  }
598  void resolvePutIndiciesImpl(edm::stream::EDFilterAdaptorBase* iProd,
599  BranchType iBranchType,
600  ModuleToResolverIndicies const& iIndicies,
601  std::string const& iModuleLabel) {
602  iProd->resolvePutIndicies(iBranchType, iIndicies, iModuleLabel);
603  }
604 
605  std::vector<ProductResolverIndex> s_emptyIndexList;
606 
607  std::vector<ProductResolverIndex> const& itemsShouldPutInEventImpl(void const*) {
608  return s_emptyIndexList;
609  }
610 
611  std::vector<ProductResolverIndex> const& itemsShouldPutInEventImpl(ProducerBase const* iProd) {
612  return iProd->indiciesForPutProducts(edm::InEvent);
613  }
614 
615  std::vector<ProductResolverIndex> const& itemsShouldPutInEventImpl(edm::stream::EDProducerAdaptorBase const* iProd) {
616  return iProd->indiciesForPutProducts(edm::InEvent);
617  }
618 
619  std::vector<ProductResolverIndex> const& itemsShouldPutInEventImpl(edm::stream::EDFilterAdaptorBase const* iProd) {
620  return iProd->indiciesForPutProducts(edm::InEvent);
621  }
622 
623  }
624 
625  template<typename T>
627  std::unordered_multimap<std::string,
628  std::tuple<TypeID const*, const char*, edm::ProductResolverIndex>> const& iIndicies) {
629  resolvePutIndiciesImpl(&module(), iBranchType,iIndicies, description().moduleLabel());
630  }
631 
632 
633  template<typename T>
634  std::vector<ProductResolverIndex> const&
636  return itemsShouldPutInEventImpl(&module());
637  }
638 
639 
640  template<>
642  template<>
644  template<>
646  template<>
648  template<>
650  template<>
652  template<>
654  template<>
656 
657  template<>
659  template<>
661  template<>
663  template<>
665 
666  template<>
668  template<>
670  template<>
672  template<>
674 
675 
676  template<>
678  template<>
680  template<>
682 
683  //Explicitly instantiate our needed templates to avoid having the compiler
684  // instantiate them in all of our libraries
685  template class WorkerT<EDProducer>;
686  template class WorkerT<EDFilter>;
687  template class WorkerT<EDAnalyzer>;
688  template class WorkerT<OutputModule>;
689  template class WorkerT<one::EDProducerBase>;
690  template class WorkerT<one::EDFilterBase>;
691  template class WorkerT<one::EDAnalyzerBase>;
692  template class WorkerT<one::OutputModuleBase>;
693  template class WorkerT<global::EDProducerBase>;
694  template class WorkerT<global::EDFilterBase>;
695  template class WorkerT<global::EDAnalyzerBase>;
696  template class WorkerT<global::OutputModuleBase>;
700  template class WorkerT<limited::EDProducerBase>;
701  template class WorkerT<limited::EDFilterBase>;
702  template class WorkerT<limited::EDAnalyzerBase>;
703  template class WorkerT<limited::OutputModuleBase>;
704 }
bool implDoStreamEnd(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:341
static const char module_[]
bool wantsStreamLuminosityBlocks() const final
Definition: WorkerT.cc:147
ModuleDescription const & description() const
Definition: Worker.h:182
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:319
void implEndJob() override
Definition: WorkerT.cc:438
bool wantsGlobalRuns() const final
Definition: WorkerT.cc:132
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &) override
Definition: WorkerT.cc:570
T & module()
Definition: WorkerT.h:81
bool implDoStreamBegin(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:329
ActivityRegistry * activityRegistry()
Definition: Worker.h:266
bool implDo(EventPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:154
#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:159
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts(BranchType iBranchType) const
Definition: ProducerBase.h:86
void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:477
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts(BranchType iBranchType) const
bool implDoPrePrefetchSelection(StreamID id, EventPrincipal const &ep, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:211
bool wantsGlobalLuminosityBlocks() const final
Definition: WorkerT.cc:137
void callWorkerEndStream(D, StreamID)
Definition: WorkerT.cc:460
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:451
Definition: value.py:1
TaskQueueAdaptor serializeRunModule() override
Definition: WorkerT.cc:498
void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, std::tuple< TypeID const *, const char *, edm::ProductResolverIndex >> const &iIndicies) override
Definition: WorkerT.cc:626
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:310
bool implDoBegin(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:302
~WorkerT() override
Definition: WorkerT.cc:127
std::vector< ProductResolverIndex > const & itemsShouldPutInEvent() const override
Definition: WorkerT.cc:635
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:151
bool implNeedToRunSelection() const final
Definition: WorkerT.cc:206
void implEndStream(StreamID) override
Definition: WorkerT.cc:467
void implBeginJob() override
Definition: WorkerT.cc:431
void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:484
std::pair< OmniClusterRef, TrackingParticleRef > P
void resolvePutIndicies(BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
void callWorkerBeginStream(D, StreamID)
Definition: WorkerT.cc:444
void implDoAcquire(EventPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *mcc, WaitingTaskWithArenaHolder &holder) final
Definition: WorkerT.cc:162
HLT enums.
void itemsToGetForSelection(std::vector< ProductResolverIndexAndSkipBit > &) const final
Definition: WorkerT.cc:219
void postDoEvent(EventPrincipal const &)
Definition: Worker.cc:377
void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &) override
Definition: WorkerT.cc:491
bool implDoEnd(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:353
bool wantsStreamRuns() const final
Definition: WorkerT.cc:142
static Interceptor::Registry registry("Interceptor")
long double T
std::string workerType() const override
Definition: WorkerT.cc:424
WorkerT(std::shared_ptr< T >, ModuleDescription const &, ExceptionToActionTable const *actions)
Definition: WorkerT.cc:120