From 2030726945f00313a3c3e26bf392d7fd0a4b86ed Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Thu, 3 Mar 2022 11:22:02 +0100 Subject: [PATCH] Add an option to cmsDriver for selecting the accelerators to use --- Configuration/Applications/python/ConfigBuilder.py | 11 +++++++++++ Configuration/Applications/python/Options.py | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/Configuration/Applications/python/ConfigBuilder.py b/Configuration/Applications/python/ConfigBuilder.py index b0bf7283c0c11..3e3e11fc10da3 100644 --- a/Configuration/Applications/python/ConfigBuilder.py +++ b/Configuration/Applications/python/ConfigBuilder.py @@ -89,6 +89,7 @@ class Options: defaultOptions.nStreams = '0' defaultOptions.nConcurrentLumis = '0' defaultOptions.nConcurrentIOVs = '1' +defaultOptions.accelerators = None # some helper routines def dumpPython(process,name): @@ -2280,6 +2281,16 @@ def prepare(self, doChecking = False): self.process.options.numberOfStreams = int(self._options.nStreams) self.process.options.numberOfConcurrentLuminosityBlocks = int(self._options.nConcurrentLumis) self.process.options.eventSetup.numberOfConcurrentIOVs = int(self._options.nConcurrentIOVs) + + if self._options.accelerators is not None: + accelerators = self._options.accelerators.split(',') + self.pythonCfgCode += "\n" + self.pythonCfgCode += "# Enable only these accelerator backends\n" + self.pythonCfgCode += "process.load('Configuration.StandardSequences.Accelerators_cff')\n" + self.pythonCfgCode += "process.options.accelerators = ['" + "', '".join(accelerators) + "']\n" + self.process.load('Configuration.StandardSequences.Accelerators_cff') + self.process.options.accelerators = accelerators + #repacked version if self._options.isRepacked: self.pythonCfgCode +="\n" diff --git a/Configuration/Applications/python/Options.py b/Configuration/Applications/python/Options.py index 75de94c79c1df..a2671a9dcbbae 100644 --- a/Configuration/Applications/python/Options.py +++ b/Configuration/Applications/python/Options.py @@ -414,3 +414,8 @@ default=defaultOptions.nConcurrentIOVs, dest='nConcurrentIOVs' ) +expertSettings.add_option("--accelerators", + help="Comma-separated list of accelerators to enable; if 'cpu' is not included, the job will fail if none of the accelerators is available (default is not set, enabling all available accelerators, including the cpu)", + default=None, + dest='accelerators' + )