Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:15:44

0001 import FWCore.ParameterSet.Config as cms
0002 from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA
0003 
0004 process = cms.Process('Writer')
0005 
0006 process.source = cms.Source('EmptySource')
0007 
0008 process.load('Configuration.StandardSequences.Accelerators_cff')
0009 
0010 # enable logging for the TestPortableAnalyzer
0011 process.MessageLogger.TestPortableAnalyzer = cms.untracked.PSet()
0012 
0013 # run the producer on a CUDA gpu (if available)
0014 process.testProducerCuda = cms.EDProducer('TestPortableProducerCUDA',
0015     size = cms.int32(42)
0016 )
0017 
0018 # copy the product from the gpu (if available) to the host
0019 process.testTranscriberFromCuda = cms.EDProducer('TestPortableTranscriber',
0020     source = cms.InputTag('testProducerCuda')
0021 )
0022 
0023 # run the producer on the cpu
0024 process.testProducerCpu = cms.EDProducer('TestPortableProducerCPU',
0025     size = cms.int32(42)
0026 )
0027 
0028 # either run the producer on a CUDA gpu (if available) and copy the product to the cpu, or run the producer directly on the cpu
0029 process.testProducer = SwitchProducerCUDA(
0030     cpu = cms.EDAlias(
0031         testProducerCpu = cms.VPSet(cms.PSet(type = cms.string('*')))
0032     ),
0033     cuda = cms.EDAlias(
0034         testTranscriberFromCuda = cms.VPSet(cms.PSet(type = cms.string('*')))
0035     )
0036 )
0037 
0038 # analyse the product
0039 process.testAnalyzer = cms.EDAnalyzer('TestPortableAnalyzer',
0040     source = cms.InputTag('testProducer')
0041 )
0042 
0043 # run a second producer explicitly on the cpu
0044 process.testProducerSerial = cms.EDProducer('TestPortableProducerCPU',
0045     size = cms.int32(99)
0046 )
0047 
0048 # analyse the second product
0049 process.testAnalyzerSerial = cms.EDAnalyzer('TestPortableAnalyzer',
0050     source = cms.InputTag('testProducerSerial')
0051 )
0052 
0053 # write the two products to a 'test.root' file
0054 process.output = cms.OutputModule('PoolOutputModule',
0055     fileName = cms.untracked.string('test.root'),
0056     outputCommands = cms.untracked.vstring(
0057         'drop *',
0058         'keep *_testProducer_*_*',
0059         'keep *_testProducerSerial_*_*',
0060   )
0061 )
0062 
0063 process.producer_task = cms.Task(process.testProducerCuda, process.testTranscriberFromCuda, process.testProducerCpu)
0064 
0065 process.process_path = cms.Path(
0066     process.testProducer +
0067     process.testAnalyzer,
0068     process.producer_task)
0069 
0070 process.serial_path = cms.Path(
0071     process.testProducerSerial +
0072     process.testAnalyzerSerial)
0073 
0074 process.output_path = cms.EndPath(process.output)
0075 
0076 process.maxEvents.input = 10