CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
edm::Path Class Reference

#include <Path.h>

Public Types

typedef WorkersInPath::size_type size_type
 
typedef hlt::HLTState State
 
typedef std::shared_ptr< HLTGlobalStatusTrigResPtr
 
typedef std::vector< WorkerInPathWorkersInPath
 

Public Member Functions

int bitPosition () const
 
unsigned int bitPosition (size_type i) const
 
void clearCounters ()
 
Worker const * getWorker (size_type i) const
 
std::string const & name () const
 
Pathoperator= (Path const &)=delete
 
 Path (int bitpos, std::string const &path_name, WorkersInPath const &workers, TrigResPtr trptr, ExceptionToActionTable const &actions, std::shared_ptr< ActivityRegistry > reg, StreamContext const *streamContext, PathContext::PathType pathType)
 
 Path (Path const &)
 
void processOneOccurrenceAsync (WaitingTaskHolder, EventTransitionInfo const &, ServiceToken const &, StreamID const &, StreamContext const *)
 
template<typename T >
void runAllModulesAsync (WaitingTaskHolder, typename T::TransitionInfoType const &, ServiceToken const &, StreamID const &, typename T::Context const *)
 
void setEarlyDeleteHelpers (std::map< const Worker *, EarlyDeleteHelper *> const &)
 
void setPathStatusInserter (PathStatusInserter *pathStatusInserter, Worker *pathStatusInserterWorker)
 
size_type size () const
 
int timesExcept () const
 
int timesExcept (size_type i) const
 
int timesFailed () const
 
int timesFailed (size_type i) const
 
int timesPassed () const
 
int timesPassed (size_type i) const
 
int timesRun () const
 
int timesVisited (size_type i) const
 

Private Member Functions

void finished (std::exception_ptr, StreamContext const *, EventTransitionInfo const &, StreamID const &)
 
void handleWorkerFailure (cms::Exception &e, int nwrwue, ModuleDescription const &, std::string const &id)
 
void recordStatus (int nwrwue, hlt::HLTState state)
 
void runNextWorkerAsync (unsigned int iNextModuleIndex, EventTransitionInfo const &, ServiceToken const &, StreamID const &, StreamContext const *, oneapi::tbb::task_group &iGroup)
 
void threadsafe_setFailedModuleInfo (int nwrwue, bool iExceptionHappened)
 
void updateCounters (hlt::HLTState state)
 
void workerFinished (std::exception_ptr const *, unsigned int iModuleIndex, EventTransitionInfo const &, ServiceToken const &, StreamID const &, StreamContext const *, oneapi::tbb::task_group &iGroup)
 

Static Private Member Functions

static void exceptionContext (cms::Exception &ex, bool isEvent, bool begin, BranchType branchType, ModuleDescription const &, std::string const &id, PathContext const &)
 

Private Attributes

ExceptionToActionTable const *const act_table_
 
std::shared_ptr< ActivityRegistry > const actReg_
 
int const bitpos_
 
int failedModuleIndex_
 
std::atomic< unsigned int > modulesToRun_
 
PathContext pathContext_
 
PathStatusInserterpathStatusInserter_
 
WorkerpathStatusInserterWorker_
 
std::atomic< bool > printedException_ = false
 
State state_
 
std::atomic< bool > stateLock_ = false
 
int timesExcept_
 
int timesFailed_
 
int timesPassed_
 
int timesRun_
 
TrigResPtr const trptr_
 
WaitingTaskList waitingTasks_
 
WorkersInPath workers_
 

Detailed Description

Definition at line 41 of file Path.h.

Member Typedef Documentation

◆ size_type

typedef WorkersInPath::size_type edm::Path::size_type

Definition at line 46 of file Path.h.

◆ State

Definition at line 43 of file Path.h.

◆ TrigResPtr

typedef std::shared_ptr<HLTGlobalStatus> edm::Path::TrigResPtr

Definition at line 47 of file Path.h.

◆ WorkersInPath

typedef std::vector<WorkerInPath> edm::Path::WorkersInPath

Definition at line 45 of file Path.h.

Constructor & Destructor Documentation

◆ Path() [1/2]

edm::Path::Path ( int  bitpos,
std::string const &  path_name,
WorkersInPath const &  workers,
TrigResPtr  trptr,
ExceptionToActionTable const &  actions,
std::shared_ptr< ActivityRegistry reg,
StreamContext const *  streamContext,
PathContext::PathType  pathType 
)

