CMS 3D CMS Logo

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 &)
 
void endJob (ExceptionCollector &collector)
 
std::vector< ModuleDescription const * > getAllModuleDescriptions () const
 
void getTriggerReport (TriggerReport &rep) 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::MyPrincipal &principal, EventSetup const &eventSetup, 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 75 of file GlobalSchedule.h.

Member Typedef Documentation

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

Definition at line 78 of file GlobalSchedule.h.

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

Definition at line 77 of file GlobalSchedule.h.

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

Definition at line 79 of file GlobalSchedule.h.

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

Definition at line 80 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 23 of file GlobalSchedule.cc.

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

34  :
35  actReg_(areg),
36  processContext_(processContext)
37  {
38  workerManagers_.reserve(prealloc.numberOfLuminosityBlocks());
39  for(unsigned int i = 0; i<prealloc.numberOfLuminosityBlocks(); ++i) {
40  workerManagers_.emplace_back(modReg,areg,actions);
41  }
42  for (auto const& moduleLabel : iModulesToUse) {
43  bool isTracked;
44  ParameterSet* modpset = proc_pset.getPSetForUpdate(moduleLabel, isTracked);
45  if (modpset != nullptr) { // It will be null for PathStatusInserters, it should
46  // be impossible to be null for anything else
47  assert(isTracked);
48 
49  //side effect keeps this module around
50  for(auto& wm: workerManagers_) {
51  wm.addToAllWorkers(wm.getWorker(*modpset, pregistry, &prealloc,processConfiguration, moduleLabel));
52  }
53  }
54  }
55  if(inserter) {
56  inserter->doPreallocate(prealloc);
57  for(auto& wm: workerManagers_) {
58  auto results_inserter = WorkerPtr(new edm::WorkerT<TriggerResultInserter::ModuleType>(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_) {
71  inserterPtr->moduleDescription(),
72  &actions));
73  workerPtr->setActivityRegistry(actReg_);
74  wm.addToAllWorkers(workerPtr.get());
75  extraWorkers_.emplace_back(std::move(workerPtr));
76  }
77  }
78 
79  for(auto & endPathStatusInserter : endPathStatusInserters) {
80  std::shared_ptr<EndPathStatusInserter> inserterPtr = get_underlying(endPathStatusInserter);
81  inserterPtr->doPreallocate(prealloc);
82  for(auto& wm: workerManagers_) {
84  inserterPtr->moduleDescription(),
85  &actions));
86  workerPtr->setActivityRegistry(actReg_);
87  wm.addToAllWorkers(workerPtr.get());
88  extraWorkers_.emplace_back(std::move(workerPtr));
89  }
90  }
91 
92  } // GlobalSchedule::GlobalSchedule
std::vector< WorkerManager > workerManagers_
roAction_t actions[nactions]
Definition: GenABIO.cc:187
T & get_underlying(propagate_const< T > &)
std::shared_ptr< Worker > WorkerPtr
std::shared_ptr< ActivityRegistry > actReg_
ProcessContext const * processContext_
def move(src, dest)
Definition: eostools.py:510
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.

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

returns the collection of pointers to workers

Definition at line 125 of file GlobalSchedule.h.

Referenced by getAllModuleDescriptions().

125  {
126  return workerManagers_[0].allWorkers();
127  }
std::vector< WorkerManager > workerManagers_
void edm::GlobalSchedule::beginJob ( ProductRegistry const &  iRegistry)

Definition at line 98 of file GlobalSchedule.cc.

References workerManagers_.

98  {
99  workerManagers_[0].beginJob(iRegistry);
100  }
std::vector< WorkerManager > workerManagers_
void edm::GlobalSchedule::endJob ( ExceptionCollector collector)

Definition at line 94 of file GlobalSchedule.cc.

References workerManagers_.

94  {
95  workerManagers_[0].endJob(collector);
96  }
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 122 of file GlobalSchedule.cc.

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

122  {
123  std::vector<ModuleDescription const*> result;
124  result.reserve(allWorkers().size());
125 
126  for (auto const& worker : allWorkers()) {
127  ModuleDescription const* p = worker->descPtr();
128  result.push_back(p);
129  }
130  return result;
131  }
size
Write out results.
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
void edm::GlobalSchedule::getTriggerReport ( TriggerReport rep) const

Return the trigger report information on paths, modules-in-path, modules-in-endpath, and modules.

