Skip to content

Commit

Permalink
Merge pull request #16292 from knoepfel/CMSSW_8_1_X
Browse files Browse the repository at this point in the history
Cleaning up subProcesses looping.
  • Loading branch information
cmsbuild committed Oct 25, 2016
2 parents 2c2e523 + abe3676 commit 1ba792a
Show file tree
Hide file tree
Showing 9 changed files with 388 additions and 609 deletions.
6 changes: 1 addition & 5 deletions FWCore/Framework/interface/EventProcessor.h
Expand Up @@ -231,10 +231,6 @@ namespace edm {

void setupSignal();

bool hasSubProcesses() const {
return subProcesses_.get() != nullptr && !subProcesses_->empty();
}

void possiblyContinueAfterForkChildFailure();

friend class StreamProcessingTask;
Expand Down Expand Up @@ -279,7 +275,7 @@ namespace edm {
ProcessContext processContext_;
PathsAndConsumesOfModules pathsAndConsumesOfModules_;
edm::propagate_const<std::unique_ptr<Schedule>> schedule_;
edm::propagate_const<std::unique_ptr<std::vector<SubProcess>>> subProcesses_;
std::vector<SubProcess> subProcesses_;
edm::propagate_const<std::unique_ptr<HistoryAppender>> historyAppender_;

edm::propagate_const<std::unique_ptr<FileBlock>> fb_;
Expand Down
101 changes: 31 additions & 70 deletions FWCore/Framework/interface/SubProcess.h
Expand Up @@ -14,6 +14,7 @@
#include "FWCore/ServiceRegistry/interface/ProcessContext.h"
#include "FWCore/ServiceRegistry/interface/ServiceLegacy.h"
#include "FWCore/ServiceRegistry/interface/ServiceToken.h"
#include "FWCore/Utilities/interface/Algorithms.h"
#include "FWCore/Utilities/interface/BranchType.h"
#include "FWCore/Utilities/interface/get_underlying_safe.h"

Expand Down Expand Up @@ -57,9 +58,9 @@ namespace edm {
SubProcess& operator=(SubProcess const&) = delete; // Disallow copying
SubProcess(SubProcess&&) = default; // Allow Moving
SubProcess& operator=(SubProcess&&) = default; // Allow moving

//From OutputModule
void selectProducts(ProductRegistry const& preg,
void selectProducts(ProductRegistry const& preg,
ThinnedAssociationsHelper const& parentThinnedAssociationsHelper,
std::map<BranchID, bool>& keepAssociation);

Expand All @@ -78,18 +79,18 @@ namespace edm {

void doEndLuminosityBlock(LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);


void doBeginStream(unsigned int);
void doEndStream(unsigned int);
void doStreamBeginRun(unsigned int iID, RunPrincipal const& principal, IOVSyncValue const& ts);

void doStreamEndRun(unsigned int iID, RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);

void doStreamBeginLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts);

void doStreamEndLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);


// Write the luminosity block
void writeLumi(ProcessHistoryID const& parentPhID, int runNumber, int lumiNumber);

Expand All @@ -104,33 +105,21 @@ namespace edm {
void closeOutputFiles() {
ServiceRegistry::Operate operate(serviceToken_);
schedule_->closeOutputFiles();
if(hasSubProcesses()) {
for(auto& subProcess : *subProcesses_) {
subProcess.closeOutputFiles();
}
}
for_all(subProcesses_, [](auto& subProcess) { subProcess.closeOutputFiles(); });
}

// Call openNewFileIfNeeded() on all OutputModules
void openNewOutputFilesIfNeeded() {
ServiceRegistry::Operate operate(serviceToken_);
schedule_->openNewOutputFilesIfNeeded();
if(hasSubProcesses()) {
for(auto& subProcess : *subProcesses_) {
subProcess.openNewOutputFilesIfNeeded();
}
}
for_all(subProcesses_, [](auto& subProcess) { subProcess.openNewOutputFilesIfNeeded(); });
}

// Call openFiles() on all OutputModules
void openOutputFiles(FileBlock& fb) {
ServiceRegistry::Operate operate(serviceToken_);
schedule_->openOutputFiles(fb);
if(hasSubProcesses()) {
for(auto& subProcess : *subProcesses_) {
subProcess.openOutputFiles(fb);
}
}
for_all(subProcesses_, [&fb](auto& subProcess) { subProcess.openOutputFiles(fb); });
}

void updateBranchIDListHelper(BranchIDLists const&);
Expand All @@ -142,11 +131,7 @@ namespace edm {
void respondToCloseInputFile(FileBlock const& fb) {
ServiceRegistry::Operate operate(serviceToken_);
schedule_->respondToCloseInputFile(fb);
if(hasSubProcesses()) {
for(auto& subProcess : *subProcesses_) {
subProcess.respondToCloseInputFile(fb);
}
}
for_all(subProcesses_, [&fb](auto& subProcess) { subProcess.respondToCloseInputFile(fb); });
}

// Call shouldWeCloseFile() on all OutputModules.
Expand All @@ -155,11 +140,9 @@ namespace edm {
if(schedule_->shouldWeCloseOutput()) {
return true;
}
if(hasSubProcesses()) {
for(auto const& subProcess : *subProcesses_) {
if(subProcess.shouldWeCloseOutput()) {
return true;
}
for(auto const& subProcess : subProcesses_) {
if(subProcess.shouldWeCloseOutput()) {
return true;
}
}
return false;
Expand All @@ -168,21 +151,13 @@ namespace edm {
void preForkReleaseResources() {
ServiceRegistry::Operate operate(serviceToken_);
schedule_->preForkReleaseResources();
if(hasSubProcesses()) {
for(auto& subProcess : *subProcesses_) {
subProcess.preForkReleaseResources();
}
}
for_all(subProcesses_, [](auto& subProcess){ subProcess.preForkReleaseResources(); });
}

void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) {
ServiceRegistry::Operate operate(serviceToken_);
schedule_->postForkReacquireResources(iChildIndex, iNumberOfChildren);
if(hasSubProcesses()) {
for(auto& subProcess : *subProcesses_) {
subProcess.postForkReacquireResources(iChildIndex, iNumberOfChildren);
}
}
for_all(subProcesses_, [iChildIndex, iNumberOfChildren](auto& subProcess){ subProcess.postForkReacquireResources(iChildIndex, iNumberOfChildren); });
}

/// Return a vector allowing const access to all the ModuleDescriptions for this SubProcess
Expand Down Expand Up @@ -217,11 +192,7 @@ namespace edm {
void enableEndPaths(bool active) {
ServiceRegistry::Operate operate(serviceToken_);
schedule_->enableEndPaths(active);
if(hasSubProcesses()) {
for(auto& subProcess : *subProcesses_) {
subProcess.enableEndPaths(active);
}
}
for_all(subProcesses_, [active](auto& subProcess){ subProcess.enableEndPaths(active); });
}

/// Return true if end_paths are active, and false if they are inactive.
Expand All @@ -244,11 +215,9 @@ namespace edm {
if(schedule_->terminate()) {
return true;
}
if(hasSubProcesses()) {
for(auto const& subProcess : *subProcesses_) {
if(subProcess.terminate()) {
return true;
}
for(auto const& subProcess : subProcesses_) {
if(subProcess.terminate()) {
return true;
}
}
return false;
Expand All @@ -258,21 +227,17 @@ namespace edm {
void clearCounters() {
ServiceRegistry::Operate operate(serviceToken_);
schedule_->clearCounters();
if(hasSubProcesses()) {
for(auto& subProcess : *subProcesses_) {
subProcess.clearCounters();
}
}
for_all(subProcesses_, [](auto& subProcess){ subProcess.clearCounters(); });
}

private:
void beginJob();
void endJob();
void process(EventPrincipal const& e);
void beginRun(RunPrincipal const& r, IOVSyncValue const& ts);
void endRun(RunPrincipal const& r, IOVSyncValue const& ts, bool cleaningUpAfterException);
void beginLuminosityBlock(LuminosityBlockPrincipal const& lb, IOVSyncValue const& ts);
void endLuminosityBlock(LuminosityBlockPrincipal const& lb, IOVSyncValue const& ts, bool cleaningUpAfterException);
void beginJob();
void endJob();
void process(EventPrincipal const& e);
void beginRun(RunPrincipal const& r, IOVSyncValue const& ts);
void endRun(RunPrincipal const& r, IOVSyncValue const& ts, bool cleaningUpAfterException);
void beginLuminosityBlock(LuminosityBlockPrincipal const& lb, IOVSyncValue const& ts);
void endLuminosityBlock(LuminosityBlockPrincipal const& lb, IOVSyncValue const& ts, bool cleaningUpAfterException);

void propagateProducts(BranchType type, Principal const& parentPrincipal, Principal& principal) const;
void fixBranchIDListsForEDAliases(std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID);
Expand All @@ -284,10 +249,6 @@ namespace edm {
return droppedBranchIDToKeptBranchID_;
}

bool hasSubProcesses() const {
return subProcesses_.get() != nullptr && !subProcesses_->empty();
}

std::shared_ptr<BranchIDListHelper const> branchIDListHelper() const {return get_underlying_safe(branchIDListHelper_);}
std::shared_ptr<BranchIDListHelper>& branchIDListHelper() {return get_underlying_safe(branchIDListHelper_);}
std::shared_ptr<ThinnedAssociationsHelper const> thinnedAssociationsHelper() const {return get_underlying_safe(thinnedAssociationsHelper_);}
Expand All @@ -313,7 +274,7 @@ namespace edm {
edm::propagate_const<std::shared_ptr<eventsetup::EventSetupProvider>> esp_;
edm::propagate_const<std::unique_ptr<Schedule>> schedule_;
std::map<ProcessHistoryID, ProcessHistoryID> parentToChildPhID_;
edm::propagate_const<std::unique_ptr<std::vector<SubProcess>>> subProcesses_;
std::vector<SubProcess> subProcesses_;
edm::propagate_const<std::unique_ptr<ParameterSet>> processParameterSet_;

// keptProducts_ are pointers to the BranchDescription objects describing
Expand All @@ -336,6 +297,6 @@ namespace edm {
};

// free function
std::unique_ptr<std::vector<ParameterSet> > popSubProcessVParameterSet(ParameterSet& parameterSet);
std::vector<ParameterSet> popSubProcessVParameterSet(ParameterSet& parameterSet);
}
#endif

0 comments on commit 1ba792a

Please sign in to comment.