Skip to content

Commit

Permalink
Adopt the "alternative module loading" approach
Browse files Browse the repository at this point in the history
  • Loading branch information
fwyzard committed Feb 15, 2023
1 parent dcc3824 commit 1869351
Showing 1 changed file with 17 additions and 33 deletions.
50 changes: 17 additions & 33 deletions HeterogeneousCore/AlpakaTest/test/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,19 @@
process.source = cms.Source('EmptySource')

process.load('Configuration.StandardSequences.Accelerators_cff')
process.load('HeterogeneousCore.AlpakaCore.ProcessAcceleratorAlpaka_cfi')

# enable logging for the AlpakaService and TestAlpakaAnalyzer
process.MessageLogger.TestAlpakaAnalyzer = cms.untracked.PSet()
process.MessageLogger.AlpakaService = cms.untracked.PSet()

# enable alpaka-based heterogeneous modules
process.AlpakaServiceCudaAsync = cms.Service('AlpakaServiceCudaAsync')
process.AlpakaServiceSerialSync = cms.Service('AlpakaServiceSerialSync')

# run the producer on a CUDA gpu (if available)
process.testProducerCuda = cms.EDProducer('alpaka_cuda_async::TestAlpakaProducer',
size = cms.int32(42)
)

# run the producer on the cpu
process.testProducerCpu = cms.EDProducer('alpaka_serial_sync::TestAlpakaProducer',
size = cms.int32(42)
)

# 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
#
# TODO: the cuda case needs currently explicitly to restrict the
# host-only data products. In the near future the constraints of
# SwichProducer will be relaxed to not consider transient data
# products (as defined in classes_def.xml) after which the explicit
# set of data products can be removed.
process.testProducer = SwitchProducerCUDA(
cpu = cms.EDAlias(
testProducerCpu = cms.VPSet(cms.PSet(type = cms.string('*')))
),
cuda = cms.EDAlias(
testProducerCuda = cms.VPSet(cms.PSet(type = cms.string('128falseportabletestTestSoALayoutPortableHostCollection')))
)
# either run the producer on a gpu (if available) and copy the product to the cpu, or run the producer directly on the cpu
process.testProducer = cms.EDProducer('TestAlpakaProducer@alpaka',
size = cms.int32(42),
# alpaka.backend can be set to a specific backend to force using it, or be omitted or left empty to use the defult backend;
# depending on the architecture and available hardware, the supported backends are "serial_sync", "cuda_async", "rocm_async"
#alpaka = cms.untracked.PSet(
# backend = cms.untracked.string("")
#)
)

# analyse the product
Expand All @@ -50,6 +30,13 @@
process.testProducerSerial = cms.EDProducer('alpaka_serial_sync::TestAlpakaProducer',
size = cms.int32(99)
)
# an alternative approach would be to use
#process.testProducerSerial = cms.EDProducer('TestAlpakaProducer@alpaka',
# size = cms.int32(99),
# alpaka = cms.untracked.PSet(
# backend = cms.untracked.string("serial_sync")
# )
#)

# analyse the second product
process.testAnalyzerSerial = cms.EDAnalyzer('TestAlpakaAnalyzer',
Expand All @@ -66,12 +53,9 @@
)
)

process.producer_task = cms.Task(process.testProducerCuda, process.testProducerCpu)

process.process_path = cms.Path(
process.testProducer +
process.testAnalyzer,
process.producer_task)
process.testAnalyzer)

process.serial_path = cms.Path(
process.testProducerSerial +
Expand Down

0 comments on commit 1869351

Please sign in to comment.