Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-15 01:07:43

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 AlpakaService and TestAlpakaAnalyzer
0011 process.MessageLogger.TestAlpakaAnalyzer = cms.untracked.PSet()
0012 process.MessageLogger.AlpakaService = cms.untracked.PSet()
0013 
0014 # enable alpaka-based heterogeneous modules
0015 process.AlpakaServiceCudaAsync = cms.Service('AlpakaServiceCudaAsync')
0016 process.AlpakaServiceSerialSync = cms.Service('AlpakaServiceSerialSync')
0017 
0018 # run the producer on a CUDA gpu (if available)
0019 process.testProducerCuda = cms.EDProducer('alpaka_cuda_async::TestAlpakaProducer',
0020     size = cms.int32(42)
0021 )
0022 
0023 # copy the product from the gpu (if available) to the host
0024 process.testTranscriberFromCuda = cms.EDProducer('alpaka_cuda_async::TestAlpakaTranscriber',
0025     source = cms.InputTag('testProducerCuda')
0026 )
0027 
0028 # run the producer on the cpu
0029 process.testProducerCpu = cms.EDProducer('alpaka_serial_sync::TestAlpakaProducer',
0030     size = cms.int32(42)
0031 )
0032 
0033 # extract the cpu product from the heterogeneous wrapper
0034 process.testTranscriberFromCpu = cms.EDProducer('alpaka_serial_sync::TestAlpakaTranscriber',
0035     source = cms.InputTag('testProducerCpu')
0036 )
0037 
0038 # 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
0039 process.testProducer = SwitchProducerCUDA(
0040     cpu = cms.EDAlias(
0041         testTranscriberFromCpu = cms.VPSet(cms.PSet(type = cms.string('*')))
0042     ),
0043     cuda = cms.EDAlias(
0044         testTranscriberFromCuda = cms.VPSet(cms.PSet(type = cms.string('*')))
0045     )
0046 )
0047 
0048 # analyse the product
0049 process.testAnalyzer = cms.EDAnalyzer('TestAlpakaAnalyzer',
0050     source = cms.InputTag('testProducer')
0051 )
0052 
0053 # run a second producer explicitly on the cpu
0054 process.testProducerSerial = cms.EDProducer('alpaka_serial_sync::TestAlpakaProducer',
0055     size = cms.int32(99)
0056 )
0057 
0058 # extract the cpu product from the heterogeneous wrapper
0059 process.testTranscriberSerial = cms.EDProducer('alpaka_serial_sync::TestAlpakaTranscriber',
0060     source = cms.InputTag('testProducerSerial')
0061 )
0062 
0063 # analyse the second product
0064 process.testAnalyzerSerial = cms.EDAnalyzer('TestAlpakaAnalyzer',
0065     source = cms.InputTag('testTranscriberSerial')
0066 )
0067 
0068 # write the two products to a 'test.root' file
0069 process.output = cms.OutputModule('PoolOutputModule',
0070     fileName = cms.untracked.string('test.root'),
0071     outputCommands = cms.untracked.vstring(
0072         'drop *',
0073         'keep *_testProducer_*_*',
0074         'keep *_testTranscriberSerial_*_*',
0075   )
0076 )
0077 
0078 process.producer_task = cms.Task(process.testProducerCuda, process.testTranscriberFromCuda, process.testProducerCpu, process.testTranscriberFromCpu)
0079 
0080 process.process_path = cms.Path(
0081     process.testProducer +
0082     process.testAnalyzer,
0083     process.producer_task)
0084 
0085 process.serial_path = cms.Path(
0086     process.testProducerSerial +
0087     process.testTranscriberSerial +
0088     process.testAnalyzerSerial)
0089 
0090 process.output_path = cms.EndPath(process.output)
0091 
0092 process.maxEvents.input = 10