CMS 3D CMS Logo

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

#include <StreamSchedule.h>

Classes

class  SendTerminationSignalIfException
 

Public Types

typedef std::vector< Worker * > AllWorkers
 
typedef std::vector< PathNonTrigPaths
 
typedef std::vector< WorkerInPathPathWorkers
 
typedef std::vector< PathTrigPaths
 
typedef std::shared_ptr< HLTGlobalStatus const > TrigResConstPtr
 
typedef std::shared_ptr< HLTGlobalStatusTrigResPtr
 
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 availablePaths (std::vector< std::string > &oLabelsToFill) const
 adds to oLabelsToFill the labels for all paths in the process More...
 
void beginStream ()
 
void clearCounters ()
 Clear all the counters in the trigger report. More...
 
StreamContext const & context () const
 
void enableEndPaths (bool active)
 
bool endPathsEnabled () const
 
void endStream ()
 
std::vector< ModuleDescription const * > getAllModuleDescriptions () const
 
void getTriggerReport (TriggerReport &rep) const
 
void moduleDescriptionsInEndPath (std::string const &iEndPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
 
void moduleDescriptionsInPath (std::string const &iPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
 
void modulesInPath (std::string const &iPathLabel, std::vector< std::string > &oLabelsToFill) const
 adds to oLabelsToFill in execution order the labels of all modules in path iPathLabel More...
 
unsigned int numberOfUnscheduledModules () const
 
void processOneEventAsync (WaitingTaskHolder iTask, EventPrincipal &ep, EventSetup const &es, std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter >>> &pathStatusInserters)
 
template<typename T >
void processOneStreamAsync (WaitingTaskHolder iTask, 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...
 
StreamID streamID () const
 
 StreamSchedule (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 >, ParameterSet &proc_pset, service::TriggerNamesService const &tns, PreallocationConfiguration const &prealloc, ProductRegistry &pregistry, BranchIDListHelper &branchIDListHelper, ExceptionToActionTable const &actions, std::shared_ptr< ActivityRegistry > areg, std::shared_ptr< ProcessConfiguration > processConfiguration, bool allowEarlyDelete, StreamID streamID, ProcessContext const *processContext)
 
 StreamSchedule (StreamSchedule const &)=delete
 
int totalEvents () const
 
int totalEventsFailed () const
 
int totalEventsPassed () const
 

Private Member Functions

ExceptionToActionTable const & actionTable () const
 returns the action table More...
 
void addToAllWorkers (Worker *w)
 
void fillEndPath (ParameterSet &proc_pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, int bitpos, std::string const &name, std::vector< std::string > const &endPathNames)
 
void fillTrigPath (ParameterSet &proc_pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, int bitpos, std::string const &name, TrigResPtr, std::vector< std::string > const &endPathNames)
 
void fillWorkers (ParameterSet &proc_pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, std::string const &name, bool ignoreFilters, PathWorkers &out, std::vector< std::string > const &endPathNames)
 
void finishedPaths (std::exception_ptr, WaitingTaskHolder, EventPrincipal &ep, EventSetup const &es)
 
std::exception_ptr finishProcessOneEvent (std::exception_ptr)
 
void initializeEarlyDelete (ModuleRegistry &modReg, edm::ParameterSet const &opts, edm::ProductRegistry const &preg, bool allowEarlyDelete)
 
void makePathStatusInserters (std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter >>> &pathStatusInserters, std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter >>> &endPathStatusInserters, ExceptionToActionTable const &actions)
 
void reportSkipped (EventPrincipal const &ep) const
 
void resetAll ()
 
void resetEarlyDelete ()
 
TrigResConstPtr results () const
 
TrigResPtrresults ()
 

Private Attributes

std::shared_ptr< ActivityRegistryactReg_
 
std::vector< BranchToCountearlyDeleteBranchToCount_
 
std::vector< EarlyDeleteHelperearlyDeleteHelpers_
 
std::vector< unsigned int > earlyDeleteHelperToBranchIndicies_
 
std::vector< int > empty_end_paths_
 
std::vector< int > empty_trig_paths_
 
TrigPaths end_paths_
 
volatile bool endpathsAreActive_
 
std::vector< edm::propagate_const< WorkerPtr > > endPathStatusInserterWorkers_
 
unsigned int number_of_unscheduled_modules_
 
std::vector< edm::propagate_const< WorkerPtr > > pathStatusInserterWorkers_
 
edm::propagate_const< TrigResPtrresults_
 
edm::propagate_const< WorkerPtrresults_inserter_
 
std::atomic< bool > skippingEvent_
 
StreamContext streamContext_
 
StreamID streamID_
 
int total_events_
 
int total_passed_
 
TrigPaths trig_paths_
 
WorkerManager workerManager_
 

Detailed Description

Definition at line 147 of file StreamSchedule.h.

Member Typedef Documentation

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

Definition at line 155 of file StreamSchedule.h.

Definition at line 151 of file StreamSchedule.h.

Definition at line 159 of file StreamSchedule.h.

typedef std::vector<Path> edm::StreamSchedule::TrigPaths

Definition at line 150 of file StreamSchedule.h.

typedef std::shared_ptr<HLTGlobalStatus const> edm::StreamSchedule::TrigResConstPtr

Definition at line 153 of file StreamSchedule.h.

Definition at line 152 of file StreamSchedule.h.

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

Definition at line 149 of file StreamSchedule.h.

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

Definition at line 154 of file StreamSchedule.h.

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

Definition at line 157 of file StreamSchedule.h.

Constructor & Destructor Documentation

edm::StreamSchedule::StreamSchedule ( 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,
ParameterSet proc_pset,
service::TriggerNamesService const &  tns,
PreallocationConfiguration const &  prealloc,
ProductRegistry pregistry,
BranchIDListHelper branchIDListHelper,
ExceptionToActionTable const &  actions,
std::shared_ptr< ActivityRegistry areg,
std::shared_ptr< ProcessConfiguration processConfiguration,
bool  allowEarlyDelete,
StreamID  streamID,
ProcessContext const *  processContext 
)

Definition at line 135 of file StreamSchedule.cc.

References actReg_, addToAllWorkers(), edm::WorkerManager::addToUnscheduledWorkers(), allWorkers(), end_paths_, fillEndPath(), fillTrigPath(), edm::propagate_const< T >::get(), edm::service::TriggerNamesService::getEndPaths(), edm::ParameterSet::getParameter(), edm::ParameterSet::getPSetForUpdate(), edm::service::TriggerNamesService::getTrigPaths(), edm::ParameterSet::getUntrackedParameterSet(), initializeEarlyDelete(), diffTwoXMLs::label, makePathStatusInserters(), number_of_unscheduled_modules_, geometryDiff::opts, results(), results_inserter_, edm::WorkerManager::setOnDemandProducts(), trig_paths_, edm::StreamID::value(), and workerManager_.

149  :
150  workerManager_(modReg,areg, actions),
151  actReg_(areg),
152  results_(new HLTGlobalStatus(tns.getTrigPaths().size())),
154  trig_paths_(),
155  end_paths_(),
156  total_events_(),
157  total_passed_(),
160  streamContext_(streamID_, processContext),
161  endpathsAreActive_(true),
162  skippingEvent_(false){
163 
164  ParameterSet const& opts = proc_pset.getUntrackedParameterSet("options", ParameterSet());
165  bool hasPath = false;
166  std::vector<std::string> const& pathNames = tns.getTrigPaths();
167  std::vector<std::string> const& endPathNames = tns.getEndPaths();
168 
169  int trig_bitpos = 0;
170  trig_paths_.reserve(pathNames.size());
171  for (auto const& trig_name : pathNames) {
172  fillTrigPath(proc_pset, preg, &prealloc, processConfiguration, trig_bitpos, trig_name, results(), endPathNames);
173  ++trig_bitpos;
174  hasPath = true;
175  }
176 
177  if (hasPath) {
178  // the results inserter stands alone
179  inserter->setTrigResultForStream(streamID.value(), results());
180 
181  results_inserter_ = makeInserter(actions, actReg_, inserter);
183  }
184 
185  // fill normal endpaths
186  int bitpos = 0;
187  end_paths_.reserve(endPathNames.size());
188  for (auto const& end_path_name : endPathNames) {
189  fillEndPath(proc_pset, preg, &prealloc, processConfiguration, bitpos, end_path_name, endPathNames);
190  ++bitpos;
191  }
192 
193  makePathStatusInserters(pathStatusInserters, endPathStatusInserters, actions);
194 
195  //See if all modules were used
196  std::set<std::string> usedWorkerLabels;
197  for (auto const& worker : allWorkers()) {
198  usedWorkerLabels.insert(worker->description().moduleLabel());
199  }
200  std::vector<std::string> modulesInConfig(proc_pset.getParameter<std::vector<std::string> >("@all_modules"));
201  std::set<std::string> modulesInConfigSet(modulesInConfig.begin(), modulesInConfig.end());
202  std::vector<std::string> unusedLabels;
203  set_difference(modulesInConfigSet.begin(), modulesInConfigSet.end(),
204  usedWorkerLabels.begin(), usedWorkerLabels.end(),
205  back_inserter(unusedLabels));
206  std::set<std::string> unscheduledLabels;
207  std::vector<std::string> shouldBeUsedLabels;
208  if (!unusedLabels.empty()) {
209  //Need to
210  // 1) create worker
211  // 2) if it is a WorkerT<EDProducer>, add it to our list
212  // 3) hand list to our delayed reader
213  for (auto const& label : unusedLabels) {
214  bool isTracked;
215  ParameterSet* modulePSet(proc_pset.getPSetForUpdate(label, isTracked));
216  assert(isTracked);
217  assert(modulePSet != nullptr);
218  workerManager_.addToUnscheduledWorkers(*modulePSet, preg, &prealloc, processConfiguration, label, unscheduledLabels, shouldBeUsedLabels);
219  }
220  if (!shouldBeUsedLabels.empty()) {
221  std::ostringstream unusedStream;
222  unusedStream << "'" << shouldBeUsedLabels.front() << "'";
223  for (std::vector<std::string>::iterator itLabel = shouldBeUsedLabels.begin() + 1,
224  itLabelEnd = shouldBeUsedLabels.end();
225  itLabel != itLabelEnd;
226  ++itLabel) {
227  unusedStream << ",'" << *itLabel << "'";
228  }
229  LogInfo("path")
230  << "The following module labels are not assigned to any path:\n"
231  << unusedStream.str()
232  << "\n";
233  }
234  }
235  if (!unscheduledLabels.empty()) {
236  number_of_unscheduled_modules_=unscheduledLabels.size();
237  workerManager_.setOnDemandProducts(preg, unscheduledLabels);
238  }
239 
240 
241  initializeEarlyDelete(*modReg, opts,preg,allowEarlyDelete);
242 
243  } // StreamSchedule::StreamSchedule
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
roAction_t actions[nactions]
Definition: GenABIO.cc:187
void fillTrigPath(ParameterSet &proc_pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, int bitpos, std::string const &name, TrigResPtr, std::vector< std::string > const &endPathNames)
void initializeEarlyDelete(ModuleRegistry &modReg, edm::ParameterSet const &opts, edm::ProductRegistry const &preg, bool allowEarlyDelete)
void setOnDemandProducts(ProductRegistry &pregistry, std::set< std::string > const &unscheduledLabels) const
void addToUnscheduledWorkers(ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration > processConfiguration, std::string label, std::set< std::string > &unscheduledLabels, std::vector< std::string > &shouldBeUsedLabels)
volatile bool endpathsAreActive_
void addToAllWorkers(Worker *w)
edm::propagate_const< WorkerPtr > results_inserter_
unsigned int number_of_unscheduled_modules_
WorkerManager workerManager_
std::shared_ptr< ActivityRegistry > actReg_
void fillEndPath(ParameterSet &proc_pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, int bitpos, std::string const &name, std::vector< std::string > const &endPathNames)
StreamID streamID() const
StreamContext streamContext_
element_type const * get() const
unsigned int value() const
Definition: StreamID.h:46
edm::propagate_const< TrigResPtr > results_
std::atomic< bool > skippingEvent_
void makePathStatusInserters(std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter >>> &pathStatusInserters, std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter >>> &endPathStatusInserters, ExceptionToActionTable const &actions)
TrigResConstPtr results() const
edm::StreamSchedule::StreamSchedule ( StreamSchedule const &  )
delete

Member Function Documentation

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

returns the action table

Definition at line 289 of file StreamSchedule.h.

References dataset::name, geometryDiff::opts, MillePedeFileConverter_cfg::out, AlCaHLTBitMon_QueryRunRegistry::string, and w.

Referenced by fillEndPath(), fillTrigPath(), and finishedPaths().

289  {
290  return workerManager_.actionTable();
291  }
WorkerManager workerManager_
ExceptionToActionTable const & actionTable() const
Definition: WorkerManager.h:79
void edm::StreamSchedule::addToAllWorkers ( Worker w)
private

Definition at line 887 of file StreamSchedule.cc.

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

Referenced by fillEndPath(), fillTrigPath(), makePathStatusInserters(), and StreamSchedule().

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

returns the collection of pointers to workers

Definition at line 256 of file StreamSchedule.h.

Referenced by clearCounters(), getAllModuleDescriptions(), getTriggerReport(), initializeEarlyDelete(), replaceModule(), and StreamSchedule().

256  {
257  return workerManager_.allWorkers();
258  }
WorkerManager workerManager_
AllWorkers const & allWorkers() const
Definition: WorkerManager.h:75
void edm::StreamSchedule::availablePaths ( std::vector< std::string > &  oLabelsToFill) const

adds to oLabelsToFill the labels for all paths in the process

Definition at line 717 of file StreamSchedule.cc.

References edm::Path::name(), create_public_lumi_plots::transform, and trig_paths_.

717  {
718  oLabelsToFill.reserve(trig_paths_.size());
719  std::transform(trig_paths_.begin(),
720  trig_paths_.end(),
721  std::back_inserter(oLabelsToFill),
722  std::bind(&Path::name, std::placeholders::_1));
723  }
std::string const & name() const
Definition: Path.h:73
void edm::StreamSchedule::beginStream ( )

Definition at line 499 of file StreamSchedule.cc.

References edm::WorkerManager::beginStream(), streamContext_, streamID_, and workerManager_.

499  {
501  }
WorkerManager workerManager_
StreamContext streamContext_
void beginStream(StreamID iID, StreamContext &streamContext)
void edm::StreamSchedule::clearCounters ( )

Clear all the counters in the trigger report.

Definition at line 872 of file StreamSchedule.cc.

References allWorkers(), edm::Path::clearCounters(), edm::Worker::clearCounters(), end_paths_, edm::for_all(), total_events_, total_passed_, and trig_paths_.

872  {
873  using std::placeholders::_1;
875  for_all(trig_paths_, std::bind(&Path::clearCounters, _1));
876  for_all(end_paths_, std::bind(&Path::clearCounters, _1));
877  for_all(allWorkers(), std::bind(&Worker::clearCounters, _1));
878  }
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
void clearCounters()
Definition: Worker.h:206
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
void clearCounters()
Definition: Path.cc:171
StreamContext const& edm::StreamSchedule::context ( ) const
inline

Definition at line 264 of file StreamSchedule.h.

264 { return streamContext_;}
StreamContext streamContext_
void edm::StreamSchedule::enableEndPaths ( bool  active)

Turn end_paths "off" if "active" is false; turn end_paths "on" if "active" is true.

Definition at line 801 of file StreamSchedule.cc.

References endpathsAreActive_.

801  {
802  endpathsAreActive_ = active;
803  }
volatile bool endpathsAreActive_
bool edm::StreamSchedule::endPathsEnabled ( ) const

Return true if end_paths are active, and false if they are inactive.

Definition at line 806 of file StreamSchedule.cc.

References endpathsAreActive_.

806  {
807  return endpathsAreActive_;
808  }
volatile bool endpathsAreActive_
void edm::StreamSchedule::endStream ( )

Definition at line 503 of file StreamSchedule.cc.

References edm::WorkerManager::endStream(), streamContext_, streamID_, and workerManager_.

503  {
505  }
void endStream(StreamID iID, StreamContext &streamContext)
WorkerManager workerManager_
StreamContext streamContext_
void edm::StreamSchedule::fillEndPath ( ParameterSet proc_pset,
ProductRegistry preg,
PreallocationConfiguration const *  prealloc,
std::shared_ptr< ProcessConfiguration const >  processConfiguration,
int  bitpos,
std::string const &  name,
std::vector< std::string > const &  endPathNames 
)
private

Definition at line 479 of file StreamSchedule.cc.

References actionTable(), actReg_, addToAllWorkers(), empty_end_paths_, end_paths_, fillWorkers(), edm::PathContext::kEndPath, and streamContext_.

Referenced by StreamSchedule().

484  {
485  PathWorkers tmpworkers;
486  fillWorkers(proc_pset, preg, prealloc, processConfiguration, name, true, tmpworkers, endPathNames);
487 
488  if (!tmpworkers.empty()) {
489  //EndPaths are not supposed to stop if SkipEvent type exception happens
490  end_paths_.emplace_back(bitpos, name, tmpworkers, TrigResPtr(), actionTable(), actReg_, &streamContext_, nullptr, PathContext::PathType::kEndPath);
491  } else {
492  empty_end_paths_.push_back(bitpos);
493  }
494  for (WorkerInPath const& workerInPath : tmpworkers) {
495  addToAllWorkers(workerInPath.getWorker());
496  }
497  }
std::shared_ptr< HLTGlobalStatus > TrigResPtr
void addToAllWorkers(Worker *w)
ExceptionToActionTable const & actionTable() const
returns the action table
void fillWorkers(ParameterSet &proc_pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, std::string const &name, bool ignoreFilters, PathWorkers &out, std::vector< std::string > const &endPathNames)
std::shared_ptr< ActivityRegistry > actReg_
std::vector< WorkerInPath > PathWorkers
std::vector< int > empty_end_paths_
StreamContext streamContext_
void edm::StreamSchedule::fillTrigPath ( ParameterSet proc_pset,
ProductRegistry preg,
PreallocationConfiguration const *  prealloc,
std::shared_ptr< ProcessConfiguration const >  processConfiguration,
int  bitpos,
std::string const &  name,
TrigResPtr  trptr,
std::vector< std::string > const &  endPathNames 
)
private

Definition at line 459 of file StreamSchedule.cc.

References actionTable(), actReg_, addToAllWorkers(), empty_trig_paths_, fillWorkers(), edm::PathContext::kPath, skippingEvent_, streamContext_, and trig_paths_.

Referenced by StreamSchedule().

464  {
465  PathWorkers tmpworkers;
466  fillWorkers(proc_pset, preg, prealloc, processConfiguration, name, false, tmpworkers, endPathNames);
467 
468  // an empty path will cause an extra bit that is not used
469  if (!tmpworkers.empty()) {
470  trig_paths_.emplace_back(bitpos, name, tmpworkers, trptr, actionTable(), actReg_, &streamContext_, &skippingEvent_, PathContext::PathType::kPath);
471  } else {
472  empty_trig_paths_.push_back(bitpos);
473  }
474  for (WorkerInPath const& workerInPath : tmpworkers) {
475  addToAllWorkers(workerInPath.getWorker());
476  }
477  }
std::vector< int > empty_trig_paths_
void addToAllWorkers(Worker *w)
ExceptionToActionTable const & actionTable() const
returns the action table
void fillWorkers(ParameterSet &proc_pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, std::string const &name, bool ignoreFilters, PathWorkers &out, std::vector< std::string > const &endPathNames)
std::shared_ptr< ActivityRegistry > actReg_
std::vector< WorkerInPath > PathWorkers
StreamContext streamContext_
std::atomic< bool > skippingEvent_
void edm::StreamSchedule::fillWorkers ( ParameterSet proc_pset,
ProductRegistry preg,
PreallocationConfiguration const *  prealloc,
std::shared_ptr< ProcessConfiguration const >  processConfiguration,
std::string const &  name,
bool  ignoreFilters,
PathWorkers out,
std::vector< std::string > const &  endPathNames 
)
private

Definition at line 402 of file StreamSchedule.cc.

References edm::errors::Configuration, edm::Worker::description(), Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getPSetForUpdate(), edm::ParameterSet::getUntrackedParameter(), edm::WorkerManager::getWorker(), edm::WorkerInPath::Ignore, edm::Worker::kFilter, edm::ModuleDescription::moduleName(), edm::Worker::moduleType(), dataset::name, edm::WorkerInPath::Normal, edm::search_all(), AlCaHLTBitMon_QueryRunRegistry::string, edm::WorkerInPath::Veto, and workerManager_.

Referenced by fillEndPath(), and fillTrigPath().

409  {
410  vstring modnames = proc_pset.getParameter<vstring>(pathName);
411  PathWorkers tmpworkers;
412 
413  unsigned int placeInPath = 0;
414  for (auto const& name : modnames) {
415 
417  if (name[0] == '!') filterAction = WorkerInPath::Veto;
418  else if (name[0] == '-') filterAction = WorkerInPath::Ignore;
419 
420  std::string moduleLabel = name;
421  if (filterAction != WorkerInPath::Normal) moduleLabel.erase(0, 1);
422 
423  bool isTracked;
424  ParameterSet* modpset = proc_pset.getPSetForUpdate(moduleLabel, isTracked);
425  if (modpset == nullptr) {
426  std::string pathType("endpath");
427  if (!search_all(endPathNames, pathName)) {
428  pathType = std::string("path");
429  }
431  "The unknown module label \"" << moduleLabel <<
432  "\" appears in " << pathType << " \"" << pathName <<
433  "\"\n please check spelling or remove that label from the path.";
434  }
435  assert(isTracked);
436 
437  Worker* worker = workerManager_.getWorker(*modpset, preg, prealloc, processConfiguration, moduleLabel);
438  if (ignoreFilters && filterAction != WorkerInPath::Ignore && worker->moduleType()==Worker::kFilter) {
439  // We have a filter on an end path, and the filter is not explicitly ignored.
440  // See if the filter is allowed.
441  std::vector<std::string> allowed_filters = proc_pset.getUntrackedParameter<vstring>("@filters_on_endpaths");
442  if (!search_all(allowed_filters, worker->description().moduleName())) {
443  // Filter is not allowed. Ignore the result, and issue a warning.
444  filterAction = WorkerInPath::Ignore;
445  LogWarning("FilterOnEndPath")
446  << "The EDFilter '" << worker->description().moduleName() << "' with module label '" << moduleLabel << "' appears on EndPath '" << pathName << "'.\n"
447  << "The return value of the filter will be ignored.\n"
448  << "To suppress this warning, either remove the filter from the endpath,\n"
449  << "or explicitly ignore it in the configuration by using cms.ignore().\n";
450  }
451  }
452  tmpworkers.emplace_back(worker, filterAction, placeInPath);
453  ++placeInPath;
454  }
455 
456  out.swap(tmpworkers);
457  }
vector< string > vstring
Definition: ExoticaDQM.cc:8
WorkerManager workerManager_
std::vector< WorkerInPath > PathWorkers
bool search_all(ForwardSequence const &s, Datum const &d)
Definition: Algorithms.h:46
Worker * getWorker(ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, std::string const &label)
void edm::StreamSchedule::finishedPaths ( std::exception_ptr  iExcept,
WaitingTaskHolder  iWait,
EventPrincipal ep,
EventSetup const &  es 
)
private

Definition at line 621 of file StreamSchedule.cc.

References mps_fire::action, actionTable(), cms::Exception::addContext(), cms::Exception::category(), cms::Exception::context(), edm::WaitingTaskHolder::doneWaiting(), MillePedeFileConverter_cfg::e, edm::exception_actions::FailPath, edm::ExceptionToActionTable::find(), edm::propagate_const< T >::get(), edm::EventPrincipal::id(), edm::exception_actions::IgnoreCompletely, edm::printCmsExceptionWarning(), results_, results_inserter_, edm::exception_actions::SkipEvent, streamContext_, streamID_, and total_passed_.

Referenced by processOneEventAsync().

622  {
623 
624  if(iExcept) {
625  try {
626  std::rethrow_exception(iExcept);
627  }
628  catch(cms::Exception& e) {
630  assert (action != exception_actions::IgnoreCompletely);
631  assert (action != exception_actions::FailPath);
632  if (action == exception_actions::SkipEvent) {
633  edm::printCmsExceptionWarning("SkipEvent", e);
634  iExcept = std::exception_ptr();
635  } else {
636  iExcept = std::current_exception();
637  }
638  }
639  catch(...) {
640  iExcept = std::current_exception();
641  }
642  }
643 
644 
645  if((not iExcept) and results_->accept()) {
646  ++total_passed_;
647  }
648 
649  if(nullptr != results_inserter_.get()) {
650  try {
651  //Even if there was an exception, we need to allow results inserter
652  // to run since some module may be waiting on its results.
653  ParentContext parentContext(&streamContext_);
654  using Traits = OccurrenceTraits<EventPrincipal, BranchActionStreamBegin>;
655 
656  results_inserter_->doWork<Traits>(ep, es, streamID_, parentContext, &streamContext_);
657  }
658  catch (cms::Exception & ex) {
659  if (not iExcept) {
660  if(ex.context().empty()) {
661  std::ostringstream ost;
662  ost << "Processing Event " << ep.id();
663  ex.addContext(ost.str());
664  }
665  iExcept = std::current_exception();
666  }
667  }
668  catch(...) {
669  if (not iExcept) {
670  iExcept = std::current_exception();
671  }
672  }
673  }
674  iWait.doneWaiting(iExcept);
675  }
std::string const & category() const
Definition: Exception.cc:183
exception_actions::ActionCodes find(const std::string &category) const
edm::propagate_const< WorkerPtr > results_inserter_
ExceptionToActionTable const & actionTable() const
returns the action table
StreamContext streamContext_
std::list< std::string > const & context() const
Definition: Exception.cc:191
element_type const * get() const
edm::propagate_const< TrigResPtr > results_
void addContext(std::string const &context)
Definition: Exception.cc:227
void printCmsExceptionWarning(char const *behavior, cms::Exception const &e)
std::exception_ptr edm::StreamSchedule::finishProcessOneEvent ( std::exception_ptr  iExcept)
private

Definition at line 679 of file StreamSchedule.cc.

References actReg_, edm::addContextAndPrintException(), cms::Exception::context(), edm::ExceptionFromThisContext, resetEarlyDelete(), streamContext_, and edm::convertException::wrap().

Referenced by processOneEventAsync().

679  {
680  using Traits = OccurrenceTraits<EventPrincipal, BranchActionStreamBegin>;
681 
682  if(iExcept) {
683  //add context information to the exception and print message
684  try {
685  convertException::wrap([&]() {
686  std::rethrow_exception(iExcept);
687  });
688  } catch(cms::Exception& ex) {
689  bool const cleaningUpAfterException = false;
690  if (ex.context().empty()) {
691  addContextAndPrintException("Calling function StreamSchedule::processOneEvent", ex, cleaningUpAfterException);
692  } else {
693  addContextAndPrintException("", ex, cleaningUpAfterException);
694  }
695  iExcept = std::current_exception();
696  }
697 
698  actReg_->preStreamEarlyTerminationSignal_(streamContext_,TerminationOrigin::ExceptionFromThisContext);
699  }
700 
701  try {
702  Traits::postScheduleSignal(actReg_.get(), &streamContext_);
703  } catch(...) {
704  if(not iExcept) {
705  iExcept = std::current_exception();
706  }
707  }
708  if(not iExcept ) {
710  }
711 
712  return iExcept;
713  }
void addContextAndPrintException(char const *context, cms::Exception &ex, bool disablePrint)
std::shared_ptr< ActivityRegistry > actReg_
StreamContext streamContext_
std::list< std::string > const & context() const
Definition: Exception.cc:191
auto wrap(F iFunc) -> decltype(iFunc())
std::vector< ModuleDescription const * > edm::StreamSchedule::getAllModuleDescriptions ( ) const

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

Definition at line 525 of file StreamSchedule.cc.

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

525  {
526  std::vector<ModuleDescription const*> result;
527  result.reserve(allWorkers().size());
528 
529  for (auto const& worker : allWorkers()) {
530  ModuleDescription const* p = worker->descPtr();
531  result.push_back(p);
532  }
533  return result;
534  }
size
Write out results.
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
void edm::StreamSchedule::getTriggerReport ( TriggerReport rep) const

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

Definition at line 861 of file StreamSchedule.cc.

References allWorkers(), end_paths_, edm::TriggerReport::endPathSummaries, edm::TriggerReport::eventSummary, edm::fillPathSummary(), edm::fillWorkerSummary(), edm::EventSummary::totalEvents, totalEvents(), edm::EventSummary::totalEventsFailed, totalEventsFailed(), edm::EventSummary::totalEventsPassed, totalEventsPassed(), trig_paths_, edm::TriggerReport::trigPathSummaries, and edm::TriggerReport::workerSummaries.

861  {
862  rep.eventSummary.totalEvents += totalEvents();
863  rep.eventSummary.totalEventsPassed += totalEventsPassed();
864  rep.eventSummary.totalEventsFailed += totalEventsFailed();
865 
866  fill_summary(trig_paths_, rep.trigPathSummaries, &fillPathSummary);
867  fill_summary(end_paths_, rep.endPathSummaries, &fillPathSummary);
868  fill_summary(allWorkers(), rep.workerSummaries, &fillWorkerSummary);
869  }
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
int totalEventsFailed() const
int totalEvents() const
int totalEventsPassed() const
static void fillPathSummary(Path const &path, PathSummary &sum)
rep
Definition: cuy.py:1188
static void fillWorkerSummary(Worker const *pw, WorkerSummary &sum)
void edm::StreamSchedule::initializeEarlyDelete ( ModuleRegistry modReg,
edm::ParameterSet const &  opts,
edm::ProductRegistry const &  preg,
bool  allowEarlyDelete 
)
private

Definition at line 246 of file StreamSchedule.cc.

References allWorkers(), MicroEventContent_cff::branch, edm::BranchDescription::branchName(), edm::maker::ModuleHolder::createOutputModuleCommunicator(), delta, earlyDeleteBranchToCount_, earlyDeleteHelpers_, earlyDeleteHelperToBranchIndicies_, end_paths_, edm::ModuleRegistry::forAllModuleHolders(), runEdmFileComparison::found, edm::pset::Registry::getMapped(), diffTreeTool::index, edm::InEvent, edm::pset::Registry::instance(), checklumidiff::l, gen::n, AlCaHLTBitMon_ParallelJobs::p, muonDTDigis_cfi::pset, resetEarlyDelete(), AlCaHLTBitMon_QueryRunRegistry::string, trig_paths_, mitigatedMETSequence_cff::U, and w.

Referenced by StreamSchedule().

248  {
249  //for now, if have a subProcess, don't allow early delete
250  // In the future we should use the SubProcess's 'keep list' to decide what can be kept
251  if(not allowEarlyDelete) return;
252 
253  //see if 'canDeleteEarly' was set and if so setup the list with those products actually
254  // registered for this job
255  std::multimap<std::string,Worker*> branchToReadingWorker;
256  initializeBranchToReadingWorker(opts,preg,branchToReadingWorker);
257 
258  //If no delete early items have been specified we don't have to do anything
259  if(branchToReadingWorker.empty()) {
260  return;
261  }
262  const std::vector<std::string> kEmpty;
263  std::map<Worker*,unsigned int> reserveSizeForWorker;
264  unsigned int upperLimitOnReadingWorker =0;
265  unsigned int upperLimitOnIndicies = 0;
266  unsigned int nUniqueBranchesToDelete=branchToReadingWorker.size();
267 
268  //talk with output modules first
269  modReg.forAllModuleHolders([&branchToReadingWorker,&nUniqueBranchesToDelete](maker::ModuleHolder* iHolder){
270  auto comm = iHolder->createOutputModuleCommunicator();
271  if (comm) {
272  if(!branchToReadingWorker.empty()) {
273  //If an OutputModule needs a product, we can't delete it early
274  // so we should remove it from our list
275  SelectedProductsForBranchType const& kept = comm->keptProducts();
276  for(auto const& item: kept[InEvent]) {
277  BranchDescription const& desc = *item.first;
278  auto found = branchToReadingWorker.equal_range(desc.branchName());
279  if(found.first !=found.second) {
280  --nUniqueBranchesToDelete;
281  branchToReadingWorker.erase(found.first,found.second);
282  }
283  }
284  }
285  }
286  });
287 
288  if(branchToReadingWorker.empty()) {
289  return;
290  }
291 
292  for (auto w :allWorkers()) {
293  //determine if this module could read a branch we want to delete early
294  auto pset = pset::Registry::instance()->getMapped(w->description().parameterSetID());
295  if(nullptr!=pset) {
296  auto branches = pset->getUntrackedParameter<std::vector<std::string>>("mightGet",kEmpty);
297  if(not branches.empty()) {
298  ++upperLimitOnReadingWorker;
299  }
300  for(auto const& branch:branches){
301  auto found = branchToReadingWorker.equal_range(branch);
302  if(found.first != found.second) {
303  ++upperLimitOnIndicies;
304  ++reserveSizeForWorker[w];
305  if(nullptr == found.first->second) {
306  found.first->second = w;
307  } else {
308  branchToReadingWorker.insert(make_pair(found.first->first,w));
309  }
310  }
311  }
312  }
313  }
314  {
315  auto it = branchToReadingWorker.begin();
316  std::vector<std::string> unusedBranches;
317  while(it !=branchToReadingWorker.end()) {
318  if(it->second == nullptr) {
319  unusedBranches.push_back(it->first);
320  //erasing the object invalidates the iterator so must advance it first
321  auto temp = it;
322  ++it;
323  branchToReadingWorker.erase(temp);
324  } else {
325  ++it;
326  }
327  }
328  if(not unusedBranches.empty()) {
329  LogWarning l("UnusedProductsForCanDeleteEarly");
330  l<<"The following products in the 'canDeleteEarly' list are not used in this job and will be ignored.\n"
331  " If possible, remove the producer from the job or add the product to the producer's own 'mightGet' list.";
332  for(auto const& n:unusedBranches){
333  l<<"\n "<<n;
334  }
335  }
336  }
337  if(!branchToReadingWorker.empty()) {
338  earlyDeleteHelpers_.reserve(upperLimitOnReadingWorker);
339  earlyDeleteHelperToBranchIndicies_.resize(upperLimitOnIndicies,0);
340  earlyDeleteBranchToCount_.reserve(nUniqueBranchesToDelete);
341  std::map<const Worker*,EarlyDeleteHelper*> alreadySeenWorkers;
342  std::string lastBranchName;
343  size_t nextOpenIndex = 0;
344  unsigned int* beginAddress = &(earlyDeleteHelperToBranchIndicies_.front());
345  for(auto& branchAndWorker:branchToReadingWorker) {
346  if(lastBranchName != branchAndWorker.first) {
347  //have to put back the period we removed earlier in order to get the proper name
348  BranchID bid(branchAndWorker.first+".");
349  earlyDeleteBranchToCount_.emplace_back(bid,0U);
350  lastBranchName = branchAndWorker.first;
351  }
352  auto found = alreadySeenWorkers.find(branchAndWorker.second);
353  if(alreadySeenWorkers.end() == found) {
354  //NOTE: we will set aside enough space in earlyDeleteHelperToBranchIndicies_ to accommodate
355  // all the branches that might be read by this worker. However, initially we will only tell the
356  // EarlyDeleteHelper about the first one. As additional branches are added via 'appendIndex' the
357  // EarlyDeleteHelper will automatically advance its internal end pointer.
358  size_t index = nextOpenIndex;
359  size_t nIndices = reserveSizeForWorker[branchAndWorker.second];
361  earlyDeleteHelpers_.emplace_back(beginAddress+index,
362  beginAddress+index+1,
364  branchAndWorker.second->setEarlyDeleteHelper(&(earlyDeleteHelpers_.back()));
365  alreadySeenWorkers.insert(std::make_pair(branchAndWorker.second,&(earlyDeleteHelpers_.back())));
366  nextOpenIndex +=nIndices;
367  } else {
368  found->second->appendIndex(earlyDeleteBranchToCount_.size()-1);
369  }
370  }
371 
372  //Now we can compactify the earlyDeleteHelperToBranchIndicies_ since we may have over estimated the
373  // space needed for each module
374  auto itLast = earlyDeleteHelpers_.begin();
375  for(auto it = earlyDeleteHelpers_.begin()+1;it != earlyDeleteHelpers_.end();++it) {
376  if(itLast->end() != it->begin()) {
377  //figure the offset for next Worker since it hasn't been moved yet so it has the original address
378  unsigned int delta = it->begin()- itLast->end();
379  it->shiftIndexPointers(delta);
380 
382  (itLast->end()-beginAddress),
384  (it->begin()-beginAddress));
385  }
386  itLast = it;
387  }
388  earlyDeleteHelperToBranchIndicies_.erase(earlyDeleteHelperToBranchIndicies_.begin()+(itLast->end()-beginAddress),
390 
391  //now tell the paths about the deleters
392  for(auto& p : trig_paths_) {
393  p.setEarlyDeleteHelpers(alreadySeenWorkers);
394  }
395  for(auto& p : end_paths_) {
396  p.setEarlyDeleteHelpers(alreadySeenWorkers);
397  }
399  }
400  }
dbl * delta
Definition: mlp_gen.cc:36
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
const double w
Definition: UKUtility.cc:23
std::array< SelectedProducts, NumBranchTypes > SelectedProductsForBranchType
std::vector< BranchToCount > earlyDeleteBranchToCount_
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:19
std::vector< unsigned int > earlyDeleteHelperToBranchIndicies_
static Registry * instance()
Definition: Registry.cc:13
std::vector< EarlyDeleteHelper > earlyDeleteHelpers_
void edm::StreamSchedule::makePathStatusInserters ( std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter >>> &  pathStatusInserters,
std::vector< edm::propagate_const< std::shared_ptr< EndPathStatusInserter >>> &  endPathStatusInserters,
ExceptionToActionTable const &  actions 
)
private

Definition at line 907 of file StreamSchedule.cc.

References actions, actReg_, addToAllWorkers(), empty_end_paths_, empty_trig_paths_, end_paths_, endPathStatusInserterWorkers_, edm::get_underlying(), pathStatusInserterWorkers_, and trig_paths_.

Referenced by StreamSchedule().

910  {
911 
912  int bitpos = 0;
913  unsigned int indexEmpty = 0;
914  unsigned int indexOfPath = 0;
915  for(auto & pathStatusInserter : pathStatusInserters) {
916  std::shared_ptr<PathStatusInserter> inserterPtr = get_underlying(pathStatusInserter);
918  inserterPtr->moduleDescription(),
919  &actions));
920  pathStatusInserterWorkers_.emplace_back(workerPtr);
921  workerPtr->setActivityRegistry(actReg_);
922  addToAllWorkers(workerPtr.get());
923 
924  // A little complexity here because a C++ Path object is not
925  // instantiated and put into end_paths if there are no modules
926  // on the configured path.
927  if (indexEmpty < empty_trig_paths_.size() && bitpos == empty_trig_paths_.at(indexEmpty)) {
928  ++indexEmpty;
929  } else {
930  trig_paths_.at(indexOfPath).setPathStatusInserter(inserterPtr.get(),
931  workerPtr.get());
932  ++indexOfPath;
933  }
934  ++bitpos;
935  }
936 
937  bitpos = 0;
938  indexEmpty = 0;
939  indexOfPath = 0;
940  for(auto & endPathStatusInserter : endPathStatusInserters) {
941  std::shared_ptr<EndPathStatusInserter> inserterPtr = get_underlying(endPathStatusInserter);
943  inserterPtr->moduleDescription(),
944  &actions));
945  endPathStatusInserterWorkers_.emplace_back(workerPtr);
946  workerPtr->setActivityRegistry(actReg_);
947  addToAllWorkers(workerPtr.get());
948 
949  // A little complexity here because a C++ Path object is not
950  // instantiated and put into end_paths if there are no modules
951  // on the configured path.
952  if (indexEmpty < empty_end_paths_.size() && bitpos == empty_end_paths_.at(indexEmpty)) {
953  ++indexEmpty;
954  } else {
955  end_paths_.at(indexOfPath).setPathStatusInserter(nullptr,
956  workerPtr.get());
957  ++indexOfPath;
958  }
959  ++bitpos;
960  }
961  }
std::vector< int > empty_trig_paths_
roAction_t actions[nactions]
Definition: GenABIO.cc:187
std::vector< edm::propagate_const< WorkerPtr > > pathStatusInserterWorkers_
void addToAllWorkers(Worker *w)
std::shared_ptr< Worker > WorkerPtr
std::shared_ptr< ActivityRegistry > actReg_
std::vector< int > empty_end_paths_
T & get_underlying(propagate_const< T > &)
std::vector< edm::propagate_const< WorkerPtr > > endPathStatusInserterWorkers_
void edm::StreamSchedule::moduleDescriptionsInEndPath ( std::string const &  iEndPathLabel,
std::vector< ModuleDescription const * > &  descriptions,
unsigned int  hint 
) const

