Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpaka-related updates [13.0.x] #40772

Merged
merged 4 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions FWCore/ParameterSet/python/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1538,10 +1538,10 @@ def handleProcessAccelerators(self, parameterSet):
resolved.update(acc)
# Sanity check
if len(invalid) != 0:
raise ValueError("Invalid pattern{} of {} in process.options.accelerators, valid values are {} or a pattern matching to some of them.".format(
raise ValueError("Invalid pattern{} of '{}' in process.options.accelerators, valid values are '{}' or a pattern matching some of them.".format(
"s" if len(invalid) > 2 else "",
",".join(invalid),
",".join(sorted(list(allAccelerators)))))
"', '".join(invalid),
"', '".join(sorted(list(allAccelerators)))))
selectedAccelerators = sorted(list(resolved))
parameterSet.addVString(False, "@selected_accelerators", selectedAccelerators)

Expand Down
2 changes: 1 addition & 1 deletion HeterogeneousCore/AlpakaCore/interface/EventCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace cms::alpakatools {
friend class alpaka_cuda_async::AlpakaService;
#endif
#ifdef ALPAKA_ACC_GPU_HIP_ENABLED
friend class alpaka_hip_async::AlpakaService;
friend class alpaka_rocm_async::AlpakaService;
#endif
#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED
friend class alpaka_serial_sync::AlpakaService;
Expand Down
2 changes: 1 addition & 1 deletion HeterogeneousCore/AlpakaCore/interface/QueueCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace cms::alpakatools {
friend class alpaka_cuda_async::AlpakaService;
#endif
#ifdef ALPAKA_ACC_GPU_HIP_ENABLED
friend class alpaka_hip_async::AlpakaService;
friend class alpaka_rocm_async::AlpakaService;
#endif
#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED
friend class alpaka_serial_sync::AlpakaService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HeterogeneousCore_AlpakaCore_interface_MakerMacros_h
#define HeterogeneousCore_AlpakaCore_interface_MakerMacros_h
#ifndef HeterogeneousCore_AlpakaCore_interface_alpaka_MakerMacros_h
#define HeterogeneousCore_AlpakaCore_interface_alpaka_MakerMacros_h

#include "FWCore/Framework/interface/MakerMacros.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
Expand All @@ -16,4 +16,4 @@
#define DEFINE_FWK_ALPAKA_MODULE(name) DEFINE_FWK_ALPAKA_MODULE2(ALPAKA_ACCELERATOR_NAMESPACE::name)
#endif

#endif // HeterogeneousCore_AlpakaCore_interface_MakerMacros_h
#endif // HeterogeneousCore_AlpakaCore_interface_alpaka_MakerMacros_h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ namespace alpaka_cuda_async {
#endif // ALPAKA_ACC_GPU_CUDA_ENABLED

#ifdef ALPAKA_ACC_GPU_HIP_ENABLED
namespace alpaka_hip_async {
namespace alpaka_rocm_async {
class AlpakaService;
} // namespace alpaka_hip_async
} // namespace alpaka_rocm_async
#endif // ALPAKA_ACC_GPU_HIP_ENABLED

#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace cms::alpakatools {
friend class alpaka_cuda_async::AlpakaService;
#endif
#ifdef ALPAKA_ACC_GPU_HIP_ENABLED
friend class alpaka_hip_async::AlpakaService;
friend class alpaka_rocm_async::AlpakaService;
#endif
#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED
friend class alpaka_serial_sync::AlpakaService;
Expand Down
8 changes: 4 additions & 4 deletions HeterogeneousCore/AlpakaInterface/interface/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace alpaka_cuda_async {
#endif // ALPAKA_ACC_GPU_CUDA_ENABLED

#ifdef ALPAKA_ACC_GPU_HIP_ENABLED
namespace alpaka_hip_async {
namespace alpaka_rocm_async {
using namespace alpaka_common;

using Platform = alpaka::PltfHipRt;
Expand All @@ -79,13 +79,13 @@ namespace alpaka_hip_async {
using Acc2D = Acc<Dim2D>;
using Acc3D = Acc<Dim3D>;

} // namespace alpaka_hip_async
} // namespace alpaka_rocm_async

#ifdef ALPAKA_ACCELERATOR_NAMESPACE
#define ALPAKA_DUPLICATE_NAMESPACE
#else
#define ALPAKA_ACCELERATOR_NAMESPACE alpaka_hip_async
#define ALPAKA_TYPE_SUFFIX HipAsync
#define ALPAKA_ACCELERATOR_NAMESPACE alpaka_rocm_async
#define ALPAKA_TYPE_SUFFIX ROCmAsync
#endif

#endif // ALPAKA_ACC_GPU_HIP_ENABLED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

} // namespace ALPAKA_ACCELERATOR_NAMESPACE

#include "HeterogeneousCore/AlpakaCore/interface/MakerMacros.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/MakerMacros.h"
DEFINE_FWK_ALPAKA_MODULE(TestAlpakaGlobalProducer);
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

} // namespace ALPAKA_ACCELERATOR_NAMESPACE

#include "HeterogeneousCore/AlpakaCore/interface/MakerMacros.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/MakerMacros.h"
DEFINE_FWK_ALPAKA_MODULE(TestAlpakaGlobalProducerOffset);
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

} // namespace ALPAKA_ACCELERATOR_NAMESPACE

#include "HeterogeneousCore/AlpakaCore/interface/MakerMacros.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/MakerMacros.h"
DEFINE_FWK_ALPAKA_MODULE(TestAlpakaProducer);
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

} // namespace ALPAKA_ACCELERATOR_NAMESPACE

#include "HeterogeneousCore/AlpakaCore/interface/MakerMacros.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/MakerMacros.h"
DEFINE_FWK_ALPAKA_MODULE(TestAlpakaStreamProducer);
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

} // namespace ALPAKA_ACCELERATOR_NAMESPACE

#include "HeterogeneousCore/AlpakaCore/interface/MakerMacros.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/MakerMacros.h"
DEFINE_FWK_ALPAKA_MODULE(TestAlpakaStreamSynchronizingProducer);
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