-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw a specific, UnavailableAccelerator, exception if requested acce…
…lerator is not available
- Loading branch information
Showing
11 changed files
with
226 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
||
namespace edm { | ||
void ensureAvailableAccelerators(edm::ParameterSet const& parameterSet); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "FWCore/Framework/interface/ensureAvailableAccelerators.h" | ||
#include "FWCore/Utilities/interface/EDMException.h" | ||
|
||
#include <algorithm> | ||
#include <vector> | ||
|
||
namespace edm { | ||
void ensureAvailableAccelerators(edm::ParameterSet const& parameterSet) { | ||
ParameterSet const& optionsPset(parameterSet.getUntrackedParameterSet("options")); | ||
auto accelerators = optionsPset.getUntrackedParameter<std::vector<std::string>>("accelerators"); | ||
if (not accelerators.empty()) { | ||
auto const& availableAccelerators = | ||
parameterSet.getUntrackedParameter<std::vector<std::string>>("@available_accelerators"); | ||
std::sort(accelerators.begin(), accelerators.end()); | ||
std::vector<std::string> unavailableAccelerators; | ||
std::set_difference(accelerators.begin(), | ||
accelerators.end(), | ||
availableAccelerators.begin(), | ||
availableAccelerators.end(), | ||
std::back_inserter(unavailableAccelerators)); | ||
if (not unavailableAccelerators.empty()) { | ||
Exception ex(errors::UnavailableAccelerator); | ||
ex << "Compute accelerators "; | ||
bool first = true; | ||
for (auto const& acc : unavailableAccelerators) { | ||
if (not first) { | ||
ex << ", "; | ||
} else { | ||
first = true; | ||
} | ||
ex << acc; | ||
} | ||
ex << " were requested but are not available in this system."; | ||
throw ex; | ||
} | ||
} | ||
} | ||
} // namespace edm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
test=testProcessAccelerator | ||
LOCAL_TEST_DIR=${CMSSW_BASE}/src/FWCore/Integration/test | ||
LOCAL_TMP_DIR=${CMSSW_BASE}/tmp/${SCRAM_ARCH} | ||
|
||
function die { echo Failure $1: status $2 ; exit $2 ; } | ||
|
||
pushd ${LOCAL_TMP_DIR} | ||
|
||
echo "*************************************************" | ||
echo "accelerators=auto" | ||
cmsRun ${LOCAL_TEST_DIR}/${test}_cfg.py || die "cmsRun ${test}_cfg.py" $? | ||
|
||
echo "*************************************************" | ||
echo "accelerators=auto, enableTest2" | ||
cmsRun ${LOCAL_TEST_DIR}/${test}_cfg.py || die "cmsRun ${test}_cfg.py" $? | ||
|
||
echo "*************************************************" | ||
echo "accelerators=test1" | ||
cmsRun ${LOCAL_TEST_DIR}/${test}_cfg.py -- --accelerators=test1 || die "cmsRun ${test}_cfg.py -- --accelerators=test1" $? | ||
|
||
echo "*************************************************" | ||
echo "accelerators=test2" | ||
cmsRun -j testProcessAccelerators_jobreport.xml ${LOCAL_TEST_DIR}/${test}_cfg.py -- --accelerators=test2 && die "cmsRun ${test}_cfg.py -- --accelerators=test2 did not fail" 1 | ||
EXIT_CODE=$(edmFjrDump --exitCode testProcessAccelerators_jobreport.xml) | ||
if [ "x${EXIT_CODE}" != "x8035" ]; then | ||
echo "ProcessAccelerator test for unavailable accelerator reported exit code ${EXIT_CODE} which is different from the expected 8035" | ||
exit 1 | ||
fi | ||
|
||
echo "*************************************************" | ||
echo "accelerators=test1, enableTest2" | ||
cmsRun ${LOCAL_TEST_DIR}/${test}_cfg.py -- --accelerators=test1 --enableTest2 || die "cmsRun ${test}_cfg.py -- --accelerators=test1 --enableTest2" $? | ||
|
||
echo "*************************************************" | ||
echo "accelerators=test2, enableTest2" | ||
cmsRun ${LOCAL_TEST_DIR}/${test}_cfg.py -- --accelerators=test2 --enableTest2 || die "cmsRun ${test}_cfg.py -- --accelerators=test2 --enableTest2" $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
import argparse | ||
import sys | ||
|
||
parser = argparse.ArgumentParser(prog=sys.argv[0], description='Test ProcessAccelerator.') | ||
|
||
parser.add_argument("--enableTest2", help="Enable test2 accelerator", action="store_true") | ||
parser.add_argument("--accelerators", type=str, help="Comma-separated string for accelerators to enable") | ||
|
||
argv = sys.argv[:] | ||
if '--' in argv: | ||
argv.remove("--") | ||
args, unknown = parser.parse_known_args(argv) | ||
if args.accelerators is not None: | ||
args.accelerators = args.accelerators.split(",") | ||
|
||
class ProcessAcceleratorTest(cms.ProcessAccelerator): | ||
def __init__(self): | ||
super(ProcessAcceleratorTest,self).__init__() | ||
self._labels = ["test1", "test2"] | ||
self._enabled = ["test1"] | ||
if args.enableTest2: | ||
self._enabled.append("test2") | ||
def labels(self): | ||
return self._labels | ||
def enabledLabels(self): | ||
return self._enabled | ||
|
||
class SwitchProducerTest(cms.SwitchProducer): | ||
def __init__(self, **kargs): | ||
super(SwitchProducerTest,self).__init__( | ||
dict( | ||
test1 = lambda accelerators: ("test1" in accelerators, -10), | ||
test2 = lambda accelerators: ("test2" in accelerators, -9), | ||
), **kargs) | ||
|
||
process = cms.Process("PROD1") | ||
|
||
process.add_(ProcessAcceleratorTest()) | ||
|
||
process.source = cms.Source("EmptySource") | ||
process.maxEvents.input = 3 | ||
if args.accelerators is not None: | ||
process.options.accelerators = args.accelerators | ||
|
||
process.intProducer1 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(1)) | ||
process.intProducer2 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(2)) | ||
|
||
if args.enableTest2 and ("test2" in args.accelerators or "auto" in args.accelerators): | ||
process.intProducer1.throw = cms.untracked.bool(True) | ||
else: | ||
process.intProducer2.throw = cms.untracked.bool(True) | ||
|
||
process.intProducer = SwitchProducerTest( | ||
test1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer1")), | ||
test2 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer2")) | ||
) | ||
|
||
process.intConsumer = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer")) | ||
|
||
process.t = cms.Task( | ||
process.intProducer1, | ||
process.intProducer2, | ||
process.intProducer | ||
) | ||
process.p = cms.Path( | ||
process.intConsumer, | ||
process.t | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters