CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
edm::GlobalSchedule Class Reference

#include <GlobalSchedule.h>

Classes

class  SendTerminationSignalIfException
 

Public Types

typedef std::vector< Worker * > AllWorkers
 
typedef std::vector< std::string > vstring
 
typedef std::shared_ptr< WorkerWorkerPtr
 
typedef std::vector< Worker * > Workers
 

Public Member Functions

AllWorkers const & allWorkers () const
 returns the collection of pointers to workers More...
 
void beginJob (ProductRegistry const &, eventsetup::ESRecordsToProxyIndices const &, ProcessBlockHelperBase const &)
 
void deleteModule (std::string const &iLabel)
 Delete the module with label iLabel. More...
 
void endJob (ExceptionCollector &collector)
 
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 > processConfiguration, ProcessContext const *processContext)
 
 GlobalSchedule (GlobalSchedule const &)=delete
 
template<typename T >
void processOneGlobalAsync (WaitingTaskHolder holder, typename T::TransitionInfoType &, ServiceToken const &token, bool cleaningUpAfterException=false)
 
void replaceModule (maker::ModuleHolder *iMod, std::string const &iLabel)
 clone the type of module with label iLabel but configure with iPSet. More...
 
bool terminate () const
 Return whether each output module has reached its maximum count. More...
 

Private Member Functions

ExceptionToActionTable const & actionTable () const
 returns the action table More...
 

Private Attributes

std::shared_ptr< ActivityRegistryactReg_
 
std::vector
< edm::propagate_const
< WorkerPtr > > 
extraWorkers_
 
ProcessContext const * processContext_
 
std::vector< WorkerManagerworkerManagers_
 

Detailed Description

Definition at line 81 of file GlobalSchedule.h.

Member Typedef Documentation

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

Definition at line 84 of file GlobalSchedule.h.

typedef std::vector<std::string> edm::GlobalSchedule::vstring

Definition at line 83 of file GlobalSchedule.h.

typedef std::shared_ptr<Worker> edm::GlobalSchedule::WorkerPtr

Definition at line 85 of file GlobalSchedule.h.

typedef std::vector<Worker*> edm::GlobalSchedule::Workers

Definition at line 86 of file GlobalSchedule.h.

Constructor & Destructor Documentation

edm::GlobalSchedule::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 processConfiguration,
ProcessContext const *  processContext 
)

Definition at line 22 of file GlobalSchedule.cc.

References edm::actions, actReg_, cms::cuda::assert(), extraWorkers_, edm::get_underlying(), edm::ParameterSet::getPSetForUpdate(), mps_fire::i, eostools::move(), edm::PreallocationConfiguration::numberOfLuminosityBlocks(), and workerManagers_.

35  : actReg_(areg), processContext_(processContext) {
36  workerManagers_.reserve(prealloc.numberOfLuminosityBlocks());
37  for (unsigned int i = 0; i < prealloc.numberOfLuminosityBlocks(); ++i) {
38  workerManagers_.emplace_back(modReg, areg, actions);
39  }
40  for (auto const& moduleLabel : iModulesToUse) {
41  bool isTracked;
42  ParameterSet* modpset = proc_pset.getPSetForUpdate(moduleLabel, isTracked);
43  if (modpset != nullptr) { // It will be null for PathStatusInserters, it should
44  // be impossible to be null for anything else
45  assert(isTracked);
46 
47  //side effect keeps this module around
48  for (auto& wm : workerManagers_) {
49  wm.addToAllWorkers(wm.getWorker(*modpset, pregistry, &prealloc, processConfiguration, moduleLabel));
50  }
51  }
52  }
53  if (inserter) {
54  inserter->doPreallocate(prealloc);
55  for (auto& wm : workerManagers_) {
57  inserter, inserter->moduleDescription(), &actions)); // propagate_const<T> has no reset() function
58  results_inserter->setActivityRegistry(actReg_);
59  wm.addToAllWorkers(results_inserter.get());
60  extraWorkers_.emplace_back(std::move(results_inserter));
61  }
62  }
63 
64  for (auto& pathStatusInserter : pathStatusInserters) {
65  std::shared_ptr<PathStatusInserter> inserterPtr = get_underlying(pathStatusInserter);
66  inserterPtr->doPreallocate(prealloc);
67 
68  for (auto& wm : workerManagers_) {
69  WorkerPtr workerPtr(
70  new edm::WorkerT<PathStatusInserter::ModuleType>(inserterPtr, inserterPtr->moduleDescription(), &actions));
71  workerPtr->setActivityRegistry(actReg_);
72  wm.addToAllWorkers(workerPtr.get());
73  extraWorkers_.emplace_back(std::move(workerPtr));
74  }
75  }
76 
77  for (auto& endPathStatusInserter : endPathStatusInserters) {
78  std::shared_ptr<EndPathStatusInserter> inserterPtr = get_underlying(endPathStatusInserter);
79  inserterPtr->doPreallocate(prealloc);
80  for (auto& wm : workerManagers_) {
82  inserterPtr, inserterPtr->moduleDescription(), &actions));
83  workerPtr->setActivityRegistry(actReg_);
84  wm.addToAllWorkers(workerPtr.get());
85  extraWorkers_.emplace_back(std::move(workerPtr));
86  }
87  }
88 
89  } // GlobalSchedule::GlobalSchedule
std::vector< WorkerManager > workerManagers_
processConfiguration
Definition: Schedule.cc:687
assert(be >=bs)
actions
Definition: Schedule.cc:687
def move
Definition: eostools.py:511
std::shared_ptr< Worker > WorkerPtr
areg
Definition: Schedule.cc:687
std::shared_ptr< ActivityRegistry > actReg_
constexpr T & get_underlying(propagate_const< T > &)
ProcessContext const * processContext_
prealloc
Definition: Schedule.cc:687
std::vector< edm::propagate_const< WorkerPtr > > extraWorkers_
edm::GlobalSchedule::GlobalSchedule ( GlobalSchedule const &  )
delete

