CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
edm::WorkerManager Class Reference

#include <WorkerManager.h>

Public Types

typedef std::vector< Worker * > AllWorkers
 

Public Member Functions

ExceptionToActionTable const & actionTable () const
 
void addToAllWorkers (Worker *w)
 
void addToUnscheduledWorkers (ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, std::string label, std::set< std::string > &unscheduledLabels, std::vector< std::string > &shouldBeUsedLabels)
 
AllWorkers const & allWorkers () const
 
void beginJob (ProductRegistry const &iRegistry, eventsetup::ESRecordsToProxyIndices const &, ProcessBlockHelperBase const &)
 
void beginStream (StreamID iID, StreamContext &streamContext)
 
void deleteModuleIfExists (std::string const &moduleLabel)
 
void endJob ()
 
void endJob (ExceptionCollector &collector)
 
void endStream (StreamID iID, StreamContext &streamContext)
 
WorkergetWorker (ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, std::string const &label)
 
template<typename T >
void processAccumulatorsAsync (WaitingTaskHolder, typename T::TransitionInfoType const &, ServiceToken const &, StreamID, ParentContext const &, typename T::Context const *)
 
template<typename T , typename U >
void processOneOccurrenceAsync (WaitingTaskHolder, typename T::TransitionInfoType &, ServiceToken const &, StreamID, typename T::Context const *topContext, U const *context)
 
void resetAll ()
 
void setupOnDemandSystem (EventTransitionInfo const &)
 
void setupResolvers (Principal &principal)
 
AllWorkers const & unscheduledWorkers () const
 
 WorkerManager (std::shared_ptr< ActivityRegistry > actReg, ExceptionToActionTable const &actions, ModuleTypeResolverMaker const *typeResolverMaker)
 
 WorkerManager (WorkerManager &&)=default
 
 WorkerManager (std::shared_ptr< ModuleRegistry > modReg, std::shared_ptr< ActivityRegistry > actReg, ExceptionToActionTable const &actions)
 

Private Attributes

ExceptionToActionTable const * actionTable_
 
AllWorkers allWorkers_
 
void const * lastSetupEventPrincipal_
 
UnscheduledCallProducer unscheduled_
 
WorkerRegistry workerReg_
 

Detailed Description

Definition at line 37 of file WorkerManager.h.

Member Typedef Documentation

◆ AllWorkers

typedef std::vector<Worker*> edm::WorkerManager::AllWorkers

Definition at line 39 of file WorkerManager.h.

Constructor & Destructor Documentation

◆ WorkerManager() [1/3]

edm::WorkerManager::WorkerManager ( std::shared_ptr< ActivityRegistry actReg,
ExceptionToActionTable const &  actions,
ModuleTypeResolverMaker const *  typeResolverMaker 
)

Definition at line 17 of file WorkerManager.cc.

20  : workerReg_(areg, typeResolverMaker),
22  allWorkers_(),
23  unscheduled_(*areg),
24  lastSetupEventPrincipal_(nullptr) {} // WorkerManager::WorkerManager
roAction_t actions[nactions]
Definition: GenABIO.cc:181
UnscheduledCallProducer unscheduled_
AllWorkers allWorkers_
ExceptionToActionTable const * actionTable_
void const * lastSetupEventPrincipal_
WorkerRegistry workerReg_

◆ WorkerManager() [2/3]

edm::WorkerManager::WorkerManager ( WorkerManager &&  )
default

◆ WorkerManager() [3/3]

edm::WorkerManager::WorkerManager ( std::shared_ptr< ModuleRegistry modReg,
std::shared_ptr< ActivityRegistry actReg,
ExceptionToActionTable const &  actions 
)

Definition at line 26 of file WorkerManager.cc.

29  : workerReg_(areg, modReg),
31  allWorkers_(),
32  unscheduled_(*areg),
33  lastSetupEventPrincipal_(nullptr) {} // WorkerManager::WorkerManager
roAction_t actions[nactions]
Definition: GenABIO.cc:181
UnscheduledCallProducer unscheduled_
AllWorkers allWorkers_
ExceptionToActionTable const * actionTable_
void const * lastSetupEventPrincipal_
WorkerRegistry workerReg_

Member Function Documentation

◆ actionTable()

ExceptionToActionTable const& edm::WorkerManager::actionTable ( ) const
inline

Definition at line 93 of file WorkerManager.h.

References actionTable_.

Referenced by edm::StreamSchedule::actionTable().

93 { return *actionTable_; }
ExceptionToActionTable const * actionTable_

◆ addToAllWorkers()