Definition at line 19 of file Path.cc.

References modulesToRun_, pathContext_, and workers_.

27  : timesRun_(),
28  timesPassed_(),
29  timesFailed_(),
30  timesExcept_(),
33  bitpos_(bitpos),
34  trptr_(trptr),
35  actReg_(areg),
38  pathContext_(path_name, streamContext, bitpos, pathType),
39  pathStatusInserter_(nullptr),
40  pathStatusInserterWorker_(nullptr) {
41  for (auto& workerInPath : workers_) {
42  workerInPath.setPathContext(&pathContext_);
43  }
44  modulesToRun_ = workers_.size();
45  }
TrigResPtr const trptr_
Definition: Path.h:109
std::atomic< unsigned int > modulesToRun_
Definition: Path.h:118
not [yet] run
Definition: HLTenums.h:17
roAction_t actions[nactions]
Definition: GenABIO.cc:181
int timesFailed_
Definition: Path.h:98
int timesExcept_
Definition: Path.h:99
PathContext pathContext_
Definition: Path.h:116
int const bitpos_
Definition: Path.h:108
ExceptionToActionTable const *const act_table_
Definition: Path.h:112
WorkersInPath workers_
Definition: Path.h:114
int failedModuleIndex_
Definition: Path.h:105
std::shared_ptr< ActivityRegistry > const actReg_
Definition: Path.h:111
State state_
Definition: Path.h:106
int timesPassed_
Definition: Path.h:97
int timesRun_
Definition: Path.h:96
Worker * pathStatusInserterWorker_
Definition: Path.h:121
PathStatusInserter * pathStatusInserter_
Definition: Path.h:120

◆ Path() [2/2]

edm::Path::Path ( Path const &  r)

Definition at line 47 of file Path.cc.

References modulesToRun_, pathContext_, and workers_.

48  : timesRun_(r.timesRun_),
49  timesPassed_(r.timesPassed_),
50  timesFailed_(r.timesFailed_),
51  timesExcept_(r.timesExcept_),
52  failedModuleIndex_(r.failedModuleIndex_),
53  state_(r.state_),
54  bitpos_(r.bitpos_),
55  trptr_(r.trptr_),
56  actReg_(r.actReg_),
57  act_table_(r.act_table_),
58  workers_(r.workers_),
59  pathContext_(r.pathContext_),
60  pathStatusInserter_(r.pathStatusInserter_),
61  pathStatusInserterWorker_(r.pathStatusInserterWorker_) {
62  for (auto& workerInPath : workers_) {
63  workerInPath.setPathContext(&pathContext_);
64  }
65  modulesToRun_ = workers_.size();
66  }
TrigResPtr const trptr_
Definition: Path.h:109
std::atomic< unsigned int > modulesToRun_
Definition: Path.h:118
int timesFailed_
Definition: Path.h:98
int timesExcept_
Definition: Path.h:99
PathContext pathContext_
Definition: Path.h:116
int const bitpos_
Definition: Path.h:108
ExceptionToActionTable const *const act_table_
Definition: Path.h:112
WorkersInPath workers_
Definition: Path.h:114
int failedModuleIndex_
Definition: Path.h:105
std::shared_ptr< ActivityRegistry > const actReg_
Definition: Path.h:111
State state_
Definition: Path.h:106
int timesPassed_
Definition: Path.h:97
int timesRun_
Definition: Path.h:96
Worker * pathStatusInserterWorker_
Definition: Path.h:121
PathStatusInserter * pathStatusInserter_
Definition: Path.h:120

Member Function Documentation

◆ bitPosition() [1/2]

int edm::Path::bitPosition ( ) const
inline

Definition at line 72 of file Path.h.

References bitpos_.

Referenced by finished().

72 { return bitpos_; }
int const bitpos_
Definition: Path.h:108

◆ bitPosition() [2/2]

unsigned int edm::Path::bitPosition ( size_type  i) const
inline

Definition at line 89 of file Path.h.

References mps_fire::i, and workers_.

89 { return workers_.at(i).bitPosition(); }
WorkersInPath workers_
Definition: Path.h:114

◆ clearCounters()

void edm::Path::clearCounters ( )

Definition at line 183 of file Path.cc.

References edm::WorkerInPath::clearCounters(), edm::for_all(), timesExcept_, timesFailed_, timesPassed_, timesRun_, and workers_.

Referenced by edm::StreamSchedule::clearCounters().

