diff --git a/HeterogeneousCore/AlpakaCore/interface/alpaka/ESProducer.h b/HeterogeneousCore/AlpakaCore/interface/alpaka/ESProducer.h index 4a3b2234fc477..158f597e769bf 100644 --- a/HeterogeneousCore/AlpakaCore/interface/alpaka/ESProducer.h +++ b/HeterogeneousCore/AlpakaCore/interface/alpaka/ESProducer.h @@ -33,6 +33,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { } protected: + ESProducer(edm::ParameterSet const& iConfig); + template auto setWhatProduced(T* iThis, edm::es::Label const& label = {}) { return setWhatProduced(iThis, &T::produce, label); @@ -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; } @@ -129,6 +131,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { } static void throwSomeNullException(); + + std::string const moduleLabel_; + std::string const appendToDataLabel_; }; } // namespace ALPAKA_ACCELERATOR_NAMESPACE diff --git a/HeterogeneousCore/AlpakaCore/src/alpaka/ESProducer.cc b/HeterogeneousCore/AlpakaCore/src/alpaka/ESProducer.cc index 7acedc339607a..c4f7c58a68e1d 100644 --- a/HeterogeneousCore/AlpakaCore/src/alpaka/ESProducer.cc +++ b/HeterogeneousCore/AlpakaCore/src/alpaka/ESProducer.cc @@ -2,6 +2,10 @@ #include "HeterogeneousCore/AlpakaCore/interface/alpaka/ESProducer.h" namespace ALPAKA_ACCELERATOR_NAMESPACE { + ESProducer::ESProducer(edm::ParameterSet const& iConfig) + : moduleLabel_(iConfig.getParameter("@module_label")), + appendToDataLabel_(iConfig.getParameter("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 " diff --git a/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerA.cc b/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerA.cc index e6268397aa922..952b2485d8236 100644 --- a/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerA.cc +++ b/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerA.cc @@ -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(); } diff --git a/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerB.cc b/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerB.cc index 807038d1cef06..63266214cd9b7 100644 --- a/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerB.cc +++ b/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerB.cc @@ -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("explicitLabel")); token_ = cc.consumes(); } diff --git a/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerC.cc b/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerC.cc index 9d0f19a67bd8f..a7f3450f6aeaf 100644 --- a/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerC.cc +++ b/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerC.cc @@ -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(); } diff --git a/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerD.cc b/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerD.cc index a77485c40b8e7..af3512443482e 100644 --- a/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerD.cc +++ b/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaESProducerD.cc @@ -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("srcA")); tokenB_ = cc.consumes(iConfig.getParameter("srcB")); diff --git a/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaGlobalProducer.cc b/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaGlobalProducer.cc index 84afac96b78d3..e068527c2fbf7 100644 --- a/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaGlobalProducer.cc +++ b/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaGlobalProducer.cc @@ -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("eventSetupSource"))), deviceToken_{produces()}, size_{config.getParameter("size").getParameter( EDM_STRINGIZE(ALPAKA_ACCELERATOR_NAMESPACE))} {} @@ -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("alpaka_serial_sync"); diff --git a/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaStreamProducer.cc b/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaStreamProducer.cc index e543a53b0aa0c..da761be224fa4 100644 --- a/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaStreamProducer.cc +++ b/HeterogeneousCore/AlpakaTest/plugins/alpaka/TestAlpakaStreamProducer.cc @@ -27,7 +27,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { : size_{config.getParameter("size").getParameter( EDM_STRINGIZE(ALPAKA_ACCELERATOR_NAMESPACE))} { getToken_ = consumes(config.getParameter("source")); - esToken_ = esConsumes(); + esToken_ = esConsumes(config.getParameter("eventSetupSource")); devicePutToken_ = produces(config.getParameter("productInstanceName")); } @@ -46,6 +46,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add("source"); + desc.add("eventSetupSource", edm::ESInputTag{}); desc.add("productInstanceName", ""); edm::ParameterSetDescription psetSize; diff --git a/HeterogeneousCore/AlpakaTest/test/testAlpakaModules_cfg.py b/HeterogeneousCore/AlpakaTest/test/testAlpakaModules_cfg.py index 67c9db3965da6..47a9fdc4b7474 100644 --- a/HeterogeneousCore/AlpakaTest/test/testAlpakaModules_cfg.py +++ b/HeterogeneousCore/AlpakaTest/test/testAlpakaModules_cfg.py @@ -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"), @@ -64,6 +62,7 @@ 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 @@ -71,6 +70,7 @@ ) 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) @@ -78,6 +78,7 @@ ) 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),