void edm::WorkerManager::addToAllWorkers ( Worker w)

Definition at line 137 of file WorkerManager.cc.

References allWorkers_, edm::search_all(), and w().

Referenced by edm::StreamSchedule::addToAllWorkers(), and addToUnscheduledWorkers().

137  {
138  if (!search_all(allWorkers_, w)) {
139  allWorkers_.push_back(w);
140  }
141  }
T w() const
AllWorkers allWorkers_
bool search_all(ForwardSequence const &s, Datum const &d)
Definition: Algorithms.h:36

◆ addToUnscheduledWorkers()

void edm::WorkerManager::addToUnscheduledWorkers ( ParameterSet pset,
ProductRegistry preg,
PreallocationConfiguration const *  prealloc,
std::shared_ptr< ProcessConfiguration const >  processConfiguration,
std::string  label,
std::set< std::string > &  unscheduledLabels,
std::vector< std::string > &  shouldBeUsedLabels 
)

Definition at line 54 of file WorkerManager.cc.

References addToAllWorkers(), edm::UnscheduledCallProducer::addWorker(), cms::cuda::assert(), getWorker(), edm::Worker::kFilter, kFilterType(), edm::Worker::kProducer, kProducerType(), label, edm::Worker::moduleType(), muonDTDigis_cfi::pset, AlCaHLTBitMon_QueryRunRegistry::string, and unscheduled_.

Referenced by edm::SecondaryEventProvider::SecondaryEventProvider(), and edm::StreamSchedule::StreamSchedule().

60  {
61  //Need to
62  // 1) create worker
63  // 2) if it is a WorkerT<EDProducer>, add it to our list
64  auto modType = pset.getParameter<std::string>("@module_edm_type");
65  if (modType == kProducerType || modType == kFilterType) {
66  Worker* newWorker = getWorker(pset, preg, prealloc, processConfiguration, label);
67  assert(newWorker->moduleType() == Worker::kProducer || newWorker->moduleType() == Worker::kFilter);
68  unscheduledLabels.insert(label);
69  unscheduled_.addWorker(newWorker);
70  //add to list so it gets reset each new event
71  addToAllWorkers(newWorker);
72  } else {
73  shouldBeUsedLabels.push_back(label);
74  }
75  }
static const std::string kFilterType("EDFilter")
UnscheduledCallProducer unscheduled_
assert(be >=bs)
Worker * getWorker(ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, std::string const &label)
char const * label
static const std::string kProducerType("EDProducer")
void addToAllWorkers(Worker *w)

◆ allWorkers()

AllWorkers const& edm::WorkerManager::allWorkers ( ) const
inline

Definition at line 88 of file WorkerManager.h.

References allWorkers_.

Referenced by edm::StreamSchedule::allWorkers(), and edm::GlobalSchedule::processOneGlobalAsync().

88 { return allWorkers_; }
AllWorkers allWorkers_

◆ beginJob()

void edm::WorkerManager::beginJob ( ProductRegistry const &  iRegistry,
eventsetup::ESRecordsToProxyIndices const &  iESIndices,
ProcessBlockHelperBase const &  processBlockHelperBase 
)

Definition at line 93 of file WorkerManager.cc.

References allWorkers_, edm::Worker::beginJob(), edm::for_all(), edm::InEvent, edm::InLumi, edm::InProcess, edm::InRun, SimL1EmulatorRepack_CalouGT_cff::processName, and edm::ProductRegistry::productLookup().

Referenced by edm::SecondaryEventProvider::beginJob().

95  {
96  auto const processBlockLookup = iRegistry.productLookup(InProcess);
97  auto const runLookup = iRegistry.productLookup(InRun);
98  auto const lumiLookup = iRegistry.productLookup(InLumi);
99  auto const eventLookup = iRegistry.productLookup(InEvent);
100  if (!allWorkers_.empty()) {
101  auto const& processName = allWorkers_[0]->description()->processName();
102  auto processBlockModuleToIndicies = processBlockLookup->indiciesForModulesInProcess(processName);
103  auto runModuleToIndicies = runLookup->indiciesForModulesInProcess(processName);
104  auto lumiModuleToIndicies = lumiLookup->indiciesForModulesInProcess(processName);
105  auto eventModuleToIndicies = eventLookup->indiciesForModulesInProcess(processName);
106  for (auto& worker : allWorkers_) {
107  worker->updateLookup(InProcess, *processBlockLookup);
108  worker->updateLookup(InRun, *runLookup);
109  worker->updateLookup(InLumi, *lumiLookup);
110  worker->updateLookup(InEvent, *eventLookup);
111  worker->updateLookup(iESIndices);
112  worker->resolvePutIndicies(InProcess, processBlockModuleToIndicies);
113  worker->resolvePutIndicies(InRun, runModuleToIndicies);
114  worker->resolvePutIndicies(InLumi, lumiModuleToIndicies);
115  worker->resolvePutIndicies(InEvent, eventModuleToIndicies);
116  worker->selectInputProcessBlocks(iRegistry, processBlockHelperBase);
117  }
118 
119  for_all(allWorkers_, std::bind(&Worker::beginJob, std::placeholders::_1));
120  }
121  }
AllWorkers allWorkers_
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
void beginJob()
Definition: Worker.cc:273