183  {
184  using std::placeholders::_1;
186  for_all(workers_, std::bind(&WorkerInPath::clearCounters, _1));
187  }
int timesFailed_
Definition: Path.h:98
int timesExcept_
Definition: Path.h:99
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
WorkersInPath workers_
Definition: Path.h:114
int timesPassed_
Definition: Path.h:97
int timesRun_
Definition: Path.h:96

◆ exceptionContext()

void edm::Path::exceptionContext ( cms::Exception ex,
bool  isEvent,
bool  begin,
BranchType  branchType,
ModuleDescription const &  desc,
std::string const &  id,
PathContext const &  pathContext 
)
staticprivate

Definition at line 104 of file Path.cc.

References cms::Exception::addContext(), l1ctLayer2EG_cff::id, edm::InLumi, edm::InRun, and edm::PathContext::pathName().

Referenced by handleWorkerFailure().

110  {
111  std::ostringstream ost;
112  ost << "Running path '" << pathContext.pathName() << "'";
113  ex.addContext(ost.str());
114  ost.str("");
115  ost << "Processing ";
116  //For the event case, the Worker has already
117  // added the necessary module context to the exception
118  if (begin && branchType == InRun) {
119  ost << "stream begin Run";
120  } else if (begin && branchType == InLumi) {
121  ost << "stream begin LuminosityBlock ";
122  } else if (!begin && branchType == InLumi) {
123  ost << "stream end LuminosityBlock ";
124  } else if (!begin && branchType == InRun) {
125  ost << "stream end Run ";
126  } else if (isEvent) {
127  // It should be impossible to get here ...
128  ost << "Event ";
129  }
130  ost << id;
131  ex.addContext(ost.str());
132  }
void addContext(std::string const &context)
Definition: Exception.cc:169

◆ finished()

void edm::Path::finished ( std::exception_ptr  iException,
StreamContext const *  iContext,
EventTransitionInfo const &  iInfo,
StreamID const &  streamID 
)
private

Definition at line 300 of file Path.cc.

References actReg_, bitPosition(), CMS_SA_ALLOW, edm::WaitingTaskList::doneWaiting(), failedModuleIndex_, pathContext_, pathStatusInserter_, pathStatusInserterWorker_, recordStatus(), edm::Worker::runModuleDirectly(), edm::PathStatusInserter::setPathStatus(), state_, mps_update::status, updateCounters(), and waitingTasks_.

Referenced by processOneOccurrenceAsync(), and workerFinished().

303  {
305  auto failedModuleBitPosition = bitPosition(failedModuleIndex_);
306  recordStatus(failedModuleBitPosition, state_);
307  // Caught exception is propagated via WaitingTaskList
308  CMS_SA_ALLOW try {
309  HLTPathStatus status(state_, failedModuleBitPosition);
310 
311  if (pathStatusInserter_) { // pathStatusInserter is null for EndPaths
313  }
315  std::exception_ptr jException =
316  pathStatusInserterWorker_->runModuleDirectly<OccurrenceTraits<EventPrincipal, BranchActionStreamBegin>>(
317  iInfo, streamID, ParentContext(iContext), iContext);
318  if (jException && not iException) {
319  iException = jException;
320  }
321  }
322  actReg_->postPathEventSignal_(*iContext, pathContext_, status);
323  } catch (...) {
324  if (not iException) {
325  iException = std::current_exception();
326  }
327  }
328  waitingTasks_.doneWaiting(iException);
329  }
std::exception_ptr runModuleDirectly(typename T::TransitionInfoType const &, StreamID, ParentContext const &, typename T::Context const *)
Definition: Worker.h:1195
#define CMS_SA_ALLOW
void recordStatus(int nwrwue, hlt::HLTState state)
Definition: Path.cc:160
void setPathStatus(StreamID const &, HLTPathStatus const &)
PathContext pathContext_
Definition: Path.h:116
WaitingTaskList waitingTasks_
Definition: Path.h:117
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
void updateCounters(hlt::HLTState state)
Definition: Path.cc:166
int failedModuleIndex_
Definition: Path.h:105
std::shared_ptr< ActivityRegistry > const actReg_
Definition: Path.h:111
State state_
Definition: Path.h:106
int bitPosition() const
Definition: Path.h:72
Worker * pathStatusInserterWorker_
Definition: Path.h:121
PathStatusInserter * pathStatusInserter_
Definition: Path.h:120

◆ getWorker()

Worker const* edm::Path::getWorker ( size_type  i) const
inline

Definition at line 88 of file Path.h.