Definition at line 772 of file StreamSchedule.cc.

References end_paths_, runEdmFileComparison::found, mps_fire::i, and edm::Path::name().

774  {
775  descriptions.clear();
776  bool found = false;
777  TrigPaths::const_iterator itFound;
778 
779  if(hint < end_paths_.size()) {
780  itFound = end_paths_.begin() + hint;
781  if(itFound->name() == iEndPathLabel) found = true;
782  }
783  if(!found) {
784  // if the hint did not work, do it the slow way
785  itFound = std::find_if (end_paths_.begin(),
786  end_paths_.end(),
787  std::bind(std::equal_to<std::string>(),
788  iEndPathLabel,
789  std::bind(&Path::name, std::placeholders::_1)));
790  if (itFound != end_paths_.end()) found = true;
791  }
792  if (found) {
793  descriptions.reserve(itFound->size());
794  for (size_t i = 0; i < itFound->size(); ++i) {
795  descriptions.push_back(itFound->getWorker(i)->descPtr());
796  }
797  }
798  }
std::string const & name() const
Definition: Path.h:73
void edm::StreamSchedule::moduleDescriptionsInPath ( std::string const &  iPathLabel,
std::vector< ModuleDescription const * > &  descriptions,
unsigned int  hint 
) const

Definition at line 743 of file StreamSchedule.cc.

