CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ProcessAcceleratorCUDA.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 import os
4 
5 class ProcessAcceleratorCUDA(cms.ProcessAccelerator):
6  def __init__(self):
7  super(ProcessAcceleratorCUDA,self).__init__()
8  self._label = "gpu-nvidia"
9  def labels(self):
10  return [self._label]
11  def enabledLabels(self):
12  enabled = (os.system("cudaIsEnabled") == 0)
13  if enabled:
14  return self.labels()
15  else:
16  return []
17  def apply(self, process, accelerators):
18  if not hasattr(process, "CUDAService"):
19  from HeterogeneousCore.CUDAServices.CUDAService_cfi import CUDAService
20  process.add_(CUDAService)
21 
22  if not hasattr(process.MessageLogger, "CUDAService"):
23  process.MessageLogger.CUDAService = cms.untracked.PSet()
24 
25  if self._label in accelerators:
26  process.CUDAService.enabled = True
27  else:
28  process.CUDAService.enabled = False
29 
30 cms.specialImportRegistry.registerSpecialImportForType(ProcessAcceleratorCUDA, "from HeterogeneousCore.CUDACore.ProcessAcceleratorCUDA import ProcessAcceleratorCUDA")