References mps_fire::i, and workers_.

Referenced by setEarlyDeleteHelpers().

88 { return workers_.at(i).getWorker(); }
WorkersInPath workers_
Definition: Path.h:114

◆ handleWorkerFailure()

void edm::Path::handleWorkerFailure ( cms::Exception e,
int  nwrwue,
ModuleDescription const &  desc,
std::string const &  id 
)
private

Definition at line 68 of file Path.cc.

References act_table_, writedatasetfile::action, edm::Exception::codeToString(), submitPVResolutionJobs::desc, MillePedeFileConverter_cfg::e, exceptionContext(), edm::ExceptionToActionTable::find(), edm::InEvent, name(), pathContext_, edm::printCmsExceptionWarning(), printedException_, edm::errors::ProductNotFound, edm::exception_actions::Rethrow, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, and edm::exception_actions::TryToContinue.

Referenced by workerFinished().

68  {
69  if (e.context().empty()) {
70  exceptionContext(e, true /*isEvent*/, true /*begin*/, InEvent /*branchType*/, desc, id, pathContext_);
71  }
72  // there is no support as of yet for specific paths having
73  // different exception behavior
74 
75  // If not processing an event, always rethrow.
77  switch (action) {
79  bool expected = false;
80  if (printedException_.compare_exchange_strong(expected, true)) {
81  std::ostringstream s;
82  s << "Path " << name() << " applying TryToContinue on";
83  edm::printCmsExceptionWarning(s.str().c_str(), e);
84  }
85  break;
86  }
87  default: {
90  if (e.category() == pNF) {
91  std::ostringstream ost;
92  ost << "If you wish to continue processing events after a " << pNF << " exception,\n"
93  << "add \"TryToContinue = cms.untracked.vstring('ProductNotFound')\" to the \"options\" PSet in the "
94  "configuration.\n";
95  e.addAdditionalInfo(ost.str());
96  }
97  }
98  //throw will copy which will slice the object
99  e.raise();
100  }
101  }
102  }
static const std::string & codeToString(Code)
-----------— implementation details ---------------—
Definition: EDMException.cc:55
PathContext pathContext_
Definition: Path.h:116
ExceptionToActionTable const *const act_table_
Definition: Path.h:112
static void exceptionContext(cms::Exception &ex, bool isEvent, bool begin, BranchType branchType, ModuleDescription const &, std::string const &id, PathContext const &)
Definition: Path.cc:104
exception_actions::ActionCodes find(const std::string &category) const
std::atomic< bool > printedException_
Definition: Path.h:101
std::string const & name() const
Definition: Path.h:73
void printCmsExceptionWarning(char const *behavior, cms::Exception const &e)

◆ name()

std::string const& edm::Path::name ( void  ) const
inline

◆ operator=()

Path& edm::Path::operator= ( Path const &  )
delete

◆ processOneOccurrenceAsync()

void edm::Path::processOneOccurrenceAsync ( WaitingTaskHolder  iTask,
EventTransitionInfo const &  iInfo,
ServiceToken const &  iToken,
StreamID const &  iStreamID,
StreamContext const *  iStreamContext 
)

Definition at line 203 of file Path.cc.

References actReg_, edm::WaitingTaskList::add(), failedModuleIndex_, finished(), edm::WaitingTaskHolder::group(), modulesToRun_, edm::hlt::Pass, pathContext_, printedException_, edm::WaitingTaskList::reset(), runNextWorkerAsync(), state_, timesRun_, waitingTasks_, and workers_.

