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 
0003 import argparse
0004 import sys
0005 
0006 parser = argparse.ArgumentParser(prog=sys.argv[0], description='Test CUDA EDProducers')
0007 
0008 parser.add_argument("--silent", help="Silence printouts", action="store_true")
0009 parser.add_argument("--includeAnalyzer", help="Include an EDAnalyzer", action="store_true")
0010 parser.add_argument("--accelerator", type=str, help="String for accelerator to enable")
0011 
0012 args = parser.parse_args()
0013 
0014 process = cms.Process("Test")
0015 process.load("FWCore.MessageService.MessageLogger_cfi")
0016 process.load("HeterogeneousCore.CUDACore.ProcessAcceleratorCUDA_cfi")
0017 
0018 process.source = cms.Source("EmptySource")
0019 
0020 process.maxEvents.input = 3
0021 if not args.silent:
0022     process.maxEvents.input = 10
0023     process.MessageLogger.cerr.threshold = cms.untracked.string("INFO")
0024     process.MessageLogger.cerr.INFO.limit = process.MessageLogger.cerr.default.limit
0025 
0026 
0027 if args.accelerator is not None:
0028     process.options.accelerators = [args.accelerator]
0029 
0030 # Flow diagram of the modules
0031 #
0032 #     1   5
0033 #    / \  |
0034 #   2  4  6
0035 #   |
0036 #   3
0037 
0038 from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA
0039 
0040 process.load("HeterogeneousCore.CUDATest.prod1Switch_cff")
0041 process.load("HeterogeneousCore.CUDATest.prod5Switch_cff")
0042 process.load("HeterogeneousCore.CUDATest.prod6Switch_cff")
0043 
0044 # GPU producers
0045 from HeterogeneousCore.CUDATest.testCUDAProducerGPUFirst_cfi import testCUDAProducerGPUFirst
0046 from HeterogeneousCore.CUDATest.testCUDAProducerGPU_cfi import testCUDAProducerGPU
0047 from HeterogeneousCore.CUDATest.testCUDAProducerGPUEW_cfi import testCUDAProducerGPUEW
0048 from HeterogeneousCore.CUDATest.testCUDAProducerGPUtoCPU_cfi import testCUDAProducerGPUtoCPU
0049 
0050 process.prod2CUDA = testCUDAProducerGPU.clone(src = "prod1CUDA")
0051 process.prod3CUDA = testCUDAProducerGPU.clone(src = "prod2CUDA")
0052 process.prod4CUDA = testCUDAProducerGPUEW.clone(src = "prod1CUDA")
0053 
0054 # CPU producers, switched with modules to copy data from GPU to CPU
0055 # (as "on demand" as any other EDProducer, i.e. according to
0056 # consumes() and prefetching). If a separate conversion step is needed
0057 # to get the same data formats as the CPU modules, those are then ones
0058 # that should be replaced-with here.
0059 from HeterogeneousCore.CUDATest.testCUDAProducerCPU_cfi import testCUDAProducerCPU
0060 process.prod2 = SwitchProducerCUDA(
0061     cpu = testCUDAProducerCPU.clone(src = "prod1"),
0062     cuda = testCUDAProducerGPUtoCPU.clone(src = "prod2CUDA")
0063 )
0064 process.prod3 = SwitchProducerCUDA(
0065     cpu = testCUDAProducerCPU.clone(src = "prod2"),
0066     cuda = testCUDAProducerGPUtoCPU.clone(src = "prod3CUDA")
0067 )
0068 process.prod4 = SwitchProducerCUDA(
0069     cpu = testCUDAProducerCPU.clone(src = "prod1"),
0070     cuda = testCUDAProducerGPUtoCPU.clone(src = "prod4CUDA")
0071 )
0072 
0073 # GPU analyzer (optionally)
0074 from HeterogeneousCore.CUDATest.testCUDAAnalyzerGPU_cfi import testCUDAAnalyzerGPU
0075 process.anaCUDA = testCUDAAnalyzerGPU.clone(src="prod6CUDA")
0076 if args.silent:
0077     process.anaCUDA.minValue = 2.3e7
0078     process.anaCUDA.maxValue = 2.5e7
0079 
0080 process.out = cms.OutputModule("AsciiOutputModule",
0081     outputCommands = cms.untracked.vstring(
0082         "keep *_prod3_*_*",
0083         "keep *_prod4_*_*",
0084         "keep *_prod6_*_*",
0085     ),
0086     verbosity = cms.untracked.uint32(0),
0087 )
0088 
0089 process.prod2Task = cms.Task(process.prod2, process.prod2CUDA)
0090 process.prod3Task = cms.Task(process.prod3, process.prod3CUDA)
0091 process.prod4Task = cms.Task(process.prod4, process.prod4CUDA)
0092 
0093 process.t = cms.Task(
0094     process.prod1Task,
0095     process.prod2Task,
0096     process.prod3Task,
0097     process.prod4Task,
0098     process.prod5Task,
0099     process.prod6Task
0100 )
0101 process.p = cms.Path()
0102 if args.includeAnalyzer:
0103     process.p += process.anaCUDA
0104 process.p.associate(process.t)
0105 process.ep = cms.EndPath(process.out)