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, 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...
 
void addToAllWorkers (Worker *w)
 

Private Attributes

std::shared_ptr< ActivityRegistryactReg_
 
std::vector< edm::propagate_const< WorkerPtr > > endPathStatusInserterWorkers_
 
std::vector< edm::propagate_const< WorkerPtr > > pathStatusInserterWorkers_
 
ProcessContext const * processContext_
 
edm::propagate_const< WorkerPtrresults_inserter_
 
WorkerManager workerManager_
 

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 21 of file GlobalSchedule.cc.

References actions, actReg_, addToAllWorkers(), endPathStatusInserterWorkers_, edm::propagate_const< T >::get(), edm::get_underlying(), edm::ParameterSet::getPSetForUpdate(), edm::WorkerManager::getWorker(), pathStatusInserterWorkers_, results_inserter_, and workerManager_.

32  :
33  workerManager_(modReg,areg,actions),
34  actReg_(areg),
35  processContext_(processContext)
36  {
37  for (auto const& moduleLabel : iModulesToUse) {
38  bool isTracked;
39  ParameterSet* modpset = proc_pset.getPSetForUpdate(moduleLabel, isTracked);
40  if (modpset != nullptr) { // It will be null for PathStatusInserters, it should
41  // be impossible to be null for anything else
42  assert(isTracked);
43 
44  //side effect keeps this module around
45  addToAllWorkers(workerManager_.getWorker(*modpset, pregistry, &prealloc,processConfiguration, moduleLabel));
46  }
47  }
48  if(inserter) {
49  results_inserter_ = WorkerPtr(new edm::WorkerT<TriggerResultInserter::ModuleType>(inserter, inserter->moduleDescription(), &actions)); // propagate_const<T> has no reset() function
50  inserter->doPreallocate(prealloc);
51  results_inserter_->setActivityRegistry(actReg_);
53  }
54 
55  for(auto & pathStatusInserter : pathStatusInserters) {
56  std::shared_ptr<PathStatusInserter> inserterPtr = get_underlying(pathStatusInserter);
58  inserterPtr->moduleDescription(),
59  &actions));
60  pathStatusInserterWorkers_.emplace_back(workerPtr);
61  inserterPtr->doPreallocate(prealloc);
62  workerPtr->setActivityRegistry(actReg_);
63  addToAllWorkers(workerPtr.get());
64  }
65 
66  for(auto & endPathStatusInserter : endPathStatusInserters) {
67  std::shared_ptr<EndPathStatusInserter> inserterPtr = get_underlying(endPathStatusInserter);
69  inserterPtr->moduleDescription(),
70  &actions));
71  endPathStatusInserterWorkers_.emplace_back(workerPtr);
72  inserterPtr->doPreallocate(prealloc);
73  workerPtr->setActivityRegistry(actReg_);
74  addToAllWorkers(workerPtr.get());
75  }
76 
77  } // GlobalSchedule::GlobalSchedule
edm::propagate_const< WorkerPtr > results_inserter_
std::vector< edm::propagate_const< WorkerPtr > > endPathStatusInserterWorkers_
roAction_t actions[nactions]
Definition: GenABIO.cc:187
void addToAllWorkers(Worker *w)
T & get_underlying(propagate_const< T > &)
std::shared_ptr< Worker > WorkerPtr
element_type const * get() const
std::shared_ptr< ActivityRegistry > actReg_
std::vector< edm::propagate_const< WorkerPtr > > pathStatusInserterWorkers_
ProcessContext const * processContext_
WorkerManager workerManager_
Worker * getWorker(ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, std::string const &label)
edm::GlobalSchedule::GlobalSchedule ( GlobalSchedule const &  )
delete

Member Function Documentation

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

returns the action table

Definition at line 152 of file GlobalSchedule.h.

References w.

152  {
153  return workerManager_.actionTable();
154  }
WorkerManager workerManager_
ExceptionToActionTable const & actionTable() const
Definition: WorkerManager.h:79
void edm::GlobalSchedule::addToAllWorkers ( Worker w)
private

Definition at line 117 of file GlobalSchedule.cc.

References edm::WorkerManager::addToAllWorkers(), and workerManager_.

Referenced by GlobalSchedule().

117  {
119  }
const double w
Definition: UKUtility.cc:23
WorkerManager workerManager_
void addToAllWorkers(Worker *w)
AllWorkers const& edm::GlobalSchedule::allWorkers ( ) const
inline

returns the collection of pointers to workers

Definition at line 124 of file GlobalSchedule.h.

Referenced by getAllModuleDescriptions(), and replaceModule().

124  {
125  return workerManager_.allWorkers();
126  }
AllWorkers const & allWorkers() const
Definition: WorkerManager.h:75
WorkerManager workerManager_
void edm::GlobalSchedule::beginJob ( ProductRegistry const &  iRegistry)