207  {
209  modulesToRun_ = workers_.size();
210  ++timesRun_;
211  waitingTasks_.add(iTask);
212  printedException_ = false;
213  if (actReg_) {
214  ServiceRegistry::Operate guard(iToken);
215  actReg_->prePathEventSignal_(*iStreamContext, pathContext_);
216  }
217  //If the Path succeeds, these are the values we have at the end
218  state_ = hlt::Pass;
219  failedModuleIndex_ = workers_.size() - 1;
220 
221  if (workers_.empty()) {
222  ServiceRegistry::Operate guard(iToken);
223  finished(std::exception_ptr(), iStreamContext, iInfo, iStreamID);
224  return;
225  }
226 
227  runNextWorkerAsync(0, iInfo, iToken, iStreamID, iStreamContext, *iTask.group());
228  }
std::atomic< unsigned int > modulesToRun_
Definition: Path.h:118
void runNextWorkerAsync(unsigned int iNextModuleIndex, EventTransitionInfo const &, ServiceToken const &, StreamID const &, StreamContext const *, oneapi::tbb::task_group &iGroup)
Definition: Path.cc:331
PathContext pathContext_
Definition: Path.h:116
WaitingTaskList waitingTasks_
Definition: Path.h:117
void reset()
Resets access to the resource so that added tasks will wait.
accept
Definition: HLTenums.h:18
void finished(std::exception_ptr, StreamContext const *, EventTransitionInfo const &, StreamID const &)
Definition: Path.cc:300
void add(oneapi::tbb::task_group *, WaitingTask *)
Adds task to the waiting list.
WorkersInPath workers_
Definition: Path.h:114
int failedModuleIndex_
Definition: Path.h:105
std::shared_ptr< ActivityRegistry > const actReg_
Definition: Path.h:111
State state_
Definition: Path.h:106
std::atomic< bool > printedException_
Definition: Path.h:101
int timesRun_
Definition: Path.h:96

◆ recordStatus()

void edm::Path::recordStatus ( int  nwrwue,
hlt::HLTState  state 
)
private

Definition at line 160 of file Path.cc.

References bitpos_, and trptr_.

Referenced by finished().

160  {
161  if (trptr_) {
162  trptr_->at(bitpos_) = HLTPathStatus(state, nwrwue);
163  }
164  }
TrigResPtr const trptr_
Definition: Path.h:109
int const bitpos_
Definition: Path.h:108

◆ runAllModulesAsync()

template<typename T >
void edm::Path::runAllModulesAsync ( WaitingTaskHolder  task,
typename T::TransitionInfoType const &  info,
ServiceToken const &  token,
StreamID const &  streamID,
typename T::Context const *  context 
)

Definition at line 182 of file Path.h.

References visDQMUpload::context, info(), TrackValidation_cff::task, unpackBuffers-CaloStage2::token, and workers_.

186  {
187  for (auto& worker : workers_) {
188  worker.runWorkerAsync<T>(task, info, token, streamID, context);
189  }
190  }
static const TGPicture * info(bool iBackgroundIsBlack)
WorkersInPath workers_
Definition: Path.h:114
long double T

◆ runNextWorkerAsync()

void edm::Path::runNextWorkerAsync ( unsigned int  iNextModuleIndex,
EventTransitionInfo const &  iInfo,
ServiceToken const &  iToken,
StreamID const &  iID,
StreamContext const *  iContext,
oneapi::tbb::task_group &  iGroup 
)
private

Definition at line 331 of file Path.cc.

References info(), edm::ServiceWeakToken::lock(), edm::make_waiting_task(), workerFinished(), and workers_.

Referenced by processOneOccurrenceAsync(), and workerFinished().

336  {
337  //Figure out which next modules can run concurrently
338  const int firstModuleIndex = iNextModuleIndex;
339  int lastModuleIndex = firstModuleIndex;
340  while (lastModuleIndex + 1 != static_cast<int>(workers_.size()) and workers_[lastModuleIndex].runConcurrently()) {
341  ++lastModuleIndex;
342  }
343  for (; lastModuleIndex >= firstModuleIndex; --lastModuleIndex) {
344  ServiceWeakToken weakToken = iToken;
345  auto nextTask = make_waiting_task([this, lastModuleIndex, info = iInfo, iID, iContext, weakToken, &iGroup](
346  std::exception_ptr const* iException) {
347  this->workerFinished(iException, lastModuleIndex, info, weakToken.lock(), iID, iContext, iGroup);
348  });
349  workers_[lastModuleIndex].runWorkerAsync<OccurrenceTraits<EventPrincipal, BranchActionStreamBegin>>(
350  WaitingTaskHolder(iGroup, nextTask), iInfo, iToken, iID, iContext);
351  }
352  }
static const TGPicture * info(bool iBackgroundIsBlack)
void workerFinished(std::exception_ptr const *, unsigned int iModuleIndex, EventTransitionInfo const &, ServiceToken const &, StreamID const &, StreamContext const *, oneapi::tbb::task_group &iGroup)
Definition: Path.cc:230
FunctorWaitingTask< F > * make_waiting_task(F f)
Definition: WaitingTask.h:92
WorkersInPath workers_
Definition: Path.h:114

◆ setEarlyDeleteHelpers()

void edm::Path::setEarlyDeleteHelpers ( std::map< const Worker *, EarlyDeleteHelper *> const &  iWorkerToDeleter)