References runEdmFileComparison::found, mps_fire::i, edm::Path::name(), and trig_paths_.

745  {
746  descriptions.clear();
747  bool found = false;
748  TrigPaths::const_iterator itFound;
749 
750  if(hint < trig_paths_.size()) {
751  itFound = trig_paths_.begin() + hint;
752  if(itFound->name() == iPathLabel) found = true;
753  }
754  if(!found) {
755  // if the hint did not work, do it the slow way
756  itFound = std::find_if (trig_paths_.begin(),
757  trig_paths_.end(),
758  std::bind(std::equal_to<std::string>(),
759  iPathLabel,
760  std::bind(&Path::name, std::placeholders::_1)));
761  if (itFound != trig_paths_.end()) found = true;
762  }
763  if (found) {
764  descriptions.reserve(itFound->size());
765  for (size_t i = 0; i < itFound->size(); ++i) {
766  descriptions.push_back(itFound->getWorker(i)->descPtr());
767  }
768  }
769  }
std::string const & name() const
Definition: Path.h:73
void edm::StreamSchedule::modulesInPath ( std::string const &  iPathLabel,
std::vector< std::string > &  oLabelsToFill 
) const

adds to oLabelsToFill in execution order the labels of all modules in path iPathLabel

Definition at line 726 of file StreamSchedule.cc.

References mps_fire::i, edm::Path::name(), and trig_paths_.

727  {
728  TrigPaths::const_iterator itFound =
729  std::find_if (trig_paths_.begin(),
730  trig_paths_.end(),
731  std::bind(std::equal_to<std::string>(),
732  iPathLabel,
733  std::bind(&Path::name, std::placeholders::_1)));
734  if (itFound!=trig_paths_.end()) {
735  oLabelsToFill.reserve(itFound->size());
736  for (size_t i = 0; i < itFound->size(); ++i) {
737  oLabelsToFill.push_back(itFound->getWorker(i)->description().moduleLabel());
738  }
739  }
740  }
std::string const & name() const
Definition: Path.h:73
unsigned int edm::StreamSchedule::numberOfUnscheduledModules ( ) const
inline

Definition at line 260 of file StreamSchedule.h.

260  {
262  }
unsigned int number_of_unscheduled_modules_
void edm::StreamSchedule::processOneEventAsync ( WaitingTaskHolder  iTask,
EventPrincipal ep,
EventSetup const &  es,
std::vector< edm::propagate_const< std::shared_ptr< PathStatusInserter >>> &  pathStatusInserters 
)

Definition at line 536 of file StreamSchedule.cc.

References actReg_, edm::WaitingTaskHolder::doneWaiting(), empty_end_paths_, empty_trig_paths_, end_paths_, endPathStatusInserterWorkers_, finishedPaths(), finishProcessOneEvent(), edm::ServiceRegistry::instance(), edm::make_waiting_task(), eostools::move(), cmsPerfStripChart::operate(), edm::hlt::Pass, pathStatusInserterWorkers_, edm::ServiceRegistry::presentToken(), resetAll(), results_, edm::WorkerManager::setupOnDemandSystem(), streamContext_, streamID_, total_events_, trig_paths_, and workerManager_.

