Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-25 23:40:13

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 import os
0004 
0005 class ProcessAcceleratorCUDA(cms.ProcessAccelerator):
0006     def __init__(self):
0007         super(ProcessAcceleratorCUDA,self).__init__()
0008         self._label = "gpu-nvidia"
0009     def labels(self):
0010         return [self._label]
0011     def enabledLabels(self):
0012         enabled = (os.system("cudaIsEnabled") == 0)
0013         if enabled:
0014             return self.labels()
0015         else:
0016             return []
0017     def apply(self, process, accelerators):
0018         if not hasattr(process, "CUDAService"):
0019             from HeterogeneousCore.CUDAServices.CUDAService_cfi import CUDAService
0020             process.add_(CUDAService)
0021 
0022         if not hasattr(process.MessageLogger, "CUDAService"):
0023             process.MessageLogger.CUDAService = cms.untracked.PSet()
0024 
0025         if self._label in accelerators:
0026             process.CUDAService.enabled = True
0027         else:
0028             process.CUDAService.enabled = False
0029             
0030 cms.specialImportRegistry.registerSpecialImportForType(ProcessAcceleratorCUDA, "from HeterogeneousCore.CUDACore.ProcessAcceleratorCUDA import ProcessAcceleratorCUDA")