Definition at line 189 of file Path.cc.

References newFWLiteAna::found, getWorker(), and size().

189  {
190  for (unsigned int index = 0; index != size(); ++index) {
191  auto found = iWorkerToDeleter.find(getWorker(index));
192  if (found != iWorkerToDeleter.end()) {
193  found->second->addedToPath();
194  }
195  }
196  }
Worker const * getWorker(size_type i) const
Definition: Path.h:88
size_type size() const
Definition: Path.h:83

◆ setPathStatusInserter()

void edm::Path::setPathStatusInserter ( PathStatusInserter pathStatusInserter,
Worker pathStatusInserterWorker 
)

Definition at line 198 of file Path.cc.

References pathStatusInserter_, and pathStatusInserterWorker_.

198  {
199  pathStatusInserter_ = pathStatusInserter;
200  pathStatusInserterWorker_ = pathStatusInserterWorker;
201  }
Worker * pathStatusInserterWorker_
Definition: Path.h:121
PathStatusInserter * pathStatusInserter_
Definition: Path.h:120

◆ size()

size_type edm::Path::size ( void  ) const
inline

Definition at line 83 of file Path.h.

References workers_.

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), and setEarlyDeleteHelpers().

83 { return workers_.size(); }
WorkersInPath workers_
Definition: Path.h:114

◆ threadsafe_setFailedModuleInfo()

void edm::Path::threadsafe_setFailedModuleInfo ( int  nwrwue,
bool  iExceptionHappened 
)
private

Definition at line 134 of file Path.cc.

References edm::hlt::Exception, edm::hlt::Fail, failedModuleIndex_, state_, and stateLock_.

Referenced by workerFinished().

134  {
135  bool expected = false;
136  while (not stateLock_.compare_exchange_strong(expected, true)) {
137  expected = false;
138  }
139  if (iExcept) {
140  if (state_ == hlt::Exception) {
141  if (nwrwue < failedModuleIndex_) {
142  failedModuleIndex_ = nwrwue;
143  }
144  } else {
146  failedModuleIndex_ = nwrwue;
147  }
148  } else {
149  if (state_ != hlt::Exception) {
150  if (nwrwue < failedModuleIndex_) {
151  failedModuleIndex_ = nwrwue;
152  }
153  state_ = hlt::Fail;
154  }
155  }
156 
157  stateLock_ = false;
158  }
reject
Definition: HLTenums.h:19
int failedModuleIndex_
Definition: Path.h:105
State state_
Definition: Path.h:106
std::atomic< bool > stateLock_
Definition: Path.h:104

◆ timesExcept() [1/2]

int edm::Path::timesExcept ( ) const
inline

Definition at line 80 of file Path.h.

References timesExcept_.

80 { return timesExcept_; }
int timesExcept_
Definition: Path.h:99

◆ timesExcept() [2/2]

int edm::Path::timesExcept ( size_type  i) const
inline

Definition at line 87 of file Path.h.

References mps_fire::i, and workers_.

87 { return workers_.at(i).timesExcept(); }
WorkersInPath workers_
Definition: Path.h:114

◆ timesFailed() [1/2]

int edm::Path::timesFailed ( ) const
inline

Definition at line 79 of file Path.h.

References timesFailed_.

79 { return timesFailed_; }
int timesFailed_
Definition: Path.h:98

◆ timesFailed() [2/2]

int edm::Path::timesFailed ( size_type  i) const
inline

Definition at line 86 of file Path.h.

References mps_fire::i, and workers_.

86 { return workers_.at(i).timesFailed(); }
WorkersInPath workers_
Definition: Path.h:114

◆ timesPassed() [1/2]

int edm::Path::timesPassed ( ) const
inline

Definition at line 78 of file Path.h.

References timesPassed_.

78 { return timesPassed_; }
int timesPassed_
Definition: Path.h:97

◆ timesPassed() [2/2]

int edm::Path::timesPassed ( size_type  i) const
inline

Definition at line 85 of file Path.h.

References mps_fire::i, and workers_.

85 { return workers_.at(i).timesPassed(); }
WorkersInPath workers_
Definition: Path.h:114

◆ timesRun()

int edm::Path::timesRun ( ) const
inline

Definition at line 77 of file Path.h.

References timesRun_.

77 { return timesRun_; }
int timesRun_
Definition: Path.h:96

◆ timesVisited()

int edm::Path::timesVisited ( size_type  i) const
inline

Definition at line 84 of file Path.h.

