CMS 3D CMS Logo

GlobalSchedule.cc
Go to the documentation of this file.
7 
14 
15 #include <algorithm>
16 #include <cassert>
17 #include <cstdlib>
18 #include <functional>
19 #include <map>
20 
21 namespace edm {
23  std::shared_ptr<TriggerResultInserter> inserter,
24  std::vector<edm::propagate_const<std::shared_ptr<PathStatusInserter>>>& pathStatusInserters,
25  std::vector<edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>>& endPathStatusInserters,
26  std::shared_ptr<ModuleRegistry> modReg,
27  std::vector<std::string> const& iModulesToUse,
28  ParameterSet& proc_pset,
29  ProductRegistry& pregistry,
30  PreallocationConfiguration const& prealloc,
32  std::shared_ptr<ActivityRegistry> areg,
33  std::shared_ptr<ProcessConfiguration const> processConfiguration,
34  ProcessContext const* processContext)
35  : actReg_(areg), processContext_(processContext), numberOfConcurrentLumis_(prealloc.numberOfLuminosityBlocks()) {
36  unsigned int nManagers = prealloc.numberOfLuminosityBlocks() + prealloc.numberOfRuns();
37  workerManagers_.reserve(nManagers);
38  for (unsigned int i = 0; i < nManagers; ++i) {
39  workerManagers_.emplace_back(modReg, areg, actions);
40  }
41  for (auto const& moduleLabel : iModulesToUse) {
42  bool isTracked;
43  ParameterSet* modpset = proc_pset.getPSetForUpdate(moduleLabel, isTracked);
44  if (modpset != nullptr) { // It will be null for PathStatusInserters, it should
45  // be impossible to be null for anything else
46  assert(isTracked);
47 
48  //side effect keeps this module around
49  for (auto& wm : workerManagers_) {
50  wm.addToAllWorkers(wm.getWorker(*modpset, pregistry, &prealloc, processConfiguration, moduleLabel));
51  }
52  }
53  }
54  if (inserter) {
55  inserter->doPreallocate(prealloc);
56  for (auto& wm : workerManagers_) {
58  inserter, inserter->moduleDescription(), &actions)); // propagate_const<T> has no reset() function
59  results_inserter->setActivityRegistry(actReg_);
60  wm.addToAllWorkers(results_inserter.get());
61  extraWorkers_.emplace_back(std::move(results_inserter));
62  }
63  }
64 
65  for (auto& pathStatusInserter : pathStatusInserters) {
66  std::shared_ptr<PathStatusInserter> inserterPtr = get_underlying(pathStatusInserter);
67  inserterPtr->doPreallocate(prealloc);
68 
69  for (auto& wm : workerManagers_) {
70  WorkerPtr workerPtr(
71  new edm::WorkerT<PathStatusInserter::ModuleType>(inserterPtr, inserterPtr->moduleDescription(), &actions));
72  workerPtr->setActivityRegistry(actReg_);
73  wm.addToAllWorkers(workerPtr.get());
74  extraWorkers_.emplace_back(std::move(workerPtr));
75  }
76  }
77 
78  for (auto& endPathStatusInserter : endPathStatusInserters) {
79  std::shared_ptr<EndPathStatusInserter> inserterPtr = get_underlying(endPathStatusInserter);
80  inserterPtr->doPreallocate(prealloc);
81  for (auto& wm : workerManagers_) {
83  inserterPtr, inserterPtr->moduleDescription(), &actions));
84  workerPtr->setActivityRegistry(actReg_);
85  wm.addToAllWorkers(workerPtr.get());
86  extraWorkers_.emplace_back(std::move(workerPtr));
87  }
88  }
89 
90  } // GlobalSchedule::GlobalSchedule
91 
92  void GlobalSchedule::endJob(ExceptionCollector& collector) { workerManagers_[0].endJob(collector); }
93 
96  ProcessBlockHelperBase const& processBlockHelperBase) {
97  workerManagers_[0].beginJob(iRegistry, iESIndices, processBlockHelperBase);
98  }
99 
101  Worker* found = nullptr;
102  for (auto& wm : workerManagers_) {
103  for (auto const& worker : wm.allWorkers()) {
104  if (worker->description()->moduleLabel() == iLabel) {
105  found = worker;
106  break;
107  }
108  }
109  if (nullptr == found) {
110  return;
111  }
112 
113  iMod->replaceModuleFor(found);
114  found->beginJob();
115  }
116  }
117 
119  for (auto& wm : workerManagers_) {
120  wm.deleteModuleIfExists(iLabel);
121  }
122  }
123 
124  std::vector<ModuleDescription const*> GlobalSchedule::getAllModuleDescriptions() const {
125  std::vector<ModuleDescription const*> result;
126  result.reserve(allWorkers().size());
127 
128  for (auto const& worker : allWorkers()) {
129  ModuleDescription const* p = worker->description();
130  result.push_back(p);
131  }
132  return result;
133  }
134 } // namespace edm
size
Write out results.
void replaceModule(maker::ModuleHolder *iMod, std::string const &iLabel)
clone the type of module with label iLabel but configure with iPSet.
std::vector< WorkerManager > workerManagers_
roAction_t actions[nactions]
Definition: GenABIO.cc:181
virtual void replaceModuleFor(Worker *) const =0
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
void deleteModule(std::string const &iLabel)
Delete the module with label iLabel.
assert(be >=bs)
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
GlobalSchedule(std::shared_ptr< TriggerResultInserter > inserter, std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter >>> &pathStatusInserters, std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter >>> &endPathStatusInserters, std::shared_ptr< ModuleRegistry > modReg, std::vector< std::string > const &modulesToUse, ParameterSet &proc_pset, ProductRegistry &pregistry, PreallocationConfiguration const &prealloc, ExceptionToActionTable const &actions, std::shared_ptr< ActivityRegistry > areg, std::shared_ptr< ProcessConfiguration const > processConfiguration, ProcessContext const *processContext)
std::shared_ptr< Worker > WorkerPtr
void endJob(ExceptionCollector &collector)
std::shared_ptr< ActivityRegistry > actReg_
constexpr T & get_underlying(propagate_const< T > &)
HLT enums.
void beginJob(ProductRegistry const &, eventsetup::ESRecordsToProductResolverIndices const &, ProcessBlockHelperBase const &)
def move(src, dest)
Definition: eostools.py:511
ParameterSet * getPSetForUpdate(std::string const &name, bool &isTracked)
std::vector< edm::propagate_const< WorkerPtr > > extraWorkers_