Member Function Documentation

ExceptionToActionTable const& edm::GlobalSchedule::actionTable ( ) const
inlineprivate

returns the action table

Definition at line 153 of file GlobalSchedule.h.

References workerManagers_.

153 { return workerManagers_[0].actionTable(); }
std::vector< WorkerManager > workerManagers_
AllWorkers const& edm::GlobalSchedule::allWorkers ( ) const
inline

returns the collection of pointers to workers

Definition at line 129 of file GlobalSchedule.h.

References workerManagers_.

Referenced by getAllModuleDescriptions().

129 { return workerManagers_[0].allWorkers(); }
std::vector< WorkerManager > workerManagers_
void edm::GlobalSchedule::beginJob ( ProductRegistry const &  iRegistry,
eventsetup::ESRecordsToProxyIndices const &  iESIndices,
ProcessBlockHelperBase const &  processBlockHelperBase 
)

Definition at line 93 of file GlobalSchedule.cc.

References workerManagers_.

95  {
96  workerManagers_[0].beginJob(iRegistry, iESIndices, processBlockHelperBase);
97  }
std::vector< WorkerManager > workerManagers_
void edm::GlobalSchedule::deleteModule ( std::string const &  iLabel)

Delete the module with label iLabel.

Definition at line 117 of file GlobalSchedule.cc.

References workerManagers_.

117  {
118  for (auto& wm : workerManagers_) {
119  wm.deleteModuleIfExists(iLabel);
120  }
121  }
std::vector< WorkerManager > workerManagers_
void edm::GlobalSchedule::endJob ( ExceptionCollector collector)

Definition at line 91 of file GlobalSchedule.cc.

References workerManagers_.

91 { workerManagers_[0].endJob(collector); }
std::vector< WorkerManager > workerManagers_
std::vector< ModuleDescription const * > edm::GlobalSchedule::getAllModuleDescriptions ( ) const

Return a vector allowing const access to all the ModuleDescriptions for this GlobalSchedule. *** N.B. *** Ownership of the ModuleDescriptions is not *** passed to the caller. Do not call delete on these *** pointers!

Definition at line 123 of file GlobalSchedule.cc.

References allWorkers(), AlCaHLTBitMon_ParallelJobs::p, mps_fire::result, and findQualityFiles::size.

123  {
124  std::vector<ModuleDescription const*> result;
125  result.reserve(allWorkers().size());
126 
127  for (auto const& worker : allWorkers()) {
128  ModuleDescription const* p = worker->description();
129  result.push_back(p);
130  }
131  return result;
132  }
tuple result
Definition: mps_fire.py:311
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
tuple size
Write out results.
template<typename T >
void edm::GlobalSchedule::processOneGlobalAsync ( WaitingTaskHolder  holder,
typename T::TransitionInfoType &  transitionInfo,
ServiceToken const &  token,
bool  cleaningUpAfterException = false 
)

Definition at line 162 of file GlobalSchedule.h.

References actReg_, edm::addContextAndPrintException(), CMS_SA_ALLOW, cms::Exception::context(), edm::WaitingTaskHolder::doneWaiting(), edm::ExceptionFromThisContext, edm::WaitingTaskHolder::group(), edm::StreamID::invalidStreamID(), edm::ServiceWeakToken::lock(), edm::make_waiting_task(), processContext_, unpackBuffers-CaloStage2::token, workerManagers_, and edm::convertException::wrap().

