Skip to content

Commit

Permalink
Add configuration parameter to allow disabling the module deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
makortel committed Oct 2, 2020
1 parent 9c053f9 commit c38022d
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 16 deletions.
1 change: 1 addition & 0 deletions FWCore/Framework/interface/EventProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ namespace edm {
ExcludedDataMap eventSetupDataToExcludeFromPrefetching_;

bool printDependencies_ = false;
bool deleteNonConsumedUnscheduledModules_ = true;
}; // class EventProcessor

//--------------------------------------------------------------------
Expand Down
37 changes: 21 additions & 16 deletions FWCore/Framework/src/EventProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ namespace edm {
IllegalParameters::setThrowAnException(optionsPset.getUntrackedParameter<bool>("throwIfIllegalParameter"));

printDependencies_ = optionsPset.getUntrackedParameter<bool>("printDependencies");
deleteNonConsumedUnscheduledModules_ =
optionsPset.getUntrackedParameter<bool>("deleteNonConsumedUnscheduledModules");

// Now do general initialization
ScheduleItems items;
Expand Down Expand Up @@ -433,6 +435,8 @@ namespace edm {
nStreams = 1;
nConcurrentLumis = 1;
nConcurrentRuns = 1;
// in presence of looper do not delete modules
deleteNonConsumedUnscheduledModules_ = false;
}
espController_->setMaxConcurrentIOVs(nStreams, nConcurrentLumis);

Expand Down Expand Up @@ -548,26 +552,27 @@ namespace edm {
schedule_->convertCurrentProcessAlias(processConfiguration_->processName());
pathsAndConsumesOfModules_.initialize(schedule_.get(), preg());

// in presence of looper do not delete modules
bool const deleteModules = not looper_;

std::vector<ModuleProcessName> consumedBySubProcesses;
for_all(subProcesses_, [&consumedBySubProcesses, deleteModules](auto& subProcess) {
auto c = subProcess.keepOnlyConsumedUnscheduledModules(deleteModules);
if (consumedBySubProcesses.empty()) {
consumedBySubProcesses = std::move(c);
} else if (not c.empty()) {
std::vector<ModuleProcessName> tmp;
tmp.reserve(consumedBySubProcesses.size() + c.size());
std::merge(
consumedBySubProcesses.begin(), consumedBySubProcesses.end(), c.begin(), c.end(), std::back_inserter(tmp));
std::swap(consumedBySubProcesses, tmp);
}
});
for_all(subProcesses_,
[&consumedBySubProcesses, deleteModules = deleteNonConsumedUnscheduledModules_](auto& subProcess) {
auto c = subProcess.keepOnlyConsumedUnscheduledModules(deleteModules);
if (consumedBySubProcesses.empty()) {
consumedBySubProcesses = std::move(c);
} else if (not c.empty()) {
std::vector<ModuleProcessName> tmp;
tmp.reserve(consumedBySubProcesses.size() + c.size());
std::merge(consumedBySubProcesses.begin(),
consumedBySubProcesses.end(),
c.begin(),
c.end(),
std::back_inserter(tmp));
std::swap(consumedBySubProcesses, tmp);
}
});

// Note: all these may throw
checkForModuleDependencyCorrectness(pathsAndConsumesOfModules_, printDependencies_);
if (deleteModules) {
if (deleteNonConsumedUnscheduledModules_) {
if (auto const unusedModules = nonConsumedUnscheduledModules(pathsAndConsumesOfModules_, consumedBySubProcesses);
not unusedModules.empty()) {
pathsAndConsumesOfModules_.removeModules(unusedModules);
Expand Down
2 changes: 2 additions & 0 deletions FWCore/Framework/test/run_module_delete_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ cmsRun $TEST_DIR/test_module_delete_looper_cfg.py || die "module deletetion test
echo "module deletion test with looper succeeded"
cmsRun $TEST_DIR/test_module_delete_dependencygraph_cfg.py || die "module deletetion test with DependencyGraph failed" $?
echo "module deletion test with DependencyGraph succeeded"
cmsRun $TEST_DIR/test_module_delete_disable_cfg.py || die "module deletetion test with disabling the deletion failed" $?
echo "module deletion test with disabling the deletion succeeded"
26 changes: 26 additions & 0 deletions FWCore/Framework/test/test_module_delete_disable_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("TESTMODULEDELETE")

process.maxEvents.input = 1
process.options.deleteNonConsumedUnscheduledModules = False
process.source = cms.Source("EmptySource")

process.intEventProducer = cms.EDProducer("IntProducer", ivalue = cms.int32(1))
process.intEventConsumer = cms.EDAnalyzer("IntTestAnalyzer",
moduleLabel = cms.untracked.InputTag("intEventProducer"),
valueMustMatch = cms.untracked.int32(1)
)
process.intProducerNotConsumed = cms.EDProducer("edmtest::MustRunIntProducer",
ivalue = cms.int32(1),
mustRunEvent = cms.bool(False)
)

process.t = cms.Task(
process.intEventProducer,
process.intProducerNotConsumed
)
process.p = cms.Path(
process.intEventConsumer,
process.t
)
2 changes: 2 additions & 0 deletions FWCore/ParameterSet/python/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def defaultOptions_():
forceEventSetupCacheClearOnNewRun = untracked.bool(False),
throwIfIllegalParameter = untracked.bool(True),
printDependencies = untracked.bool(False),
deleteNonConsumedUnscheduledModules = untracked.bool(True),
sizeOfStackForThreadsInKB = optional.untracked.uint32,
Rethrow = untracked.vstring(),
SkipEvent = untracked.vstring(),
Expand Down Expand Up @@ -2008,6 +2009,7 @@ def testProcessDumpPython(self):
SkipEvent = cms.untracked.vstring(),
allowUnscheduled = cms.obsolete.untracked.bool,
canDeleteEarly = cms.untracked.vstring(),
deleteNonConsumedUnscheduledModules = cms.untracked.bool(True),
emptyRunLumiMode = cms.obsolete.untracked.string,
eventSetup = cms.untracked.PSet(
forceNumberOfConcurrentIOVs = cms.untracked.PSet(
Expand Down
4 changes: 4 additions & 0 deletions FWCore/ParameterSet/src/validateTopLevelParameterSets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ namespace edm {
description.addUntracked<bool>("throwIfIllegalParameter", true)
->setComment("Set false to disable exception throws when configuration validation detects illegal parameters");
description.addUntracked<bool>("printDependencies", false)->setComment("Print data dependencies between modules");
description.addUntracked<bool>("deleteNonConsumedUnscheduledModules", true)
->setComment(
"Delete modules that are unscheduled, i.e. only in Tasks, whose products are not consumed by any other "
"otherwise-running module");

// No default for this one because the parameter value is
// actually used in the main function in cmsRun.cpp before
Expand Down

0 comments on commit c38022d

Please sign in to comment.