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

[13_0_X] Fix implicit host-to-device copy for ES data products with labels in Alpaka ESProducers #41038

Merged
merged 1 commit into from
Mar 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
7 changes: 6 additions & 1 deletion HeterogeneousCore/AlpakaCore/interface/alpaka/ESProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
}

protected:
ESProducer(edm::ParameterSet const& iConfig);

template <typename T>
auto setWhatProduced(T* iThis, edm::es::Label const& label = {}) {
return setWhatProduced(iThis, &T::produce, label);
Expand All @@ -52,7 +54,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
return std::optional{CopyT::copyAsync(iRecord.queue(), *handle)};
},
label);
*tokenPtr = ccDev.consumes();
*tokenPtr = ccDev.consumes(edm::ESInputTag{moduleLabel_, label.default_ + appendToDataLabel_});
}
return cc;
}
Expand Down Expand Up @@ -129,6 +131,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
}

static void throwSomeNullException();

std::string const moduleLabel_;
std::string const appendToDataLabel_;
};
} // namespace ALPAKA_ACCELERATOR_NAMESPACE

Expand Down
4 changes: 4 additions & 0 deletions HeterogeneousCore/AlpakaCore/src/alpaka/ESProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/ESProducer.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE {
ESProducer::ESProducer(edm::ParameterSet const& iConfig)
: moduleLabel_(iConfig.getParameter<std::string>("@module_label")),
appendToDataLabel_(iConfig.getParameter<std::string>("appendToDataLabel")) {}

void ESProducer::throwSomeNullException() {
throw edm::Exception(edm::errors::UnimplementedFeature)
<< "The Alpaka backend has multiple devices. The device-specific produce() function returned a null product "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
*/
class TestAlpakaESProducerA : public ESProducer {
public:
TestAlpakaESProducerA(edm::ParameterSet const& iConfig) {
TestAlpakaESProducerA(edm::ParameterSet const& iConfig) : ESProducer(iConfig) {
auto cc = setWhatProduced(this);
token_ = cc.consumes();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
*/
class TestAlpakaESProducerB : public ESProducer {
public:
TestAlpakaESProducerB(edm::ParameterSet const& iConfig) {
TestAlpakaESProducerB(edm::ParameterSet const& iConfig) : ESProducer(iConfig) {
auto cc = setWhatProduced(this, iConfig.getParameter<std::string>("explicitLabel"));
token_ = cc.consumes();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
*/
class TestAlpakaESProducerC : public ESProducer {
public:
TestAlpakaESProducerC(edm::ParameterSet const& iConfig) {
TestAlpakaESProducerC(edm::ParameterSet const& iConfig) : ESProducer(iConfig) {
auto cc = setWhatProduced(this);
token_ = cc.consumes();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
*/
class TestAlpakaESProducerD : public ESProducer {
public:
TestAlpakaESProducerD(edm::ParameterSet const& iConfig) {
TestAlpakaESProducerD(edm::ParameterSet const& iConfig) : ESProducer(iConfig) {
auto cc = setWhatProduced(this);
tokenA_ = cc.consumes(iConfig.getParameter<edm::ESInputTag>("srcA"));
tokenB_ = cc.consumes(iConfig.getParameter<edm::ESInputTag>("srcB"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
class TestAlpakaGlobalProducer : public global::EDProducer<> {
public:
TestAlpakaGlobalProducer(edm::ParameterSet const& config)
: esToken_(esConsumes()),
: esToken_(esConsumes(config.getParameter<edm::ESInputTag>("eventSetupSource"))),
deviceToken_{produces()},
size_{config.getParameter<edm::ParameterSet>("size").getParameter<int32_t>(
EDM_STRINGIZE(ALPAKA_ACCELERATOR_NAMESPACE))} {}
Expand All @@ -39,6 +39,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add("eventSetupSource", edm::ESInputTag{});

edm::ParameterSetDescription psetSize;
psetSize.add<int32_t>("alpaka_serial_sync");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
: size_{config.getParameter<edm::ParameterSet>("size").getParameter<int32_t>(
EDM_STRINGIZE(ALPAKA_ACCELERATOR_NAMESPACE))} {
getToken_ = consumes(config.getParameter<edm::InputTag>("source"));
esToken_ = esConsumes();
esToken_ = esConsumes(config.getParameter<edm::ESInputTag>("eventSetupSource"));
devicePutToken_ = produces(config.getParameter<std::string>("productInstanceName"));
}

Expand All @@ -46,6 +46,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("source");
desc.add("eventSetupSource", edm::ESInputTag{});
desc.add<std::string>("productInstanceName", "");

edm::ParameterSetDescription psetSize;
Expand Down
9 changes: 5 additions & 4 deletions HeterogeneousCore/AlpakaTest/test/testAlpakaModules_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@
process.esProducerC = cms.ESProducer("cms::alpakatest::TestESProducerC", value = cms.int32(27))

from HeterogeneousCore.AlpakaTest.testAlpakaESProducerA_cfi import testAlpakaESProducerA
process.alpakaESProducerA = testAlpakaESProducerA.clone()
process.alpakaESProducerAdataLabel = process.alpakaESProducerA.clone(appendToDataLabel = cms.string("appendedLabel"))
process.alpakaESProducerB = cms.ESProducer("TestAlpakaESProducerB@alpaka")
process.alpakaESProducerBexplicitLabel = process.alpakaESProducerB.clone(explicitLabel = cms.string("explicitLabel"))
process.alpakaESProducerA = testAlpakaESProducerA.clone(appendToDataLabel = cms.string("appendedLabel"))
process.alpakaESProducerB = cms.ESProducer("TestAlpakaESProducerB@alpaka", explicitLabel = cms.string("explicitLabel"))
process.alpakaESProducerC = cms.ESProducer("TestAlpakaESProducerC@alpaka")
process.alpakaESProducerD = cms.ESProducer("TestAlpakaESProducerD@alpaka",
srcA = cms.ESInputTag("", "appendedLabel"),
Expand All @@ -64,20 +62,23 @@

from HeterogeneousCore.AlpakaTest.testAlpakaGlobalProducer_cfi import testAlpakaGlobalProducer
process.alpakaGlobalProducer = testAlpakaGlobalProducer.clone(
eventSetupSource = cms.ESInputTag("alpakaESProducerA", "appendedLabel"),
size = dict(
alpaka_serial_sync = 10,
alpaka_cuda_async = 20
)
)
process.alpakaStreamProducer = cms.EDProducer("TestAlpakaStreamProducer@alpaka",
source = cms.InputTag("intProduct"),
eventSetupSource = cms.ESInputTag("alpakaESProducerB", "explicitLabel"),
size = cms.PSet(
alpaka_serial_sync = cms.int32(5),
alpaka_cuda_async = cms.int32(25)
)
)
process.alpakaStreamInstanceProducer = cms.EDProducer("TestAlpakaStreamProducer@alpaka",
source = cms.InputTag("intProduct"),
eventSetupSource = cms.ESInputTag("alpakaESProducerB", "explicitLabel"),
productInstanceName = cms.string("testInstance"),
size = cms.PSet(
alpaka_serial_sync = cms.int32(6),
Expand Down