Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:05:43

0001 import FWCore.ParameterSet.Config as cms
0002 import sys
0003 import argparse
0004 
0005 # This configuration demonstrates how to run an EDProducer on two
0006 # possibly different backends: one is the "portable" and another is
0007 # explicitly a host backend, and how to handle (one model of)
0008 # ESProducer in such case.
0009 
0010 parser = argparse.ArgumentParser(prog=sys.argv[0], description='Test various Alpaka module types')
0011 
0012 parser.add_argument("--expectBackend", type=str, help="Expect this backend to run")
0013 parser.add_argument("--run", type=int, help="Run number (default: 1)", default=1)
0014 
0015 argv = sys.argv[:]
0016 if '--' in argv:
0017     argv.remove("--")
0018 args, unknown = parser.parse_known_args(argv)
0019 
0020 process = cms.Process('TEST')
0021 
0022 process.source = cms.Source('EmptySource',
0023     firstRun = cms.untracked.uint32(args.run)
0024 )
0025 
0026 process.maxEvents.input = 10
0027 
0028 process.load('Configuration.StandardSequences.Accelerators_cff')
0029 process.load('HeterogeneousCore.AlpakaCore.ProcessAcceleratorAlpaka_cfi')
0030 
0031 process.alpakaESRecordASource = cms.ESSource("EmptyESSource",
0032     recordName = cms.string('AlpakaESTestRecordA'),
0033     iovIsRunNotTime = cms.bool(True),
0034     firstValid = cms.vuint32(1)
0035 )
0036 
0037 process.esProducerA = cms.ESProducer("cms::alpakatest::TestESProducerA", value = cms.int32(42))
0038 
0039 process.alpakaESProducerA = cms.ESProducer("TestAlpakaESProducerA@alpaka")
0040 
0041 
0042 process.producer = cms.EDProducer("TestAlpakaGlobalProducerOffset@alpaka",
0043     xvalue = cms.PSet(
0044         alpaka_serial_sync = cms.double(1.0),
0045         alpaka_cuda_async = cms.double(2.0)
0046     )
0047 )
0048 process.producerHost = process.producer.clone(
0049     alpaka = cms.untracked.PSet(
0050         backend = cms.untracked.string("serial_sync")
0051     )
0052 )
0053 
0054 process.compare = cms.EDAnalyzer("TestAlpakaHostDeviceCompare",
0055     srcHost = cms.untracked.InputTag("producerHost"),
0056     srcDevice = cms.untracked.InputTag("producer"),
0057     expectedXdiff = cms.untracked.double(0.0)
0058 )
0059 if args.expectBackend == "cuda_async":
0060     process.compare.expectedXdiff = -1.0
0061 
0062 process.t = cms.Task(process.producer, process.producerHost)
0063 process.p = cms.Path(process.compare, process.t)