◆ beginStream()

void edm::WorkerManager::beginStream ( StreamID  iID,
StreamContext streamContext 
)

Definition at line 123 of file WorkerManager.cc.

References allWorkers_.

Referenced by edm::SecondaryEventProvider::beginStream(), and edm::StreamSchedule::beginStream().

123  {
124  for (auto& worker : allWorkers_) {
125  worker->beginStream(iID, streamContext);
126  }
127  }
AllWorkers allWorkers_

◆ deleteModuleIfExists()

void edm::WorkerManager::deleteModuleIfExists ( std::string const &  moduleLabel)

Definition at line 35 of file WorkerManager.cc.

References allWorkers_, edm::WorkerRegistry::deleteModule(), edm::WorkerRegistry::get(), HerwigMaxPtPartonFilter_cfi::moduleLabel, MatrixUtil::remove(), edm::UnscheduledCallProducer::removeWorker(), unscheduled_, and workerReg_.

Referenced by edm::StreamSchedule::deleteModule().

35  {
36  auto worker = workerReg_.get(moduleLabel);
37  if (worker != nullptr) {
38  auto eraseBeg = std::remove(allWorkers_.begin(), allWorkers_.end(), worker);
39  allWorkers_.erase(eraseBeg, allWorkers_.end());
40  unscheduled_.removeWorker(worker);
42  }
43  }
void removeWorker(Worker const *worker)
UnscheduledCallProducer unscheduled_
AllWorkers allWorkers_
Worker const * get(std::string const &moduleLabel) const
void deleteModule(std::string const &moduleLabel)
Deletes the module of the Worker, but the Worker continues to exist.
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:223
WorkerRegistry workerReg_

◆ endJob() [1/2]

void edm::WorkerManager::endJob ( void  )

Definition at line 77 of file WorkerManager.cc.

References allWorkers_.

Referenced by edm::SecondaryEventProvider::endJob().

77  {
78  for (auto& worker : allWorkers_) {
79  worker->endJob();
80  }
81  }
AllWorkers allWorkers_

◆ endJob() [2/2]

void edm::WorkerManager::endJob ( ExceptionCollector collector)

Definition at line 83 of file WorkerManager.cc.

References edm::ExceptionCollector::addException(), allWorkers_, and edm::convertException::wrap().

83  {
84  for (auto& worker : allWorkers_) {
85  try {
86  convertException::wrap([&]() { worker->endJob(); });
87  } catch (cms::Exception const& ex) {
88  collector.addException(ex);
89  }
90  }
91  }
AllWorkers allWorkers_
auto wrap(F iFunc) -> decltype(iFunc())

◆ endStream()

void edm::WorkerManager::endStream ( StreamID  iID,
StreamContext streamContext 
)

Definition at line 129 of file WorkerManager.cc.

References allWorkers_.

Referenced by edm::SecondaryEventProvider::endStream(), and edm::StreamSchedule::endStream().

129  {
130  for (auto& worker : allWorkers_) {
131  worker->endStream(iID, streamContext);
132  }
133  }
AllWorkers allWorkers_

◆ getWorker()

Worker * edm::WorkerManager::getWorker ( ParameterSet pset,
ProductRegistry preg,
PreallocationConfiguration const *  prealloc,
std::shared_ptr< ProcessConfiguration const >  processConfiguration,
std::string const &  label 
)

Definition at line 45 of file WorkerManager.cc.

References actionTable_, edm::WorkerRegistry::getWorker(), label, submitPVValidationJobs::params, muonDTDigis_cfi::pset, and workerReg_.

Referenced by addToUnscheduledWorkers().

49  {
50  WorkerParams params(&pset, preg, prealloc, processConfiguration, *actionTable_);
52  }
ExceptionToActionTable const * actionTable_
char const * label
WorkerRegistry workerReg_
Worker * getWorker(WorkerParams const &p, std::string const &moduleLabel)
Retrieve the particular instance of the worker.

