Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DataFormats/Common/interface/ProductData.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace edm {

//Not const thread-safe update
void unsafe_setWrapper(std::unique_ptr<WrapperBase> iValue) const;
void unsafe_setWrapper(std::shared_ptr<WrapperBase const> iValue) const; // for SwitchProducer
void unsafe_setWrapper(std::shared_ptr<WrapperBase const> iValue) const; // for RepeatingCachedRootSource

void resetProductDescription(std::shared_ptr<ProductDescription const> bd);

Expand Down
16 changes: 0 additions & 16 deletions DataFormats/Provenance/interface/BranchDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,6 @@ namespace edm {
TypeID wrappedTypeID() const { return TypeID(transient_.wrappedType_.typeInfo()); }
TypeID unwrappedTypeID() const { return TypeID(transient_.unwrappedType_.typeInfo()); }

bool isSwitchAlias() const { return not transient_.switchAliasModuleLabel_.empty(); }
std::string const& switchAliasModuleLabel() const { return transient_.switchAliasModuleLabel_; }
void setSwitchAliasModuleLabel(std::string label) { transient_.switchAliasModuleLabel_ = std::move(label); }
BranchID const& switchAliasForBranchID() const { return transient_.switchAliasForBranchID_; }
void setSwitchAliasForBranch(BranchDescription const& aliasForBranch);

bool isAnyAlias() const { return isAlias() or isSwitchAlias(); }

bool isProvenanceSetOnRead() const noexcept { return transient_.isProvenanceSetOnRead_; }
void setIsProvenanceSetOnRead(bool value = true) noexcept { transient_.isProvenanceSetOnRead_ = value; }

Expand Down Expand Up @@ -132,14 +124,6 @@ namespace edm {
// The wrapped class name, which is currently derivable from the other attributes.
std::string wrappedName_;

// For SwitchProducer alias, the label of the aliased-for label; otherwise empty
std::string switchAliasModuleLabel_;

// Need a separate (transient) BranchID for switch, because
// otherwise originalBranchID() gives wrong answer when reading
// from a file (leading to wrong ProductProvenance to be retrieved)
BranchID switchAliasForBranchID_;

// A TypeWithDict object for the wrapped object
// This is set if and only if the dropped_ is false
TypeWithDict wrappedType_;
Expand Down
22 changes: 0 additions & 22 deletions DataFormats/Provenance/src/BranchDescription.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,28 +194,6 @@ namespace edm {
branchAliases_.insert(other.branchAliases().begin(), other.branchAliases().end());
}

void BranchDescription::setSwitchAliasForBranch(BranchDescription const& aliasForBranch) {
if (branchType_ != aliasForBranch.branchType()) {
throw Exception(errors::LogicError) << "BranchDescription::setSwitchAliasForBranch: branchType (" << branchType_
<< ") differs from aliasForBranch (" << aliasForBranch.branchType()
<< ").\nPlease report this error to the FWCore developers";
}
if (produced() != aliasForBranch.produced()) {
throw Exception(errors::LogicError) << "BranchDescription::setSwitchAliasForBranch: produced differs from "
"aliasForBranch.\nPlease report this error to the FWCore developers";
}
if (unwrappedTypeID().typeInfo() != aliasForBranch.unwrappedType().typeInfo()) {
throw Exception(errors::LogicError)
<< "BranchDescription::setSwitchAliasForBranch: unwrapped type info (" << unwrappedTypeID().name()
<< ") differs from aliasForBranch (" << aliasForBranch.unwrappedType().typeInfo().name()
<< ").\nPlease report this error to the FWCore developers";
}

branchAliases_ = aliasForBranch.branchAliases();
transient_.switchAliasForBranchID_ = aliasForBranch.originalBranchID();
transient_.availableOnlyAtEndTransition_ = aliasForBranch.availableOnlyAtEndTransition();
}

void BranchDescription::write(std::ostream& os) const {
os << "Branch Type = " << branchType() << std::endl;
os << "Process Name = " << processName() << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Framework/interface/TypeMatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace edm {
class TypeMatch {
public:
bool operator()(edm::ProductDescription const& productDescription) const {
return not productDescription.isAnyAlias();
return not productDescription.isAlias();
}
};
} // namespace edm
Expand Down
5 changes: 0 additions & 5 deletions FWCore/Framework/src/ModuleMaker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ namespace edm {
MakeModuleParams const& p,
signalslot::Signal<void(ModuleDescription const&)>& pre,
signalslot::Signal<void(ModuleDescription const&)>& post) const {
// Add process_name for SwitchProducer
if (p.pset_->getParameter<std::string>("@module_type") == "SwitchProducer") {
p.pset_->addUntrackedParameter("@process_name", p.processConfiguration_->processName());
}

ConfigurationDescriptions descriptions(baseType(), p.pset_->getParameter<std::string>("@module_type"));
fillDescriptions(descriptions);
try {
Expand Down
4 changes: 2 additions & 2 deletions FWCore/Framework/src/Principal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ namespace edm {
provenances.clear();
for (auto const& productResolver : *this) {
if (productResolver->singleProduct() && productResolver->provenanceAvailable() &&
!productResolver->productDescription().isAnyAlias()) {
!productResolver->productDescription().isAlias()) {
// We do not attempt to get the event/lumi/run status from the provenance,
// because the per event provenance may have been dropped.
if (productResolver->provenance()->productDescription().present()) {
Expand All @@ -628,7 +628,7 @@ namespace edm {
void Principal::getAllStableProvenance(std::vector<StableProvenance const*>& provenances) const {
provenances.clear();
for (auto const& productResolver : *this) {
if (productResolver->singleProduct() && !productResolver->productDescription().isAnyAlias()) {
if (productResolver->singleProduct() && !productResolver->productDescription().isAlias()) {
if (productResolver->stableProvenance()->productDescription().present()) {
provenances.push_back(productResolver->stableProvenance());
}
Expand Down
8 changes: 0 additions & 8 deletions FWCore/Framework/src/ProductRegistryHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,6 @@ namespace edm {
p->typeID_,
true,
isEndTransition(p->transition_));
if (p->aliasType_ == TypeLabelItem::AliasType::kSwitchAlias) {
if (p->branchAlias_.empty()) {
throw edm::Exception(edm::errors::LogicError)
<< "Branch alias type has been set to SwitchAlias, but the alias content is empty.\n"
<< "Please report this error to the FWCore developers";
}
pdesc.setSwitchAliasModuleLabel(p->branchAlias_);
}
if (p->isTransform_) {
pdesc.setOnDemand(true);
pdesc.setIsTransform(true);
Expand Down
165 changes: 0 additions & 165 deletions FWCore/Framework/src/ProductResolvers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -679,169 +679,4 @@ namespace edm {

bool AliasProductResolver::singleProduct_() const { return true; }

SwitchBaseProductResolver::SwitchBaseProductResolver(std::shared_ptr<ProductDescription const> bd,
DataManagingOrAliasProductResolver& realProduct)
: realProduct_(realProduct), productData_(std::move(bd)), prefetchRequested_(false) {
// Parentage of this branch is always the same by construction, so we can compute the ID just "once" here.
Parentage p;
p.setParents(std::vector<BranchID>{realProduct.productDescription().originalBranchID()});
parentageID_ = p.id();
ParentageRegistry::instance()->insertMapped(p);
}

void SwitchBaseProductResolver::connectTo(ProductResolverBase const& iOther, Principal const* iParentPrincipal) {
throw Exception(errors::LogicError)
<< "SwitchBaseProductResolver::connectTo() not implemented and should never be called.\n"
<< "Contact a Framework developer\n";
}

void SwitchBaseProductResolver::setupUnscheduled(UnscheduledConfigurator const& iConfigure) {
worker_ = iConfigure.findWorker(productDescription().moduleLabel());
}

ProductResolverBase::Resolution SwitchBaseProductResolver::resolveProductImpl(Resolution res) const {
if (res.data() == nullptr)
return res;
return Resolution(&productData_);
}

bool SwitchBaseProductResolver::productResolved_() const {
// SwitchProducer will never put anything in the event, and
// "false" will make Event::commit_() to call putProduct() with
// null unique_ptr<WrapperBase> to signal that the produce() was
// run.
return false;
}

void SwitchBaseProductResolver::setProductProvenanceRetriever_(ProductProvenanceRetriever const* provRetriever) {
productData_.setProvenance(provRetriever);
}

void SwitchBaseProductResolver::setProductID_(ProductID const& pid) {
// insertIntoSet is const, so let's exploit that to fake the getting of the "input" product
productData_.setProductID(pid);
}

void SwitchBaseProductResolver::resetProductData_(bool deleteEarly) {
productData_.resetProductData();
realProduct_.resetProductData_(deleteEarly);
if (not deleteEarly) {
prefetchRequested_ = false;
waitingTasks_.reset();
}
}

void SwitchBaseProductResolver::unsafe_setWrapperAndProvenance() const {
// update provenance
productData_.provenance().store()->insertIntoSet(ProductProvenance(productDescription().branchID(), parentageID_));
// Use the Wrapper of the pointed-to resolver, but the provenance of this resolver
productData_.unsafe_setWrapper(realProduct().getProductData().sharedConstWrapper());
}

SwitchProducerProductResolver::SwitchProducerProductResolver(std::shared_ptr<ProductDescription const> bd,
DataManagingOrAliasProductResolver& realProduct)
: SwitchBaseProductResolver(std::move(bd), realProduct), status_(defaultStatus_) {}

ProductResolverBase::Resolution SwitchProducerProductResolver::resolveProduct_(
Principal const& principal, SharedResourcesAcquirer* sra, ModuleCallingContext const* mcc) const {
if (status_ == ProductStatus::ResolveFailed) {
return resolveProductImpl(realProduct().resolveProduct(principal, sra, mcc));
}
return Resolution(nullptr);
}

void SwitchProducerProductResolver::prefetchAsync_(WaitingTaskHolder waitTask,
Principal const& principal,
ServiceToken const& token,
SharedResourcesAcquirer* sra,
ModuleCallingContext const* mcc) const noexcept {
if (productDescription().availableOnlyAtEndTransition() and mcc and not mcc->parent().isAtEndTransition()) {
return;
}

//need to try changing prefetchRequested before adding to waitingTasks
bool expected = false;
bool doPrefetchRequested = prefetchRequested().compare_exchange_strong(expected, true);
waitingTasks().add(waitTask);

if (doPrefetchRequested) {
//using a waiting task to do a callback guarantees that
// the waitingTasks() list will be released from waiting even
// if the module does not put this data product or the
// module has an exception while running
auto waiting = make_waiting_task([this](std::exception_ptr const* iException) {
if (nullptr != iException) {
waitingTasks().doneWaiting(*iException);
} else {
unsafe_setWrapperAndProvenance();
waitingTasks().doneWaiting(std::exception_ptr());
}
});
worker()->callWhenDoneAsync(WaitingTaskHolder(*waitTask.group(), waiting));
}
}

void SwitchProducerProductResolver::putProduct(std::unique_ptr<WrapperBase> edp) const {
if (status_ != defaultStatus_) {
throw Exception(errors::InsertFailure)
<< "Attempt to insert more than one product for a branch " << productDescription().branchName()
<< "This makes no sense for SwitchProducerProductResolver.\nContact a Framework developer";
}
// Let's use ResolveFailed to signal that produce() was called, as
// there is no real product in this resolver
status_ = ProductStatus::ResolveFailed;
bool expected = false;
if (prefetchRequested().compare_exchange_strong(expected, true)) {
unsafe_setWrapperAndProvenance();
waitingTasks().doneWaiting(std::exception_ptr());
}
}

bool SwitchProducerProductResolver::productUnavailable_() const {
// if produce() was run (ResolveFailed), ask from the real resolver
if (status_ == ProductStatus::ResolveFailed) {
return realProduct().productUnavailable();
}
return true;
}

void SwitchProducerProductResolver::resetProductData_(bool deleteEarly) {
SwitchBaseProductResolver::resetProductData_(deleteEarly);
if (not deleteEarly) {
status_ = defaultStatus_;
}
}

ProductResolverBase::Resolution SwitchAliasProductResolver::resolveProduct_(Principal const& principal,
SharedResourcesAcquirer* sra,
ModuleCallingContext const* mcc) const {
return resolveProductImpl(realProduct().resolveProduct(principal, sra, mcc));
}

void SwitchAliasProductResolver::prefetchAsync_(WaitingTaskHolder waitTask,
Principal const& principal,
ServiceToken const& token,
SharedResourcesAcquirer* sra,
ModuleCallingContext const* mcc) const noexcept {
//need to try changing prefetchRequested_ before adding to waitingTasks_
bool expected = false;
bool doPrefetchRequested = prefetchRequested().compare_exchange_strong(expected, true);
waitingTasks().add(waitTask);

if (doPrefetchRequested) {
//using a waiting task to do a callback guarantees that
// the waitingTasks() list will be released from waiting even
// if the module does not put this data product or the
// module has an exception while running
auto waiting = make_waiting_task([this](std::exception_ptr const* iException) {
if (nullptr != iException) {
waitingTasks().doneWaiting(*iException);
} else {
unsafe_setWrapperAndProvenance();
waitingTasks().doneWaiting(std::exception_ptr());
}
});
realProduct().prefetchAsync(WaitingTaskHolder(*waitTask.group(), waiting), principal, token, sra, mcc);
}
}
} // namespace edm
Loading