CMS 3D CMS Logo

SwitchProducerCUDA.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 def _switch_cuda(useAccelerators):
4  have_gpu = ("gpu-nvidia" in useAccelerators)
5  return (have_gpu, 2)
6 
7 class SwitchProducerCUDA(cms.SwitchProducer):
8  def __init__(self, **kargs):
9  super(SwitchProducerCUDA,self).__init__(
10  dict(cpu = cms.SwitchProducer.getCpu(),
11  cuda = _switch_cuda),
12  **kargs
13  )
14 cms.specialImportRegistry.registerSpecialImportForType(SwitchProducerCUDA, "from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA")
15 
16 if __name__ == "__main__":
17  import unittest
18 
19  class TestSwitchProducerCUDA(unittest.TestCase):
20  def testPickle(self):
21  import pickle
22  sp = SwitchProducerCUDA(cpu = cms.EDProducer("Foo"), cuda = cms.EDProducer("Bar"))
23  pkl = pickle.dumps(sp)
24  unpkl = pickle.loads(pkl)
25  self.assertEqual(unpkl.cpu.type_(), "Foo")
26  self.assertEqual(unpkl.cuda.type_(), "Bar")
27 
28  unittest.main()
29 
def _switch_cuda(useAccelerators)