Definition at line 83 of file GlobalSchedule.cc.

References edm::WorkerManager::beginJob(), and workerManager_.

83  {
84  workerManager_.beginJob(iRegistry);
85  }
void beginJob(ProductRegistry const &iRegistry)
WorkerManager workerManager_
void edm::GlobalSchedule::endJob ( ExceptionCollector collector)

Definition at line 79 of file GlobalSchedule.cc.

References edm::WorkerManager::endJob(), and workerManager_.

79  {
80  workerManager_.endJob(collector);
81  }
WorkerManager workerManager_
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 105 of file GlobalSchedule.cc.

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

105  {
106  std::vector<ModuleDescription const*> result;
107  result.reserve(allWorkers().size());
108 
109  for (auto const& worker : allWorkers()) {
110  ModuleDescription const* p = worker->descPtr();
111  result.push_back(p);
112  }
113  return result;
114  }
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,
bool  cleaningUpAfterException = false 
)

Definition at line 170 of file GlobalSchedule.h.

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

173  {
175 
176  //need the doneTask to own the memory
177  auto globalContext = std::make_shared<GlobalContext>(T::makeGlobalContext(ep, processContext_));
178 
179  if(actReg_) {
180  T::preScheduleSignal(actReg_.get(), globalContext.get());
181  }
182 
183 
184  //If we are in an end transition, we need to reset failed items since they might
185  // be set this time around
186  if( not T::begin_) {
187  ep.resetFailedFromThisProcess();
188  }
189 
190  auto doneTask = make_waiting_task(tbb::task::allocate_root(),
191  [this,iHolder, cleaningUpAfterException, globalContext, token](std::exception_ptr const* iPtr) mutable
192  {
193  ServiceRegistry::Operate op(token);
194  std::exception_ptr excpt;
195  if(iPtr) {
196  excpt = *iPtr;
197  //add context information to the exception and print message
198  try {
199  convertException::wrap([&]() {
200  std::rethrow_exception(excpt);
201  });
202  } catch(cms::Exception& ex) {
203  //TODO: should add the transition type info
204  std::ostringstream ost;
205  if(ex.context().empty()) {
206  ost<<"Processing "<<T::transitionName()<<" ";
207  }
208  addContextAndPrintException(ost.str().c_str(), ex, cleaningUpAfterException);
209  excpt = std::current_exception();
210  }
211  if(actReg_) {
212  actReg_->preGlobalEarlyTerminationSignal_(*globalContext,TerminationOrigin::ExceptionFromThisContext);
213  }
214  }
215  if(actReg_) {
216  try {
217  T::postScheduleSignal(actReg_.get(), globalContext.get());
218  } catch(...) {
219  if(not excpt) {
220  excpt = std::current_exception();
221  }
222  }
223  }
224  iHolder.doneWaiting(excpt);
225 
226  });
228 
229  ParentContext parentContext(globalContext.get());
230  //make sure the ProductResolvers know about their
231  // workers to allow proper data dependency handling
233 
234  //make sure the task doesn't get run until all workers have beens started
235  WaitingTaskHolder holdForLoop(doneTask);
236  for(auto& worker: boost::adaptors::reverse((allWorkers()))) {
237  worker->doWorkAsync<T>(doneTask,ep,es,StreamID::invalidStreamID(),parentContext,globalContext.get());
238  }
239 
240  }
void addContextAndPrintException(char const *context, cms::Exception &ex, bool disablePrint)
static StreamID invalidStreamID()
Definition: StreamID.h:48
ServiceToken presentToken() const
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
std::list< std::string > const & context() const
Definition: Exception.cc:191
static ServiceRegistry & instance()
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_
WorkerManager workerManager_
void setupOnDemandSystem(Principal &principal, EventSetup const &es)
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 87 of file GlobalSchedule.cc.

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

88  {
89  Worker* found = nullptr;
90  for (auto const& worker : allWorkers()) {
91  if (worker->description().moduleLabel() == iLabel) {
92  found = worker;
93  break;
94  }
95  }
96  if (nullptr == found) {
97  return;
98  }
99 
100  iMod->replaceModuleFor(found);
101  found->beginJob();
102  }
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
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 159 of file GlobalSchedule.h.

Referenced by GlobalSchedule().

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

Definition at line 162 of file GlobalSchedule.h.

Referenced by GlobalSchedule().

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

Definition at line 161 of file GlobalSchedule.h.

Referenced by GlobalSchedule().

ProcessContext const* edm::GlobalSchedule::processContext_
private

Definition at line 164 of file GlobalSchedule.h.

edm::propagate_const<WorkerPtr> edm::GlobalSchedule::results_inserter_
private

Definition at line 160 of file GlobalSchedule.h.

Referenced by GlobalSchedule().

WorkerManager edm::GlobalSchedule::workerManager_
private

Definition at line 158 of file GlobalSchedule.h.

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