539  {
540  this->resetAll();
541 
542  using Traits = OccurrenceTraits<EventPrincipal, BranchActionStreamBegin>;
543 
544  Traits::setStreamContext(streamContext_, ep);
545  Traits::preScheduleSignal(actReg_.get(), &streamContext_);
546 
547  HLTPathStatus hltPathStatus(hlt::Pass, 0);
548  for (int empty_trig_path : empty_trig_paths_) {
549  results_->at(empty_trig_path) = hltPathStatus;
550  pathStatusInserters[empty_trig_path]->setPathStatus(streamID_, hltPathStatus);
551  std::exception_ptr iException = pathStatusInserterWorkers_[empty_trig_path]->runModuleDirectly<OccurrenceTraits<EventPrincipal, BranchActionStreamBegin>>(
552  ep, es, streamID_, ParentContext(&streamContext_), &streamContext_
553  );
554  if (iException) {
555  iTask.doneWaiting(iException);
556  return;
557  }
558  }
559  for (int empty_end_path : empty_end_paths_) {
560  std::exception_ptr iException = endPathStatusInserterWorkers_[empty_end_path]->runModuleDirectly<OccurrenceTraits<EventPrincipal, BranchActionStreamBegin>>(
561  ep, es, streamID_, ParentContext(&streamContext_), &streamContext_
562  );
563  if (iException) {
564  iTask.doneWaiting(iException);
565  return;
566  }
567  }
568 
569  // This call takes care of the unscheduled processing.
571 
572  ++total_events_;
573  auto serviceToken = ServiceRegistry::instance().presentToken();
574 
575  auto allPathsDone = make_waiting_task(tbb::task::allocate_root(),
576  [iTask,this,serviceToken](std::exception_ptr const* iPtr) mutable
577  {
578  ServiceRegistry::Operate operate(serviceToken);
579 
580  std::exception_ptr ptr;
581  if(iPtr) {
582  ptr = *iPtr;
583  }
584  iTask.doneWaiting(finishProcessOneEvent(ptr));
585  });
586  //The holder guarantees that if the paths finish before the loop ends
587  // that we do not start too soon. It also guarantees that the task will
588  // run under that condition.
589  WaitingTaskHolder allPathsHolder(allPathsDone);
590 
591  auto pathsDone = make_waiting_task(tbb::task::allocate_root(),
592  [allPathsHolder,&ep, &es, this,serviceToken](std::exception_ptr const* iPtr) mutable
593  {
594  ServiceRegistry::Operate operate(serviceToken);
595 
596  std::exception_ptr ptr;
597  if(iPtr) {
598  ptr = *iPtr;
599  }
600  finishedPaths(ptr, std::move(allPathsHolder), ep, es);
601  });
602 
603  //The holder guarantees that if the paths finish before the loop ends
604  // that we do not start too soon. It also guarantees that the task will
605  // run under that condition.
606  WaitingTaskHolder taskHolder(pathsDone);
607 
608  //start end paths first so on single threaded the paths will run first
609  for(auto it = end_paths_.rbegin(), itEnd = end_paths_.rend();
610  it != itEnd; ++it) {
611  it->processOneOccurrenceAsync(allPathsDone,ep, es, streamID_, &streamContext_);
612  }
613 
614  for(auto it = trig_paths_.rbegin(), itEnd = trig_paths_.rend();
615  it != itEnd; ++ it) {
616  it->processOneOccurrenceAsync(pathsDone,ep, es, streamID_, &streamContext_);
617  }
618  }
std::vector< int > empty_trig_paths_
std::vector< edm::propagate_const< WorkerPtr > > pathStatusInserterWorkers_
ServiceToken presentToken() const
WorkerManager workerManager_
std::shared_ptr< ActivityRegistry > actReg_
std::vector< int > empty_end_paths_
accept
Definition: HLTenums.h:19
StreamContext streamContext_
static ServiceRegistry & instance()
std::exception_ptr finishProcessOneEvent(std::exception_ptr)
edm::propagate_const< TrigResPtr > results_
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
Definition: WaitingTask.h:92
std::vector< edm::propagate_const< WorkerPtr > > endPathStatusInserterWorkers_
void finishedPaths(std::exception_ptr, WaitingTaskHolder, EventPrincipal &ep, EventSetup const &es)
void setupOnDemandSystem(Principal &principal, EventSetup const &es)
def move(src, dest)
Definition: eostools.py:510
def operate(timelog, memlog, json_f, num)
template<typename T >
void edm::StreamSchedule::processOneStreamAsync ( WaitingTaskHolder  iTask,
typename T::MyPrincipal &  principal,
EventSetup const &  eventSetup,
bool  cleaningUpAfterException = false 
)

