Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 import FWCore.ParameterSet.Config as cms
0002 from HeterogeneousCore.AlpakaCore.functions import *
0003 
0004 process = cms.Process('Writer')
0005 
0006 process.source = cms.Source('EmptySource')
0007 
0008 process.load('Configuration.StandardSequences.Accelerators_cff')
0009 process.load('HeterogeneousCore.AlpakaCore.ProcessAcceleratorAlpaka_cfi')
0010 
0011 # enable logging for the analysers
0012 process.MessageLogger.TestAlpakaAnalyzer = cms.untracked.PSet()
0013 process.MessageLogger.TestAlpakaObjectAnalyzer = cms.untracked.PSet()
0014 
0015 # either run the producer on a gpu (if available) and copy the product to the cpu, or run the producer directly on the cpu
0016 process.testProducer = cms.EDProducer('TestAlpakaProducer@alpaka',
0017     size = cms.int32(42),
0018     size2 = cms.int32(33),
0019     size3 = cms.int32(61)
0020     # alpaka.backend can be set to a specific backend to force using it, or be omitted or left empty to use the defult backend;
0021     # depending on the architecture and available hardware, the supported backends are "serial_sync", "cuda_async", "rocm_async"
0022     #alpaka = cms.untracked.PSet(
0023     #    backend = cms.untracked.string("")
0024     #)
0025 )
0026 
0027 # analyse the first set of products
0028 process.testAnalyzer = cms.EDAnalyzer('TestAlpakaAnalyzer',
0029     source = cms.InputTag('testProducer')
0030 )
0031 
0032 process.testObjectAnalyzer = cms.EDAnalyzer('TestAlpakaObjectAnalyzer',
0033     source = cms.InputTag('testProducer')
0034 )
0035 
0036 # run a second producer explicitly on the cpu
0037 process.testProducerSerial = makeSerialClone(process.testProducer,
0038     size = cms.int32(99),
0039     size2 = cms.int32(51),
0040     size3 = cms.int32(43)
0041 )
0042 
0043 # analyse the second set of products
0044 process.testAnalyzerSerial = cms.EDAnalyzer('TestAlpakaAnalyzer',
0045     source = cms.InputTag('testProducerSerial'),
0046     expectBackend = cms.string('SerialSync')
0047 )
0048 
0049 process.testObjectAnalyzerSerial = cms.EDAnalyzer('TestAlpakaObjectAnalyzer',
0050     source = cms.InputTag('testProducerSerial'),
0051     expectBackend = cms.string('SerialSync')
0052 )
0053 
0054 # write all products to a 'test.root' file
0055 process.output = cms.OutputModule('PoolOutputModule',
0056     fileName = cms.untracked.string('test.root'),
0057     outputCommands = cms.untracked.vstring('keep *')
0058 )
0059 
0060 process.process_path = cms.Path(
0061     process.testProducer +
0062     process.testAnalyzer +
0063     process.testObjectAnalyzer)
0064 
0065 process.serial_path = cms.Path(
0066     process.testProducerSerial +
0067     process.testAnalyzerSerial +
0068     process.testObjectAnalyzerSerial)
0069 
0070 process.output_path = cms.EndPath(process.output)
0071 
0072 process.maxEvents.input = 10