References mps_fire::i, and workers_.

84 { return workers_.at(i).timesVisited(); }
WorkersInPath workers_
Definition: Path.h:114

◆ updateCounters()

void edm::Path::updateCounters ( hlt::HLTState  state)
private

Definition at line 166 of file Path.cc.

References edm::hlt::Exception, edm::hlt::Fail, edm::hlt::Pass, timesExcept_, timesFailed_, and timesPassed_.

Referenced by finished().

166  {
167  switch (state) {
168  case hlt::Pass: {
169  ++timesPassed_;
170  break;
171  }
172  case hlt::Fail: {
173  ++timesFailed_;
174  break;
175  }
176  case hlt::Exception: {
177  ++timesExcept_;
178  }
179  default:;
180  }
181  }
int timesFailed_
Definition: Path.h:98
reject
Definition: HLTenums.h:19
int timesExcept_
Definition: Path.h:99
accept
Definition: HLTenums.h:18
int timesPassed_
Definition: Path.h:97

◆ workerFinished()

void edm::Path::workerFinished ( std::exception_ptr const *  iException,
unsigned int  iModuleIndex,
EventTransitionInfo const &  iInfo,
ServiceToken const &  iToken,
StreamID const &  iID,
StreamContext const *  iContext,
oneapi::tbb::task_group &  iGroup 
)
private

Definition at line 230 of file Path.cc.