Definition at line 384 of file StreamSchedule.h.

References edm::addContextAndPrintException(), cms::Exception::context(), edm::WaitingTaskHolder::doneWaiting(), edm::ExceptionFromThisContext, h, triggerObjects_cff::id, edm::ServiceRegistry::instance(), edm::make_functor_task(), edm::make_waiting_task(), AlCaHLTBitMon_ParallelJobs::p, edm::ServiceRegistry::presentToken(), and edm::convertException::wrap().

387  {
389 
390  T::setStreamContext(streamContext_, ep);
391 
392  auto id = ep.id();
393  auto doneTask = make_waiting_task(tbb::task::allocate_root(),
394  [this,iHolder, id,cleaningUpAfterException,token](std::exception_ptr const* iPtr) mutable
395  {
396  ServiceRegistry::Operate op(token);
397  std::exception_ptr excpt;
398  if(iPtr) {
399  excpt = *iPtr;
400  //add context information to the exception and print message
401  try {
402  convertException::wrap([&]() {
403  std::rethrow_exception(excpt);
404  });
405  } catch(cms::Exception& ex) {
406  //TODO: should add the transition type info
407  std::ostringstream ost;
408  if(ex.context().empty()) {
409  ost<<"Processing "<<T::transitionName()<<" "<<id;
410  }
411  addContextAndPrintException(ost.str().c_str(), ex, cleaningUpAfterException);
412  excpt = std::current_exception();
413  }
414 
415  actReg_->preStreamEarlyTerminationSignal_(streamContext_,TerminationOrigin::ExceptionFromThisContext);
416  }
417 
418  try {
419  T::postScheduleSignal(actReg_.get(), &streamContext_);
420  } catch(...) {
421  if(not excpt) {
422  excpt = std::current_exception();
423  }
424  }
425  iHolder.doneWaiting(excpt);
426 
427  });
428 
429  auto task = make_functor_task(tbb::task::allocate_root(), [this,doneTask,&ep,&es,token] () mutable {
430  ServiceRegistry::Operate op(token);
431  T::preScheduleSignal(actReg_.get(), &streamContext_);
432  WaitingTaskHolder h(doneTask);
433 
435  for(auto& p : end_paths_) {
436  p.runAllModulesAsync<T>(doneTask, ep, es, streamID_, &streamContext_);
437  }
438 
439  for(auto& p : trig_paths_) {
440  p.runAllModulesAsync<T>(doneTask, ep, es, streamID_, &streamContext_);
441  }
442 
445  });
446 
447  if(streamID_.value() == 0) {
448  //Enqueueing will start another thread if there is only
449  // one thread in the job. Having stream == 0 use spawn
450  // avoids starting up another thread when there is only one stream.
451  tbb::task::spawn( *task);
452  } else {
453  tbb::task::enqueue( *task);
454  }
455  }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
FunctorTask< F > * make_functor_task(ALLOC &&iAlloc, F f)
Definition: FunctorTask.h:47
void addContextAndPrintException(char const *context, cms::Exception &ex, bool disablePrint)
ServiceToken presentToken() const
WorkerManager workerManager_
std::shared_ptr< ActivityRegistry > actReg_
void processOneOccurrenceAsync(WaitingTask *task, typename T::MyPrincipal &principal, EventSetup const &eventSetup, StreamID streamID, typename T::Context const *topContext, U const *context)
StreamContext streamContext_
std::list< std::string > const & context() const
Definition: Exception.cc:191
static ServiceRegistry & instance()
unsigned int value() const
Definition: StreamID.h:46
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
Definition: WaitingTask.h:92
auto wrap(F iFunc) -> decltype(iFunc())
long double T
void edm::StreamSchedule::replaceModule ( maker::ModuleHolder iMod,
std::string const &  iLabel 
)

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

