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::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 processOneGlobal (typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
 
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)
 
template<typename T >
void runNow (typename T::MyPrincipal const &p, EventSetup const &es, GlobalContext const *context)
 

Private Attributes

std::shared_ptr< ActivityRegistryactReg_
 
ProcessContext const * processContext_
 
edm::propagate_const< WorkerPtrresults_inserter_
 
WorkerManager workerManager_
 

Detailed Description

Definition at line 73 of file GlobalSchedule.h.

Member Typedef Documentation

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

Definition at line 76 of file GlobalSchedule.h.

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

Definition at line 75 of file GlobalSchedule.h.

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

Definition at line 77 of file GlobalSchedule.h.

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

Definition at line 78 of file GlobalSchedule.h.

Constructor & Destructor Documentation

edm::GlobalSchedule::GlobalSchedule ( std::shared_ptr< TriggerResultInserter inserter,
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 19 of file GlobalSchedule.cc.

References actions, actReg_, addToAllWorkers(), edm::errors::Configuration, Exception, edm::propagate_const< T >::get(), edm::ParameterSet::getPSetForUpdate(), edm::WorkerManager::getWorker(), results_inserter_, and workerManager_.

28  :
29  workerManager_(modReg,areg,actions),
30  actReg_(areg),
31  processContext_(processContext)
32  {
33  for (auto const& moduleLabel : iModulesToUse) {
34  bool isTracked;
35  ParameterSet* modpset = proc_pset.getPSetForUpdate(moduleLabel, isTracked);
36  if (modpset == 0) {
38  "The unknown module label \"" << moduleLabel <<
39  "\"\n please check spelling";
40  }
41  assert(isTracked);
42 
43  //side effect keeps this module around
44  addToAllWorkers(workerManager_.getWorker(*modpset, pregistry, &prealloc,processConfiguration, moduleLabel));
45 
46  }
47  if(inserter) {
48  results_inserter_ = WorkerPtr(new edm::WorkerT<TriggerResultInserter::ModuleType>(inserter, inserter->moduleDescription(), &actions)); // propagate_const<T> has no reset() function
49  inserter->doPreallocate(prealloc);
50  results_inserter_->setActivityRegistry(actReg_);
52  }
53 
54  } // GlobalSchedule::GlobalSchedule
edm::propagate_const< WorkerPtr > results_inserter_
roAction_t actions[nactions]
Definition: GenABIO.cc:187
void addToAllWorkers(Worker *w)
std::shared_ptr< Worker > WorkerPtr
element_type const * get() const
std::shared_ptr< ActivityRegistry > actReg_
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 158 of file GlobalSchedule.h.

References w.

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

Definition at line 95 of file GlobalSchedule.cc.

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

Referenced by GlobalSchedule().

95  {
97  }
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 125 of file GlobalSchedule.h.

Referenced by getAllModuleDescriptions(), and replaceModule().

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

Definition at line 61 of file GlobalSchedule.cc.

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

61  {
62  workerManager_.beginJob(iRegistry);
63  }
void beginJob(ProductRegistry const &iRegistry)
WorkerManager workerManager_
void edm::GlobalSchedule::endJob ( ExceptionCollector collector)

Definition at line 57 of file GlobalSchedule.cc.

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

57  {
58  workerManager_.endJob(collector);
59  }
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 83 of file GlobalSchedule.cc.

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

83  {
84  std::vector<ModuleDescription const*> result;
85  result.reserve(allWorkers().size());
86 
87  for (auto const& worker : allWorkers()) {
88  ModuleDescription const* p = worker->descPtr();
89  result.push_back(p);
90  }
91  return result;
92  }
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::processOneGlobal ( typename T::MyPrincipal &  principal,
EventSetup const &  eventSetup,
bool  cleaningUpAfterException = false 
)

Definition at line 175 of file GlobalSchedule.h.

References edm::addContextAndPrintException(), cms::Exception::context(), edm::StreamID::invalidStreamID(), and edm::convertException::wrap().

177  {
178  GlobalContext globalContext = T::makeGlobalContext(ep, processContext_);
179 
180  GlobalScheduleSignalSentry<T> sentry(actReg_.get(), &globalContext);
181 
182  SendTerminationSignalIfException terminationSentry(actReg_.get(), &globalContext);
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  // This call takes care of the unscheduled processing.
190  workerManager_.processOneOccurrence<T>(ep, es, StreamID::invalidStreamID(), &globalContext, &globalContext, cleaningUpAfterException);
191 
192  try {
193  convertException::wrap([&]() {
194  runNow<T>(ep,es,&globalContext);
195  });
196  }
197  catch(cms::Exception& ex) {
198  if (ex.context().empty()) {
199  addContextAndPrintException("Calling function GlobalSchedule::processOneGlobal", ex, cleaningUpAfterException);
200  } else {
201  addContextAndPrintException("", ex, cleaningUpAfterException);
202  }
203  throw;
204  }
205  terminationSentry.completedSuccessfully();
206 
207  //If we got here no other exception has happened so we can propogate any Service related exceptions
208  sentry.allowThrow();
209  }
void processOneOccurrence(typename T::MyPrincipal &principal, EventSetup const &eventSetup, StreamID streamID, typename T::Context const *topContext, U const *context, bool cleaningUpAfterException=false)
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_
auto wrap(F iFunc) -> decltype(iFunc())
ProcessContext const * processContext_
WorkerManager workerManager_
long double T
template<typename T >
void edm::GlobalSchedule::processOneGlobalAsync ( WaitingTaskHolder  holder,
typename T::MyPrincipal &  principal,
EventSetup const &  eventSetup,
bool  cleaningUpAfterException = false 
)

Definition at line 213 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().

216  {
218 
219  //need the doneTask to own the memory
220  auto globalContext = std::make_shared<GlobalContext>(T::makeGlobalContext(ep, processContext_));
221 
222  if(actReg_) {
223  T::preScheduleSignal(actReg_.get(), globalContext.get());
224  }
225 
226 
227  //If we are in an end transition, we need to reset failed items since they might
228  // be set this time around
229  if( not T::begin_) {
230  ep.resetFailedFromThisProcess();
231  }
232 
233  auto doneTask = make_waiting_task(tbb::task::allocate_root(),
234  [this,iHolder, cleaningUpAfterException, globalContext, token](std::exception_ptr const* iPtr) mutable
235  {
236  ServiceRegistry::Operate op(token);
237  std::exception_ptr excpt;
238  if(iPtr) {
239  excpt = *iPtr;
240  //add context information to the exception and print message
241  try {
242  convertException::wrap([&]() {
243  std::rethrow_exception(excpt);
244  });
245  } catch(cms::Exception& ex) {
246  //TODO: should add the transition type info
247  std::ostringstream ost;
248  if(ex.context().empty()) {
249  ost<<"Processing "<<T::transitionName()<<" ";
250  }
251  addContextAndPrintException(ost.str().c_str(), ex, cleaningUpAfterException);
252  excpt = std::current_exception();
253  }
254  if(actReg_) {
255  actReg_->preGlobalEarlyTerminationSignal_(*globalContext,TerminationOrigin::ExceptionFromThisContext);
256  }
257  }
258  if(actReg_) {
259  try {
260  T::postScheduleSignal(actReg_.get(), globalContext.get());
261  } catch(...) {
262  if(not excpt) {
263  excpt = std::current_exception();
264  }
265  }
266  }
267  iHolder.doneWaiting(excpt);
268 
269  });
271 
272  ParentContext parentContext(globalContext.get());
273  //make sure the ProductResolvers know about their
274  // workers to allow proper data dependency handling
276 
277  //make sure the task doesn't get run until all workers have beens started
278  WaitingTaskHolder holdForLoop(doneTask);
279  for(auto& worker: boost::adaptors::reverse((allWorkers()))) {
280  worker->doWorkAsync<T>(doneTask,ep,es,StreamID::invalidStreamID(),parentContext,globalContext.get());
281  }
282 
283  }
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:90
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 65 of file GlobalSchedule.cc.

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

66  {
67  Worker* found = nullptr;
68  for (auto const& worker : allWorkers()) {
69  if (worker->description().moduleLabel() == iLabel) {
70  found = worker;
71  break;
72  }
73  }
74  if (nullptr == found) {
75  return;
76  }
77 
78  iMod->replaceModuleFor(found);
79  found->beginJob();
80  }
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
template<typename T >
void edm::GlobalSchedule::runNow ( typename T::MyPrincipal const &  p,
EventSetup const &  es,
GlobalContext const *  context 
)
private

Definition at line 287 of file GlobalSchedule.h.

References cms::Exception::addContext(), cms::Exception::context(), edm::StreamID::invalidStreamID(), and AlCaHLTBitMon_ParallelJobs::p.

288  {
289  //do nothing for event since we will run when requested
290  for(auto & worker: allWorkers()) {
291  try {
292  ParentContext parentContext(context);
293  worker->doWork<T>(p, es,StreamID::invalidStreamID(), parentContext, context);
294  }
295  catch (cms::Exception & ex) {
296  if(ex.context().empty()) {
297  std::ostringstream ost;
298  ost << "Processing " <<T::transitionName()<<" "<< p.id();
299  ex.addContext(ost.str());
300  }
301  throw;
302  }
303  }
304  }
static StreamID invalidStreamID()
Definition: StreamID.h:48
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
std::list< std::string > const & context() const
Definition: Exception.cc:191
void addContext(std::string const &context)
Definition: Exception.cc:227
long double T
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 165 of file GlobalSchedule.h.

Referenced by GlobalSchedule().

ProcessContext const* edm::GlobalSchedule::processContext_
private

Definition at line 169 of file GlobalSchedule.h.

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

Definition at line 166 of file GlobalSchedule.h.

Referenced by GlobalSchedule().

WorkerManager edm::GlobalSchedule::workerManager_
private

Definition at line 164 of file GlobalSchedule.h.

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