◆ processAccumulatorsAsync()

template<typename T >
void edm::WorkerManager::processAccumulatorsAsync ( WaitingTaskHolder  task,
typename T::TransitionInfoType const &  info,
ServiceToken const &  token,
StreamID  streamID,
ParentContext const &  parentContext,
typename T::Context const *  context 
)

Definition at line 123 of file WorkerManager.h.

References visDQMUpload::context, info(), eostools::move(), edm::UnscheduledCallProducer::runAccumulatorsAsync(), TrackValidation_cff::task, unpackBuffers-CaloStage2::token, and unscheduled_.

Referenced by edm::StreamSchedule::processOneEventAsync().

128  {
129  unscheduled_.runAccumulatorsAsync<T>(std::move(task), info, token, streamID, parentContext, context);
130  }
static const TGPicture * info(bool iBackgroundIsBlack)
UnscheduledCallProducer unscheduled_
long double T
def move(src, dest)
Definition: eostools.py:511
void runAccumulatorsAsync(WaitingTaskHolder task, typename T::TransitionInfoType const &info, ServiceToken const &token, StreamID streamID, ParentContext const &parentContext, typename T::Context const *context)

◆ processOneOccurrenceAsync()

template<typename T , typename U >
void edm::WorkerManager::processOneOccurrenceAsync ( WaitingTaskHolder  task,
typename T::TransitionInfoType &  info,
ServiceToken const &  token,
StreamID  streamID,
typename T::Context const *  topContext,
U const *  context 
)

Definition at line 112 of file WorkerManager.h.

References visDQMUpload::context, info(), eostools::move(), edm::UnscheduledCallProducer::runNowAsync(), TrackValidation_cff::task, unpackBuffers-CaloStage2::token, mitigatedMETSequence_cff::U, and unscheduled_.

Referenced by edm::StreamSchedule::processOneStreamAsync().

117  {
118  //make sure the unscheduled items see this run or lumi transition
119  unscheduled_.runNowAsync<T, U>(std::move(task), info, token, streamID, topContext, context);
120  }
static const TGPicture * info(bool iBackgroundIsBlack)
UnscheduledCallProducer unscheduled_
void runNowAsync(WaitingTaskHolder task, typename T::TransitionInfoType const &info, ServiceToken const &token, StreamID streamID, typename T::Context const *topContext, U const *context) const
long double T
def move(src, dest)
Definition: eostools.py:511

◆ resetAll()

void edm::WorkerManager::resetAll ( )

Definition at line 135 of file WorkerManager.cc.

References allWorkers_, edm::for_all(), and edm::Worker::reset().

Referenced by edm::GlobalSchedule::processOneGlobalAsync(), edm::StreamSchedule::processOneStreamAsync(), and setupResolvers().

135 { for_all(allWorkers_, std::bind(&Worker::reset, std::placeholders::_1)); }
AllWorkers allWorkers_
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
void reset()
Definition: Worker.h:188

◆ setupOnDemandSystem()

void edm::WorkerManager::setupOnDemandSystem ( EventTransitionInfo const &  info)

Definition at line 152 of file WorkerManager.cc.

References info(), edm::UnscheduledCallProducer::setEventTransitionInfo(), and unscheduled_.

Referenced by edm::StreamSchedule::processOneEventAsync(), and edm::SecondaryEventProvider::setupPileUpEvent().

152  {
154  }
static const TGPicture * info(bool iBackgroundIsBlack)
UnscheduledCallProducer unscheduled_
void setEventTransitionInfo(EventTransitionInfo const &info)

◆ setupResolvers()

void edm::WorkerManager::setupResolvers ( Principal principal)

◆ unscheduledWorkers()

AllWorkers const& edm::WorkerManager::unscheduledWorkers ( ) const
inline

Member Data Documentation

◆ actionTable_

ExceptionToActionTable const* edm::WorkerManager::actionTable_
private

Definition at line 105 of file WorkerManager.h.

Referenced by actionTable(), and getWorker().

◆ allWorkers_

AllWorkers edm::WorkerManager::allWorkers_
private

◆ lastSetupEventPrincipal_

void const* edm::WorkerManager::lastSetupEventPrincipal_
private

Definition at line 108 of file WorkerManager.h.

Referenced by setupResolvers().

◆ unscheduled_

UnscheduledCallProducer edm::WorkerManager::unscheduled_
private

◆ workerReg_

WorkerRegistry edm::WorkerManager::workerReg_
private

Definition at line 104 of file WorkerManager.h.

Referenced by deleteModuleIfExists(), and getWorker().