CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
edm::UnscheduledProductResolver Class Reference

#include <ProductResolvers.h>

Inheritance diagram for edm::UnscheduledProductResolver:
edm::ProducedProductResolver edm::DataManagingProductResolver edm::DataManagingOrAliasProductResolver edm::ProductResolverBase

Public Member Functions

void setupUnscheduled (UnscheduledConfigurator const &) final
 
 UnscheduledProductResolver (std::shared_ptr< BranchDescription const > bd)
 
- Public Member Functions inherited from edm::ProducedProductResolver
 ProducedProductResolver (std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
 
- Public Member Functions inherited from edm::DataManagingProductResolver
void connectTo (ProductResolverBase const &, Principal const *) final
 
 DataManagingProductResolver (std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
 
void resetStatus ()
 
- Public Member Functions inherited from edm::DataManagingOrAliasProductResolver
 DataManagingOrAliasProductResolver ()
 
- Public Member Functions inherited from edm::ProductResolverBase
BranchDescription const & branchDescription () const
 
std::string const & moduleLabel () const
 
ProductResolverBaseoperator= (ProductResolverBase const &)=delete
 
void prefetchAsync (WaitingTask *waitTask, Principal const &principal, bool skipCurrentProcess, ServiceToken const &token, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
std::string const & processName () const
 
ProductID const & productID () const
 
std::string const & productInstanceName () const
 
ProductProvenance const * productProvenancePtr () const
 
bool productResolved () const
 
 ProductResolverBase ()
 
 ProductResolverBase (ProductResolverBase const &)=delete
 
TypeID productType () const
 
bool productUnavailable () const
 
bool productWasDeleted () const
 
bool productWasFetchedAndIsValid (bool iSkipCurrentProcess) const
 
Provenance const * provenance () const
 
bool provenanceAvailable () const
 
void putOrMergeProduct (std::unique_ptr< WrapperBase > edp, MergeableRunProductMetadata const *mergeableRunProductMetadata=nullptr) const
 
void putProduct (std::unique_ptr< WrapperBase > edp) const
 
void resetBranchDescription (std::shared_ptr< BranchDescription const > bd)
 
void resetProductData ()
 
std::string const & resolvedModuleLabel () const
 
Resolution resolveProduct (Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
void retrieveAndMerge (Principal const &principal, MergeableRunProductMetadata const *mergeableRunProductMetadata) const
 
void setMergeableRunProductMetadata (MergeableRunProductMetadata const *mrpm)
 
void setProductID (ProductID const &pid)
 
void setProductProvenanceRetriever (ProductProvenanceRetriever const *provRetriever)
 
bool singleProduct () const
 
StableProvenance const * stableProvenance () const
 
void unsafe_deleteProduct () const
 
bool unscheduledWasNotRun () const
 
void write (std::ostream &os) const
 
virtual ~ProductResolverBase ()
 

Private Member Functions

void prefetchAsync_ (WaitingTask *waitTask, Principal const &principal, bool skipCurrentProcess, ServiceToken const &token, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const override
 
void resetProductData_ (bool deleteEarly) override
 
Resolution resolveProduct_ (Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const override
 
bool unscheduledWasNotRun_ () const override
 

Private Attributes

UnscheduledAuxiliary const * aux_
 
std::atomic< bool > prefetchRequested_
 
WaitingTaskList waitingTasks_
 
Workerworker_
 

Additional Inherited Members

- Public Types inherited from edm::DataManagingProductResolver
enum  ProductStatus {
  ProductStatus::ProductSet, ProductStatus::NotPut, ProductStatus::ResolveFailed, ProductStatus::ResolveNotRun,
  ProductStatus::ProductDeleted
}
 
- Protected Member Functions inherited from edm::ProducedProductResolver
void putProduct_ (std::unique_ptr< WrapperBase > edp) const override
 
- Protected Member Functions inherited from edm::DataManagingProductResolver
ProductStatus defaultStatus () const
 
ProductData const & getProductData () const final
 
template<bool callResolver, typename FUNC >
ProductResolverBase::Resolution resolveProductImpl (FUNC resolver) const
 
template<bool callResolver, typename FUNC >
Resolution resolveProductImpl (FUNC resolver) const
 
void setFailedStatus () const
 
void setMergeableRunProductMetadataInProductData (MergeableRunProductMetadata const *)
 
void setProduct (std::unique_ptr< WrapperBase > edp) const
 
ProductStatus status () const
 

Detailed Description

Definition at line 182 of file ProductResolvers.h.

Constructor & Destructor Documentation

◆ UnscheduledProductResolver()

edm::UnscheduledProductResolver::UnscheduledProductResolver ( std::shared_ptr< BranchDescription const >  bd)
inlineexplicit

Definition at line 184 of file ProductResolvers.h.

Member Function Documentation

◆ prefetchAsync_()

void edm::UnscheduledProductResolver::prefetchAsync_ ( WaitingTask waitTask,
Principal const &  principal,
bool  skipCurrentProcess,
ServiceToken const &  token,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const
overrideprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 423 of file ProductResolvers.cc.

428  {
429  if (skipCurrentProcess) {
430  return;
431  }
432  //need to try changing prefetchRequested_ before adding to waitingTasks_
433  bool expected = false;
434  bool prefetchRequested = prefetchRequested_.compare_exchange_strong(expected, true);
435  waitingTasks_.add(waitTask);
436  if (prefetchRequested) {
437  //Have to create a new task which will make sure the state for UnscheduledProductResolver
438  // is properly set after the module has run
439  auto t = make_waiting_task(tbb::task::allocate_root(), [this](std::exception_ptr const* iPtr) {
440  //The exception is being rethrown because resolveProductImpl sets the ProductResolver to a failed
441  // state for the case where an exception occurs during the call to the function.
442  // Caught exception is propagated via WaitingTaskList
443  CMS_SA_ALLOW try {
444  resolveProductImpl<true>([iPtr]() {
445  if (iPtr) {
446  std::rethrow_exception(*iPtr);
447  }
448  });
449  } catch (...) {
450  waitingTasks_.doneWaiting(std::current_exception());
451  return;
452  }
453  waitingTasks_.doneWaiting(nullptr);
454  });
455  auto const& event = static_cast<EventPrincipal const&>(principal);
456  ParentContext parentContext(mcc);
457 
458  worker_->doWorkAsync<OccurrenceTraits<EventPrincipal, BranchActionStreamBegin> >(
459  t, event, *(aux_->eventSetup()), token, event.streamID(), parentContext, mcc->getStreamContext());
460  }
461  }

References edm::WaitingTaskList::add(), aux_, CMS_SA_ALLOW, edm::WaitingTaskList::doneWaiting(), edm::Worker::doWorkAsync(), event(), edm::UnscheduledAuxiliary::eventSetup(), edm::ModuleCallingContext::getStreamContext(), edm::make_waiting_task(), prefetchRequested_, OrderedSet::t, unpackBuffers-CaloStage2::token, waitingTasks_, and worker_.

◆ resetProductData_()

void edm::UnscheduledProductResolver::resetProductData_ ( bool  deleteEarly)
overrideprivatevirtual

Reimplemented from edm::DataManagingProductResolver.

Definition at line 463 of file ProductResolvers.cc.

463  {
464  if (not deleteEarly) {
465  prefetchRequested_ = false;
467  }
469  }

References prefetchRequested_, edm::WaitingTaskList::reset(), edm::DataManagingProductResolver::resetProductData_(), and waitingTasks_.

◆ resolveProduct_()

ProductResolverBase::Resolution edm::UnscheduledProductResolver::resolveProduct_ ( Principal const &  principal,
bool  skipCurrentProcess,
SharedResourcesAcquirer sra,
ModuleCallingContext const *  mcc 
) const
overrideprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 385 of file ProductResolvers.cc.

388  {
389  if (!skipCurrentProcess and worker_) {
390  return resolveProductImpl<true>([&principal, this, sra, mcc]() {
391  try {
392  auto const& event = static_cast<EventPrincipal const&>(principal);
393  ParentContext parentContext(mcc);
394  aux_->preModuleDelayedGetSignal_.emit(*(mcc->getStreamContext()), *mcc);
395 
396  auto workCall = [this, &event, &parentContext, mcc]() {
397  auto sentry(make_sentry(mcc, [this](ModuleCallingContext const* iContext) {
398  aux_->postModuleDelayedGetSignal_.emit(*(iContext->getStreamContext()), *iContext);
399  }));
400 
401  worker_->doWork<OccurrenceTraits<EventPrincipal, BranchActionStreamBegin> >(
402  event, *(aux_->eventSetup()), event.streamID(), parentContext, mcc->getStreamContext());
403  };
404 
405  if (sra) {
406  assert(false);
407  } else {
408  workCall();
409  }
410 
411  } catch (cms::Exception& ex) {
412  std::ostringstream ost;
413  ost << "Calling produce method for unscheduled module " << worker_->description().moduleName() << "/'"
414  << worker_->description().moduleLabel() << "'";
415  ex.addContext(ost.str());
416  throw;
417  }
418  });
419  }
420  return Resolution(nullptr);
421  }

References cms::Exception::addContext(), cms::cuda::assert(), aux_, edm::Worker::description(), edm::Worker::doWork(), edm::signalslot::Signal< T >::emit(), event(), edm::UnscheduledAuxiliary::eventSetup(), edm::ModuleCallingContext::getStreamContext(), edm::make_sentry(), edm::ModuleDescription::moduleLabel(), edm::ModuleDescription::moduleName(), edm::UnscheduledAuxiliary::postModuleDelayedGetSignal_, edm::UnscheduledAuxiliary::preModuleDelayedGetSignal_, Resolution, and worker_.

◆ setupUnscheduled()

void edm::UnscheduledProductResolver::setupUnscheduled ( UnscheduledConfigurator const &  iConfigure)
finalvirtual

◆ unscheduledWasNotRun_()

bool edm::UnscheduledProductResolver::unscheduledWasNotRun_ ( ) const
inlineoverrideprivatevirtual

Member Data Documentation

◆ aux_

UnscheduledAuxiliary const* edm::UnscheduledProductResolver::aux_
private

Definition at line 205 of file ProductResolvers.h.

Referenced by prefetchAsync_(), resolveProduct_(), and setupUnscheduled().

◆ prefetchRequested_

std::atomic<bool> edm::UnscheduledProductResolver::prefetchRequested_
mutableprivate

Definition at line 207 of file ProductResolvers.h.

Referenced by prefetchAsync_(), and resetProductData_().

◆ waitingTasks_

WaitingTaskList edm::UnscheduledProductResolver::waitingTasks_
mutableprivate

Definition at line 204 of file ProductResolvers.h.

Referenced by prefetchAsync_(), and resetProductData_().

◆ worker_

Worker* edm::UnscheduledProductResolver::worker_
private

Definition at line 206 of file ProductResolvers.h.

Referenced by prefetchAsync_(), resolveProduct_(), and setupUnscheduled().

edm::ModuleDescription::moduleLabel
std::string const & moduleLabel() const
Definition: ModuleDescription.h:43
edm::ProducedProductResolver::ProducedProductResolver
ProducedProductResolver(std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
Definition: ProductResolvers.h:142
cms::Exception::addContext
void addContext(std::string const &context)
Definition: Exception.cc:165
edm::UnscheduledAuxiliary::eventSetup
EventSetupImpl const * eventSetup() const
Definition: UnscheduledAuxiliary.h:38
edm::signalslot::Signal::emit
void emit(Args &&... args) const
Definition: Signal.h:46
edm::WaitingTaskList::add
void add(WaitingTask *)
Adds task to the waiting list.
Definition: WaitingTaskList.cc:89
edm::ModuleDescription::moduleName
std::string const & moduleName() const
Definition: ModuleDescription.h:42
cms::cuda::assert
assert(be >=bs)
CMS_SA_ALLOW
#define CMS_SA_ALLOW
Definition: thread_safety_macros.h:5
edm::WaitingTaskList::reset
void reset()
Resets access to the resource so that added tasks will wait.
Definition: WaitingTaskList.cc:51
edm::WaitingTaskList::doneWaiting
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
Definition: WaitingTaskList.cc:169
edm::UnscheduledProductResolver::waitingTasks_
WaitingTaskList waitingTasks_
Definition: ProductResolvers.h:204
edm::UnscheduledProductResolver::aux_
UnscheduledAuxiliary const * aux_
Definition: ProductResolvers.h:205
OrderedSet.t
t
Definition: OrderedSet.py:90
edm::make_waiting_task
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
Definition: WaitingTask.h:87
edm::UnscheduledAuxiliary::preModuleDelayedGetSignal_
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> preModuleDelayedGetSignal_
Definition: UnscheduledAuxiliary.h:45
Resolution
Definition: trackSplitPlot.h:33
edm::Worker::doWorkAsync
void doWorkAsync(WaitingTask *task, typename T::MyPrincipal const &, EventSetupImpl const &c, ServiceToken const &token, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
Definition: Worker.h:831
edm::DataManagingProductResolver::ProductStatus::ResolveNotRun
edm::Worker::description
ModuleDescription const & description() const
Definition: Worker.h:190
edm::ProductResolverBase::moduleLabel
std::string const & moduleLabel() const
Definition: ProductResolverBase.h:119
edm::DataManagingProductResolver::resetProductData_
void resetProductData_(bool deleteEarly) override
Definition: ProductResolvers.cc:571
edm::DataManagingProductResolver::status
ProductStatus status() const
Definition: ProductResolvers.h:64
edm::ProductResolverBase::branchDescription
BranchDescription const & branchDescription() const
Definition: ProductResolverBase.h:110
edm::UnscheduledProductResolver::worker_
Worker * worker_
Definition: ProductResolvers.h:206
edm::make_sentry
std::unique_ptr< T, F > make_sentry(T *iObject, F iFunc)
NOTE: if iObject is null, then iFunc will not be called.
Definition: make_sentry.h:30
edm::Worker::doWork
bool doWork(typename T::MyPrincipal const &, EventSetupImpl const &c, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
Definition: Worker.h:974
edm::UnscheduledAuxiliary::postModuleDelayedGetSignal_
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> postModuleDelayedGetSignal_
Definition: UnscheduledAuxiliary.h:46
cms::Exception
Definition: Exception.h:70
event
Definition: event.py:1
event
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of "!*" before the partial wildcard feature was incorporated). The per-event "cost" of each negative criterion with multiple relevant triggers is about the same as ! *was in the past
edm::UnscheduledProductResolver::prefetchRequested_
std::atomic< bool > prefetchRequested_
Definition: ProductResolvers.h:207
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316