template<typename T >
void edm::GlobalSchedule::processOneGlobalAsync ( WaitingTaskHolder  holder,
typename T::MyPrincipal &  principal,
EventSetup const &  eventSetup,
ServiceToken const &  token,
bool  cleaningUpAfterException = false 
)

Definition at line 166 of file GlobalSchedule.h.

References edm::addContextAndPrintException(), lumiQTWidget::aw, cms::Exception::context(), edm::WaitingTaskHolder::doneWaiting(), edm::ExceptionFromThisContext, edm::StreamID::invalidStreamID(), edm::make_waiting_task(), groupFilesInBlocks::reverse, and edm::convertException::wrap().

170  {
171  try {
172  //need the doneTask to own the memory
173  auto globalContext = std::make_shared<GlobalContext>(T::makeGlobalContext(ep, processContext_));
174 
175  if(actReg_) {
176  //Services may depend upon each other
177  ServiceRegistry::Operate op(token);
178  T::preScheduleSignal(actReg_.get(), globalContext.get());
179  }
180 
181  auto doneTask = make_waiting_task(tbb::task::allocate_root(),
182  [this,iHolder, cleaningUpAfterException, globalContext, token](std::exception_ptr const* iPtr) mutable
183  {
184  std::exception_ptr excpt;
185  if(iPtr) {
186  excpt = *iPtr;
187  //add context information to the exception and print message
188  try {
189  convertException::wrap([&]() {
190  std::rethrow_exception(excpt);
191  });
192  } catch(cms::Exception& ex) {
193  //TODO: should add the transition type info
194  std::ostringstream ost;
195  if(ex.context().empty()) {
196  ost<<"Processing "<<T::transitionName()<<" ";
197  }
198  ServiceRegistry::Operate op(token);
199  addContextAndPrintException(ost.str().c_str(), ex, cleaningUpAfterException);
200  excpt = std::current_exception();
201  }
202  if(actReg_) {
203  ServiceRegistry::Operate op(token);
204  actReg_->preGlobalEarlyTerminationSignal_(*globalContext,TerminationOrigin::ExceptionFromThisContext);
205  }
206  }
207  if(actReg_) {
208  try {
209  ServiceRegistry::Operate op(token);
210  T::postScheduleSignal(actReg_.get(), globalContext.get());
211  } catch(...) {
212  if(not excpt) {
213  excpt = std::current_exception();
214  }
215  }
216  }
217  iHolder.doneWaiting(excpt);
218 
219  });
220  workerManagers_[ep.index()].resetAll();
221 
222  ParentContext parentContext(globalContext.get());
223  //make sure the ProductResolvers know about their
224  // workers to allow proper data dependency handling
225  workerManagers_[ep.index()].setupOnDemandSystem(ep,es);
226 
227  //make sure the task doesn't get run until all workers have beens started
228  WaitingTaskHolder holdForLoop(doneTask);
229  auto& aw = workerManagers_[ep.index()].allWorkers();
230  for(Worker* worker: boost::adaptors::reverse(aw) ) {
231  worker->doWorkAsync<T>(doneTask,ep,es,token, StreamID::invalidStreamID(),parentContext,globalContext.get());
232  }
233  } catch(...) {
234  iHolder.doneWaiting(std::current_exception());
235  }
236  }
std::vector< WorkerManager > workerManagers_
void addContextAndPrintException(char const *context, cms::Exception &ex, bool disablePrint)
static StreamID invalidStreamID()
Definition: StreamID.h:48
std::list< std::string > const & context() const
Definition: Exception.cc:191
std::shared_ptr< ActivityRegistry > actReg_
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
Definition: WaitingTask.h:92
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 102 of file GlobalSchedule.cc.

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

103  {
104  Worker* found = nullptr;
105  for(auto& wm: workerManagers_) {
106  for (auto const& worker : wm.allWorkers()) {
107  if (worker->description().moduleLabel() == iLabel) {
108  found = worker;
109  break;
110  }
111  }
112  if (nullptr == found) {
113  return;
114  }
115 
116  iMod->replaceModuleFor(found);
117  found->beginJob();
118  }
119  }
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 158 of file GlobalSchedule.h.

Referenced by GlobalSchedule().

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

Definition at line 159 of file GlobalSchedule.h.

Referenced by GlobalSchedule().

ProcessContext const* edm::GlobalSchedule::processContext_
private

Definition at line 160 of file GlobalSchedule.h.

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

Definition at line 157 of file GlobalSchedule.h.

Referenced by beginJob(), endJob(), GlobalSchedule(), and replaceModule().