Skip to content

Commit

Permalink
Merge pull request #636 from Dr15Jones/useSameModuleDescription
Browse files Browse the repository at this point in the history
Have Workers for the same module use the same ModuleDescription
  • Loading branch information
ktf committed Aug 28, 2013
2 parents ad63181 + 0aa90c4 commit ab47016
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
3 changes: 3 additions & 0 deletions FWCore/Framework/interface/one/OutputModuleBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ namespace edm {

BranchIDLists const* branchIDLists() const;

const ModuleDescription& moduleDescription() const {
return moduleDescription_;
}
protected:

Trig getTriggerResults(EventPrincipal const& ep, ModuleCallingContext const*) const;
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Framework/interface/stream/EDAnalyzerAdaptorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace edm {
// ---------- static member functions --------------------

// ---------- member functions ---------------------------
const ModuleDescription moduleDescription() { return moduleDescription_;}
const ModuleDescription& moduleDescription() { return moduleDescription_;}

std::string workerType() const { return "WorkerT<EDAnalyzerAdaptorBase>";}
void
Expand Down
32 changes: 18 additions & 14 deletions FWCore/Framework/src/Worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@ namespace edm {
namespace {
class ModuleBeginJobSignalSentry {
public:
ModuleBeginJobSignalSentry(ActivityRegistry* a, ModuleDescription& md):a_(a), md_(&md) {
ModuleBeginJobSignalSentry(ActivityRegistry* a, ModuleDescription const& md):a_(a), md_(&md) {
if(a_) a_->preModuleBeginJobSignal_(*md_);
}
~ModuleBeginJobSignalSentry() {
if(a_) a_->postModuleBeginJobSignal_(*md_);
}
private:
ActivityRegistry* a_;
ModuleDescription* md_;
ModuleDescription const* md_;
};

class ModuleEndJobSignalSentry {
public:
ModuleEndJobSignalSentry(ActivityRegistry* a, ModuleDescription& md):a_(a), md_(&md) {
ModuleEndJobSignalSentry(ActivityRegistry* a, ModuleDescription const& md):a_(a), md_(&md) {
if(a_) a_->preModuleEndJobSignal_(*md_);
}
~ModuleEndJobSignalSentry() {
if(a_) a_->postModuleEndJobSignal_(*md_);
}
private:
ActivityRegistry* a_;
ModuleDescription* md_;
ModuleDescription const* md_;
};

class ModuleBeginStreamSignalSentry {
Expand Down Expand Up @@ -83,8 +83,7 @@ namespace edm {
timesFailed_(),
timesExcept_(),
state_(Ready),
md_(iMD),
moduleCallingContext_(&md_),
moduleCallingContext_(&iMD),
actions_(iActions),
cached_exception_(),
actReg_(),
Expand All @@ -103,10 +102,15 @@ namespace edm {
earlyDeleteHelper_=iHelper;
}

void Worker::resetModuleDescription(ModuleDescription const* iDesc) {
ModuleCallingContext temp(iDesc,moduleCallingContext_.state(),moduleCallingContext_.parent());
moduleCallingContext_ = temp;
}

void Worker::beginJob() {
try {
try {
ModuleBeginJobSignalSentry cpp(actReg_.get(), md_);
ModuleBeginJobSignalSentry cpp(actReg_.get(), description());
implBeginJob();
}
catch (cms::Exception& e) { throw; }
Expand All @@ -119,7 +123,7 @@ namespace edm {
catch(cms::Exception& ex) {
state_ = Exception;
std::ostringstream ost;
ost << "Calling beginJob for module " << md_.moduleName() << "/'" << md_.moduleLabel() << "'";
ost << "Calling beginJob for module " << description().moduleName() << "/'" << description().moduleLabel() << "'";
ex.addContext(ost.str());
throw;
}
Expand All @@ -128,7 +132,7 @@ namespace edm {
void Worker::endJob() {
try {
try {
ModuleEndJobSignalSentry cpp(actReg_.get(), md_);
ModuleEndJobSignalSentry cpp(actReg_.get(), description());
implEndJob();
}
catch (cms::Exception& e) { throw; }
Expand All @@ -141,7 +145,7 @@ namespace edm {
catch(cms::Exception& ex) {
state_ = Exception;
std::ostringstream ost;
ost << "Calling endJob for module " << md_.moduleName() << "/'" << md_.moduleLabel() << "'";
ost << "Calling endJob for module " << description().moduleName() << "/'" << description().moduleLabel() << "'";
ex.addContext(ost.str());
throw;
}
Expand All @@ -155,7 +159,7 @@ namespace edm {
streamContext.setRunIndex(RunIndex::invalidRunIndex());
streamContext.setLuminosityBlockIndex(LuminosityBlockIndex::invalidLuminosityBlockIndex());
streamContext.setTimestamp(Timestamp());
ModuleBeginStreamSignalSentry beginSentry(actReg_.get(), streamContext, md_);
ModuleBeginStreamSignalSentry beginSentry(actReg_.get(), streamContext, description());
implBeginStream(id);
}
catch (cms::Exception& e) { throw; }
Expand All @@ -168,7 +172,7 @@ namespace edm {
catch(cms::Exception& ex) {
state_ = Exception;
std::ostringstream ost;
ost << "Calling beginStream for module " << md_.moduleName() << "/'" << md_.moduleLabel() << "'";
ost << "Calling beginStream for module " << description().moduleName() << "/'" << description().moduleLabel() << "'";
ex.addContext(ost.str());
throw;
}
Expand All @@ -182,7 +186,7 @@ namespace edm {
streamContext.setRunIndex(RunIndex::invalidRunIndex());
streamContext.setLuminosityBlockIndex(LuminosityBlockIndex::invalidLuminosityBlockIndex());
streamContext.setTimestamp(Timestamp());
ModuleEndStreamSignalSentry endSentry(actReg_.get(), streamContext, md_);
ModuleEndStreamSignalSentry endSentry(actReg_.get(), streamContext, description());
implEndStream(id);
}
catch (cms::Exception& e) { throw; }
Expand All @@ -195,7 +199,7 @@ namespace edm {
catch(cms::Exception& ex) {
state_ = Exception;
std::ostringstream ost;
ost << "Calling endStream for module " << md_.moduleName() << "/'" << md_.moduleLabel() << "'";
ost << "Calling endStream for module " << description().moduleName() << "/'" << description().moduleLabel() << "'";
ex.addContext(ost.str());
throw;
}
Expand Down
12 changes: 6 additions & 6 deletions FWCore/Framework/src/Worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ namespace edm {
void pathFinished(EventPrincipal&);
void postDoEvent(EventPrincipal&);

ModuleDescription const& description() const {return md_;}
ModuleDescription const* descPtr() const {return &md_; }
ModuleDescription const& description() const {return *(moduleCallingContext_.moduleDescription());}
ModuleDescription const* descPtr() const {return moduleCallingContext_.moduleDescription(); }
///The signals are required to live longer than the last call to 'doWork'
/// this was done to improve performance based on profiling
void setActivityRegistry(boost::shared_ptr<ActivityRegistry> areg);
Expand Down Expand Up @@ -148,6 +148,7 @@ namespace edm {
virtual void implBeginStream(StreamID) = 0;
virtual void implEndStream(StreamID) = 0;

void resetModuleDescription(ModuleDescription const*);
private:
virtual void implRespondToOpenInputFile(FileBlock const& fb) = 0;
virtual void implRespondToCloseInputFile(FileBlock const& fb) = 0;
Expand All @@ -164,7 +165,6 @@ namespace edm {
int timesExcept_;
State state_;

ModuleDescription md_;
ModuleCallingContext moduleCallingContext_;

ExceptionToActionTable const* actions_; // memory assumed to be managed elsewhere
Expand All @@ -180,7 +180,7 @@ namespace edm {
class ModuleSignalSentry {
public:
ModuleSignalSentry(ActivityRegistry *a,
ModuleDescription& md,
ModuleDescription const& md,
typename T::Context const* context,
ModuleCallingContext* moduleCallingContext) :
a_(a), md_(&md), context_(context), moduleCallingContext_(moduleCallingContext) {
Expand All @@ -194,7 +194,7 @@ namespace edm {

private:
ActivityRegistry* a_;
ModuleDescription* md_;
ModuleDescription const* md_;
typename T::Context const* context_;
ModuleCallingContext* moduleCallingContext_;
};
Expand Down Expand Up @@ -379,7 +379,7 @@ namespace edm {
ModuleContextSentry moduleContextSentry(&moduleCallingContext_, parentContext);
try {
try {
ModuleSignalSentry<T> cpp(actReg_.get(), md_, context, &moduleCallingContext_);
ModuleSignalSentry<T> cpp(actReg_.get(), description(), context, &moduleCallingContext_);
rc = workerhelper::CallImpl<T>::call(this,streamID,ep,es, &moduleCallingContext_);

if (rc) {
Expand Down
1 change: 1 addition & 0 deletions FWCore/Framework/src/WorkerT.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace edm {

void setModule( T* iModule) {
module_ = iModule;
resetModuleDescription(&(module_->moduleDescription()));
}

virtual Types moduleType() const override;
Expand Down

0 comments on commit ab47016

Please sign in to comment.