1 import FWCore.ParameterSet.Config
as cms
5 from HeterogeneousCore.Common.PlatformStatus
import PlatformStatus
11 if "gpu-nvidia" in accelerators:
13 if "gpu-amd" in accelerators:
15 if "cpu" in accelerators:
18 raise cms.EDMException(cms.edm.errors.UnavailableAccelerator,
"ModuleTypeResolverAlpaka had no backends available because of the combination of the job configuration and accelerator availability of on the machine. The job sees {} accelerators.".
format(
", ".
join(accelerators)))
19 if backend
is not None:
21 raise cms.EDMException(cms.edm.errors.UnavailableAccelerator,
"The ProcessAcceleratorAlpaka was configured to use {} backend, but that backend is not available because of the combination of the job configuration and accelerator availability on the machine. The job was configured to use {} accelerators, which translates to {} Alpaka backends.".
format(
28 return "ModuleTypeResolverAlpaka" 31 if module.type_().endswith(
"@alpaka"):
33 if hasattr(module,
"alpaka"):
34 if hasattr(module.alpaka,
"backend"):
35 if module.alpaka.backend ==
"":
36 module.alpaka.backend = defaultBackend
38 raise cms.EDMException(cms.edm.errors.UnavailableAccelerator,
"Module {} has the Alpaka backend set explicitly, but its accelerator is not available for the job because of the combination of the job configuration and accelerator availability on the machine. The following Alpaka backends are available for the job {}.".
format(module.label_(),
", ".
join(self.
_valid_backends)))
40 module.alpaka.backend = cms.untracked.string(defaultBackend)
42 module.alpaka = cms.untracked.PSet(
43 backend = cms.untracked.string(defaultBackend)
47 """ProcessAcceleratorAlpaka itself does not define or inspect 48 availability of any accelerator devices. It merely sets up 49 necessary Alpaka infrastructure based on the availability of 50 accelerators that the concrete ProcessAccelerators (like 51 ProcessAcceleratorCUDA) define. 54 super(ProcessAcceleratorAlpaka, self).
__init__()
65 def apply(self, process, accelerators):
67 if not hasattr(process.MessageLogger,
"AlpakaService"):
68 process.MessageLogger.AlpakaService = cms.untracked.PSet()
72 if not "cpu" in accelerators:
74 from HeterogeneousCore.AlpakaServices.AlpakaServiceSerialSync_cfi
import AlpakaServiceSerialSync
77 if hasattr(process,
"AlpakaServiceSerialSync"):
78 del process.AlpakaServiceSerialSync
81 if not hasattr(process,
"AlpakaServiceSerialSync"):
82 process.add_(AlpakaServiceSerialSync)
86 if not "gpu-nvidia" in accelerators:
88 from HeterogeneousCore.AlpakaServices.AlpakaServiceCudaAsync_cfi
import AlpakaServiceCudaAsync
91 if hasattr(process,
"AlpakaServiceCudaAsync"):
92 del process.AlpakaServiceCudaAsync
95 if not hasattr(process,
"AlpakaServiceCudaAsync"):
96 process.add_(AlpakaServiceCudaAsync)
100 if not "gpu-amd" in accelerators:
102 from HeterogeneousCore.AlpakaServices.AlpakaServiceROCmAsync_cfi
import AlpakaServiceROCmAsync
105 if hasattr(process,
"AlpakaServiceROCmAsync"):
106 del process.AlpakaServiceROCmAsync
109 if not hasattr(process,
"AlpakaServiceROCmAsync"):
110 process.add_(AlpakaServiceROCmAsync)
114 cms.specialImportRegistry.registerSpecialImportForType(ProcessAcceleratorAlpaka,
"from HeterogeneousCore.AlpakaCore.ProcessAcceleratorAlpaka import ProcessAcceleratorAlpaka")
def setBackend(self, backend)
def __init__(self, accelerators, backend)
def setModuleVariant(self, module)
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
static std::string join(char **cmd)
def moduleTypeResolver(self, accelerators)
def remove(d, key, TELL=False)
def apply(self, process, accelerators)