Definition at line 507 of file StreamSchedule.cc.

References allWorkers(), edm::Worker::beginStream(), runEdmFileComparison::found, edm::maker::ModuleHolder::replaceModuleFor(), streamContext_, and streamID_.

508  {
509  Worker* found = nullptr;
510  for (auto const& worker : allWorkers()) {
511  if (worker->description().moduleLabel() == iLabel) {
512  found = worker;
513  break;
514  }
515  }
516  if (nullptr == found) {
517  return;
518  }
519 
520  iMod->replaceModuleFor(found);
521  found->beginStream(streamID_,streamContext_);
522  }
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
StreamContext streamContext_
void edm::StreamSchedule::reportSkipped ( EventPrincipal const &  ep) const
inlineprivate

Definition at line 378 of file StreamSchedule.h.

References edm::EventID::event(), edm::EventPrincipal::id(), and edm::EventID::run().

378  {
379  Service<JobReport> reportSvc;
380  reportSvc->reportSkippedEvent(ep.id().run(), ep.id().event());
381  }
void edm::StreamSchedule::resetAll ( )
private

Definition at line 881 of file StreamSchedule.cc.

References results_, and skippingEvent_.

Referenced by processOneEventAsync().

881  {
882  skippingEvent_ = false;
883  results_->reset();
884  }
edm::propagate_const< TrigResPtr > results_
std::atomic< bool > skippingEvent_
void edm::StreamSchedule::resetEarlyDelete ( )
private

Definition at line 892 of file StreamSchedule.cc.

References KineDebug3::count(), earlyDeleteBranchToCount_, earlyDeleteHelpers_, earlyDeleteHelperToBranchIndicies_, and diffTreeTool::index.

Referenced by finishProcessOneEvent(), and initializeEarlyDelete().

892  {
893  //must be sure we have cleared the count first
894  for(auto& count:earlyDeleteBranchToCount_) {
895  count.count = 0;
896  }
897  //now reset based on how many helpers use that branch
899  ++(earlyDeleteBranchToCount_[index].count);
900  }
901  for(auto& helper: earlyDeleteHelpers_) {
902  helper.reset();
903  }
904  }
Definition: helper.py:1
std::vector< BranchToCount > earlyDeleteBranchToCount_
std::vector< unsigned int > earlyDeleteHelperToBranchIndicies_
std::vector< EarlyDeleteHelper > earlyDeleteHelpers_
TrigResConstPtr edm::StreamSchedule::results ( ) const
inlineprivate

Definition at line 329 of file StreamSchedule.h.

References edm::get_underlying_safe().

Referenced by StreamSchedule().

329 {return get_underlying_safe(results_);}
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< TrigResPtr > results_
TrigResPtr& edm::StreamSchedule::results ( )
inlineprivate

Definition at line 330 of file StreamSchedule.h.

References actions, and edm::get_underlying_safe().

330 {return get_underlying_safe(results_);}
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< TrigResPtr > results_
StreamID edm::StreamSchedule::streamID ( ) const
inline

Definition at line 193 of file StreamSchedule.h.

References AlCaHLTBitMon_QueryRunRegistry::string.

193 { return streamID_; }
int edm::StreamSchedule::totalEvents ( ) const
inline

Return the number of events this StreamSchedule has tried to process (inclues both successes and failures, including failures due to exceptions during processing).

Definition at line 221 of file StreamSchedule.h.

Referenced by getTriggerReport().

221  {
222  return total_events_;
223  }
int edm::StreamSchedule::totalEventsFailed ( ) const
inline

Return the number of events that have not passed any trigger. (N.B. totalEventsFailed() + totalEventsPassed() == totalEvents()

Definition at line 233 of file StreamSchedule.h.

References cuy::rep, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getTriggerReport().

233  {
234  return totalEvents() - totalEventsPassed();
235  }
int totalEvents() const
int totalEventsPassed() const
int edm::StreamSchedule::totalEventsPassed ( ) const
inline

Return the number of events which have been passed by one or more trigger paths.

Definition at line 227 of file StreamSchedule.h.

Referenced by getTriggerReport().

227  {
228  return total_passed_;
229  }

Member Data Documentation

std::shared_ptr<ActivityRegistry> edm::StreamSchedule::actReg_
private
std::vector<BranchToCount> edm::StreamSchedule::earlyDeleteBranchToCount_
private

Definition at line 354 of file StreamSchedule.h.

Referenced by initializeEarlyDelete(), and resetEarlyDelete().

std::vector<EarlyDeleteHelper> edm::StreamSchedule::earlyDeleteHelpers_
private

Definition at line 364 of file StreamSchedule.h.

Referenced by initializeEarlyDelete(), and resetEarlyDelete().

std::vector<unsigned int> edm::StreamSchedule::earlyDeleteHelperToBranchIndicies_
private

Definition at line 361 of file StreamSchedule.h.

Referenced by initializeEarlyDelete(), and resetEarlyDelete().

std::vector<int> edm::StreamSchedule::empty_end_paths_
private

Definition at line 349 of file StreamSchedule.h.

Referenced by fillEndPath(), makePathStatusInserters(), and processOneEventAsync().

std::vector<int> edm::StreamSchedule::empty_trig_paths_
private

Definition at line 348 of file StreamSchedule.h.

Referenced by fillTrigPath(), makePathStatusInserters(), and processOneEventAsync().

TrigPaths edm::StreamSchedule::end_paths_
private
volatile bool edm::StreamSchedule::endpathsAreActive_
private

Definition at line 372 of file StreamSchedule.h.

Referenced by enableEndPaths(), and endPathsEnabled().

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

Definition at line 344 of file StreamSchedule.h.

Referenced by makePathStatusInserters(), and processOneEventAsync().

unsigned int edm::StreamSchedule::number_of_unscheduled_modules_
private

Definition at line 368 of file StreamSchedule.h.

Referenced by StreamSchedule().

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

Definition at line 343 of file StreamSchedule.h.

Referenced by makePathStatusInserters(), and processOneEventAsync().

edm::propagate_const<TrigResPtr> edm::StreamSchedule::results_
private

Definition at line 340 of file StreamSchedule.h.

Referenced by finishedPaths(), processOneEventAsync(), and resetAll().

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

Definition at line 342 of file StreamSchedule.h.

Referenced by finishedPaths(), and StreamSchedule().

std::atomic<bool> edm::StreamSchedule::skippingEvent_
private

Definition at line 373 of file StreamSchedule.h.

Referenced by fillTrigPath(), and resetAll().

StreamContext edm::StreamSchedule::streamContext_
private
StreamID edm::StreamSchedule::streamID_
private
int edm::StreamSchedule::total_events_
private

Definition at line 366 of file StreamSchedule.h.

Referenced by clearCounters(), and processOneEventAsync().

int edm::StreamSchedule::total_passed_
private

Definition at line 367 of file StreamSchedule.h.

Referenced by clearCounters(), and finishedPaths().

TrigPaths edm::StreamSchedule::trig_paths_
private
WorkerManager edm::StreamSchedule::workerManager_
private