165  {
166  auto const& principal = transitionInfo.principal();
167 
168  // Caught exception is propagated via WaitingTaskHolder
169  CMS_SA_ALLOW try {
170  //need the doneTask to own the memory
171  auto globalContext = std::make_shared<GlobalContext>(T::makeGlobalContext(principal, processContext_));
172 
173  if (actReg_) {
174  //Services may depend upon each other
176  T::preScheduleSignal(actReg_.get(), globalContext.get());
177  }
178 
179  ServiceWeakToken weakToken = token;
180  auto doneTask = make_waiting_task(
181  [this, iHolder, cleaningUpAfterException, globalContext, weakToken](std::exception_ptr const* iPtr) mutable {
182  std::exception_ptr excpt;
183  if (iPtr) {
184  excpt = *iPtr;
185  //add context information to the exception and print message
186  try {
187  convertException::wrap([&]() { std::rethrow_exception(excpt); });
188  } catch (cms::Exception& ex) {
189  //TODO: should add the transition type info
190  std::ostringstream ost;
191  if (ex.context().empty()) {
192  ost << "Processing " << T::transitionName() << " ";
193  }
194  ServiceRegistry::Operate op(weakToken.lock());
195  addContextAndPrintException(ost.str().c_str(), ex, cleaningUpAfterException);
196  excpt = std::current_exception();
197  }
198  if (actReg_) {
199  ServiceRegistry::Operate op(weakToken.lock());
200  actReg_->preGlobalEarlyTerminationSignal_(*globalContext, TerminationOrigin::ExceptionFromThisContext);
201  }
202  }
203  if (actReg_) {
204  // Caught exception is propagated via WaitingTaskHolder
205  CMS_SA_ALLOW try {
206  ServiceRegistry::Operate op(weakToken.lock());
207  T::postScheduleSignal(actReg_.get(), globalContext.get());
208  } catch (...) {
209  if (not excpt) {
210  excpt = std::current_exception();
211  }
212  }
213  }
214  iHolder.doneWaiting(excpt);
215  });
216  WorkerManager& workerManager = workerManagers_[principal.index()];
217  workerManager.resetAll();
218 
219  ParentContext parentContext(globalContext.get());
220  //make sure the ProductResolvers know about their
221  // workers to allow proper data dependency handling
222  workerManager.setupResolvers(transitionInfo.principal());
223 
224  //make sure the task doesn't get run until all workers have beens started
225  WaitingTaskHolder holdForLoop(*iHolder.group(), doneTask);
226  auto& aw = workerManager.allWorkers();
227  for (Worker* worker : boost::adaptors::reverse(aw)) {
228  worker->doWorkAsync<T>(
229  holdForLoop, transitionInfo, token, StreamID::invalidStreamID(), parentContext, globalContext.get());
230  }
231  } catch (...) {
232  iHolder.doneWaiting(std::current_exception());
233  }
234  }
#define CMS_SA_ALLOW
std::vector< WorkerManager > workerManagers_
void addContextAndPrintException(char const *context, cms::Exception &ex, bool disablePrint)
static StreamID invalidStreamID()
Definition: StreamID.h:45
std::list< std::string > const & context() const
Definition: Exception.cc:147
FunctorWaitingTask< F > * make_waiting_task(F f)
Definition: WaitingTask.h:101
std::shared_ptr< ActivityRegistry > actReg_
auto wrap(F iFunc) -> decltype(iFunc())
ProcessContext const * processContext_
long double T
void edm::GlobalSchedule::replaceModule ( maker::ModuleHolder iMod,
std::string const &  iLabel 
)

clone the type of module with label iLabel but configure with iPSet.

Definition at line 99 of file GlobalSchedule.cc.

References edm::Worker::beginJob(), newFWLiteAna::found, edm::maker::ModuleHolder::replaceModuleFor(), and workerManagers_.

99  {
100  Worker* found = nullptr;
101  for (auto& wm : workerManagers_) {
102  for (auto const& worker : wm.allWorkers()) {
103  if (worker->description()->moduleLabel() == iLabel) {
104  found = worker;
105  break;
106  }
107  }
108  if (nullptr == found) {
109  return;
110  }
111 
112  iMod->replaceModuleFor(found);
113  found->beginJob();
114  }
115  }
std::vector< WorkerManager > workerManagers_
bool edm::GlobalSchedule::terminate ( ) const

Return whether each output module has reached its maximum count.

Member Data Documentation

std::shared_ptr<ActivityRegistry> edm::GlobalSchedule::actReg_
private

Definition at line 156 of file GlobalSchedule.h.

Referenced by GlobalSchedule(), and processOneGlobalAsync().

std::vector<edm::propagate_const<WorkerPtr> > edm::GlobalSchedule::extraWorkers_
private

Definition at line 157 of file GlobalSchedule.h.

Referenced by GlobalSchedule().

ProcessContext const* edm::GlobalSchedule::processContext_
private

Definition at line 158 of file GlobalSchedule.h.

Referenced by processOneGlobalAsync().

std::vector<WorkerManager> edm::GlobalSchedule::workerManagers_
private