Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-24 02:12:49

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