References cms::cuda::assert(), cms::Exception::clone(), CMS_SA_ALLOW, submitPVResolutionJobs::desc, cppFunctionSkipper::exception, finished(), handleWorkerFailure(), edm::EventPrincipal::id(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, modulesToRun_, edm::WaitingTaskList::presetTaskAsFailed(), edm::EventTransitionInfo::principal(), runNextWorkerAsync(), edm::errors::StdException, threadsafe_setFailedModuleInfo(), edm::errors::Unknown, waitingTasks_, and workers_.

Referenced by runNextWorkerAsync().

236  {
237  EventPrincipal const& iEP = iInfo.principal();
238  ServiceRegistry::Operate guard(iToken);
239 
240  //This call also allows the WorkerInPath to update statistics
241  // so should be done even if an exception happened
242  auto& worker = workers_[iModuleIndex];
243  bool shouldContinue = worker.checkResultsOfRunWorker(true);
244  std::exception_ptr finalException;
245  if (iException) {
246  shouldContinue = false;
247  std::unique_ptr<cms::Exception> pEx;
248  try {
249  std::rethrow_exception(*iException);
250  } catch (cms::Exception& oldEx) {
251  pEx = std::unique_ptr<cms::Exception>(oldEx.clone());
252  } catch (std::exception const& oldEx) {
253  pEx = std::make_unique<edm::Exception>(errors::StdException);
254  } catch (...) {
255  pEx = std::make_unique<edm::Exception>(errors::Unknown);
256  }
257  // Caught exception is propagated via WaitingTaskList
258  CMS_SA_ALLOW try {
259  std::ostringstream ost;
260  ost << iEP.id();
261  ModuleDescription const* desc = worker.getWorker()->description();
262  assert(desc != nullptr);
263  handleWorkerFailure(*pEx, iModuleIndex, *desc, ost.str());
264  //If we didn't rethrow, then we effectively skipped
265  worker.skipWorker(iEP);
266  } catch (...) {
267  finalException = std::current_exception();
268  //set the exception early to avoid case where another Path is waiting
269  // on a module in this Path and not running the module will lead to a
270  // different but related exception in the other Path. We want this
271  // Paths exception to be the one that gets reported.
272  waitingTasks_.presetTaskAsFailed(finalException);
273  }
274  }
275  auto const nextIndex = iModuleIndex + 1;
276  if (shouldContinue and nextIndex < workers_.size()) {
277  if (not worker.runConcurrently()) {
278  --modulesToRun_;
279  runNextWorkerAsync(nextIndex, iInfo, iToken, iID, iContext, iGroup);
280  return;
281  }
282  }
283 
284  if (not shouldContinue) {
285  threadsafe_setFailedModuleInfo(iModuleIndex, iException != nullptr);
286  }
287  if (not shouldContinue and not worker.runConcurrently()) {
288  //we are leaving the path early
289  for (auto it = workers_.begin() + nextIndex, itEnd = workers_.end(); it != itEnd; ++it) {
290  --modulesToRun_;
291  it->skipWorker(iEP);
292  }
293  }
294  if (--modulesToRun_ == 0) {
295  //The path should only be marked as finished once all outstanding modules finish
296  finished(finalException, iContext, iInfo, iID);
297  }
298  }
#define CMS_SA_ALLOW
std::atomic< unsigned int > modulesToRun_
Definition: Path.h:118
void runNextWorkerAsync(unsigned int iNextModuleIndex, EventTransitionInfo const &, ServiceToken const &, StreamID const &, StreamContext const *, oneapi::tbb::task_group &iGroup)
Definition: Path.cc:331
WaitingTaskList waitingTasks_
Definition: Path.h:117
assert(be >=bs)
void handleWorkerFailure(cms::Exception &e, int nwrwue, ModuleDescription const &, std::string const &id)
Definition: Path.cc:68
void finished(std::exception_ptr, StreamContext const *, EventTransitionInfo const &, StreamID const &)
Definition: Path.cc:300
WorkersInPath workers_
Definition: Path.h:114
void presetTaskAsFailed(std::exception_ptr iExcept)
virtual Exception * clone() const
Definition: Exception.cc:185
void threadsafe_setFailedModuleInfo(int nwrwue, bool iExceptionHappened)
Definition: Path.cc:134

Member Data Documentation

◆ act_table_

ExceptionToActionTable const* const edm::Path::act_table_
private

Definition at line 112 of file Path.h.

Referenced by handleWorkerFailure().

◆ actReg_

std::shared_ptr<ActivityRegistry> const edm::Path::actReg_
private

Definition at line 111 of file Path.h.

Referenced by finished(), and processOneOccurrenceAsync().

◆ bitpos_

int const edm::Path::bitpos_
private

Definition at line 108 of file Path.h.

Referenced by bitPosition(), and recordStatus().

◆ failedModuleIndex_

int edm::Path::failedModuleIndex_
private

Definition at line 105 of file Path.h.

Referenced by finished(), processOneOccurrenceAsync(), and threadsafe_setFailedModuleInfo().

◆ modulesToRun_

std::atomic<unsigned int> edm::Path::modulesToRun_
private

Definition at line 118 of file Path.h.

Referenced by Path(), processOneOccurrenceAsync(), and workerFinished().

◆ pathContext_

PathContext edm::Path::pathContext_
private

Definition at line 116 of file Path.h.

Referenced by finished(), handleWorkerFailure(), name(), Path(), and processOneOccurrenceAsync().

◆ pathStatusInserter_

PathStatusInserter* edm::Path::pathStatusInserter_
private

Definition at line 120 of file Path.h.

Referenced by finished(), and setPathStatusInserter().

◆ pathStatusInserterWorker_

Worker* edm::Path::pathStatusInserterWorker_
private

Definition at line 121 of file Path.h.

Referenced by finished(), and setPathStatusInserter().

◆ printedException_

std::atomic<bool> edm::Path::printedException_ = false
private

Definition at line 101 of file Path.h.

Referenced by handleWorkerFailure(), and processOneOccurrenceAsync().

◆ state_

State edm::Path::state_
private

Definition at line 106 of file Path.h.

Referenced by finished(), processOneOccurrenceAsync(), and threadsafe_setFailedModuleInfo().

◆ stateLock_

std::atomic<bool> edm::Path::stateLock_ = false
private

Definition at line 104 of file Path.h.

Referenced by threadsafe_setFailedModuleInfo().

◆ timesExcept_

int edm::Path::timesExcept_
private

Definition at line 99 of file Path.h.

Referenced by clearCounters(), timesExcept(), and updateCounters().

◆ timesFailed_

int edm::Path::timesFailed_
private

Definition at line 98 of file Path.h.

Referenced by clearCounters(), timesFailed(), and updateCounters().

◆ timesPassed_

int edm::Path::timesPassed_
private

Definition at line 97 of file Path.h.

Referenced by clearCounters(), timesPassed(), and updateCounters().

◆ timesRun_

int edm::Path::timesRun_
private

Definition at line 96 of file Path.h.

Referenced by clearCounters(), processOneOccurrenceAsync(), and timesRun().

◆ trptr_

TrigResPtr const edm::Path::trptr_
private

Definition at line 109 of file Path.h.

Referenced by recordStatus().

◆ waitingTasks_

WaitingTaskList edm::Path::waitingTasks_
private

Definition at line 117 of file Path.h.

Referenced by finished(), processOneOccurrenceAsync(), and workerFinished().

◆ workers_

WorkersInPath edm::Path::workers_
private