From 2d853ef128f8d69666e0ff443ba9197d392cab7d Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Tue, 9 Apr 2024 20:13:31 +0200 Subject: [PATCH] Workaround to produce exactly same data products in Serial and CUDA backends in Alpaka modules possibly used at HLT To be reverted in the near future after the necessary metadata to deal with different ProductIDs in different HLT processes (CPU-only vs. CPU+GPU) gets propagated to the framework. --- .../plugins/alpaka/EcalRawToDigiPortable.cc | 8 ++++++++ .../AlpakaCore/interface/alpaka/ProducerBase.h | 6 ++++++ .../plugins/alpaka/EcalUncalibRecHitProducerPortable.cc | 8 ++++++++ .../plugins/alpaka/SiPixelRawToCluster.cc | 7 +++++++ .../SiPixelRecHits/plugins/alpaka/SiPixelRecHitAlpaka.cc | 9 ++++++++- .../plugins/alpaka/PFClusterSoAProducer.cc | 8 +++++++- .../plugins/alpaka/CaloRecHitSoAProducer.cc | 7 ++++++- .../plugins/alpaka/PFRecHitSoAProducer.cc | 5 +++++ RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtuplet.cc | 9 ++++++++- .../plugins/alpaka/PixelVertexProducerAlpaka.cc | 7 ++++++- .../plugins/alpaka/BeamSpotDeviceProducer.cc | 7 ++++++- 11 files changed, 75 insertions(+), 6 deletions(-) diff --git a/EventFilter/EcalRawToDigi/plugins/alpaka/EcalRawToDigiPortable.cc b/EventFilter/EcalRawToDigi/plugins/alpaka/EcalRawToDigiPortable.cc index 7739cf15c0ab3..2722942f25b97 100644 --- a/EventFilter/EcalRawToDigi/plugins/alpaka/EcalRawToDigiPortable.cc +++ b/EventFilter/EcalRawToDigi/plugins/alpaka/EcalRawToDigiPortable.cc @@ -64,6 +64,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { fedsToUnpack_{ps.getParameter>("FEDs")} { config_.maxChannelsEB = ps.getParameter("maxChannelsEB"); config_.maxChannelsEE = ps.getParameter("maxChannelsEE"); + + // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed +#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED + producesTemporarily("edm::DeviceProduct", + ps.getParameter("digisLabelEB")); + producesTemporarily("edm::DeviceProduct", + ps.getParameter("digisLabelEE")); +#endif } void EcalRawToDigiPortable::produce(device::Event& event, device::EventSetup const& setup) { diff --git a/HeterogeneousCore/AlpakaCore/interface/alpaka/ProducerBase.h b/HeterogeneousCore/AlpakaCore/interface/alpaka/ProducerBase.h index 25088489ad89f..b0f2d50011ef0 100644 --- a/HeterogeneousCore/AlpakaCore/interface/alpaka/ProducerBase.h +++ b/HeterogeneousCore/AlpakaCore/interface/alpaka/ProducerBase.h @@ -58,6 +58,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { return ProducerBaseAdaptor(*this, std::move(instanceName)); } + // For a workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed + void producesTemporarily(std::string const& iTypeName, std::string instanceName = std::string()) { + auto td = edm::TypeWithDict::byName(iTypeName); + Base::template produces(edm::TypeID(td.typeInfo()), std::move(instanceName)); + } + static void prevalidate(edm::ConfigurationDescriptions& descriptions) { Base::prevalidate(descriptions); cms::alpakatools::module_backend_config(descriptions); diff --git a/RecoLocalCalo/EcalRecProducers/plugins/alpaka/EcalUncalibRecHitProducerPortable.cc b/RecoLocalCalo/EcalRecProducers/plugins/alpaka/EcalUncalibRecHitProducerPortable.cc index d0f06f3caf186..be36fad7b190f 100644 --- a/RecoLocalCalo/EcalRecProducers/plugins/alpaka/EcalUncalibRecHitProducerPortable.cc +++ b/RecoLocalCalo/EcalRecProducers/plugins/alpaka/EcalUncalibRecHitProducerPortable.cc @@ -87,6 +87,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { multifitParametersToken_{esConsumes()}, ebDigisSizeHostBuf_{cms::alpakatools::make_host_buffer()}, eeDigisSizeHostBuf_{cms::alpakatools::make_host_buffer()} { + // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed +#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED + producesTemporarily("edm::DeviceProduct", + ps.getParameter("recHitsLabelEB")); + producesTemporarily("edm::DeviceProduct", + ps.getParameter("recHitsLabelEE")); +#endif + std::pair EBtimeFitLimits, EEtimeFitLimits; EBtimeFitLimits.first = ps.getParameter("EBtimeFitLimits_Lower"); EBtimeFitLimits.second = ps.getParameter("EBtimeFitLimits_Upper"); diff --git a/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/SiPixelRawToCluster.cc b/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/SiPixelRawToCluster.cc index 8f14c50f09263..8a74cc67767d3 100644 --- a/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/SiPixelRawToCluster.cc +++ b/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/SiPixelRawToCluster.cc @@ -94,6 +94,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { static_cast(iConfig.getParameter("VCaltoElectronGain_L1")), static_cast(iConfig.getParameter("VCaltoElectronOffset")), static_cast(iConfig.getParameter("VCaltoElectronOffset_L1"))} { + // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed +#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED + producesTemporarily("edm::DeviceProduct"); + producesTemporarily("edm::DeviceProduct"); + producesTemporarily("edm::DeviceProduct"); +#endif + if (includeErrors_) { digiErrorPutToken_ = produces(); fmtErrorToken_ = produces(); diff --git a/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/SiPixelRecHitAlpaka.cc b/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/SiPixelRecHitAlpaka.cc index 46fd8a6b8c2ca..ad23762f3bca2 100644 --- a/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/SiPixelRecHitAlpaka.cc +++ b/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/SiPixelRecHitAlpaka.cc @@ -60,7 +60,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { tBeamSpot(consumes(iConfig.getParameter("beamSpot"))), tokenClusters_(consumes(iConfig.getParameter("src"))), tokenDigi_(consumes(iConfig.getParameter("src"))), - tokenHit_(produces()) {} + tokenHit_(produces()) { + // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed +#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED + if constexpr (std::is_same_v) { + producesTemporarily("edm::DeviceProduct"); + } +#endif + } template void SiPixelRecHitAlpaka::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { diff --git a/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducer.cc b/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducer.cc index 78af328dc6c15..6ea8999d63202 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducer.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducer.cc @@ -23,7 +23,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { outputPFClusterSoA_Token_{produces()}, outputPFRHFractionSoA_Token_{produces()}, synchronise_(config.getParameter("synchronise")), - pfRecHitFractionAllocation_(config.getParameter("pfRecHitFractionAllocation")) {} + pfRecHitFractionAllocation_(config.getParameter("pfRecHitFractionAllocation")) { + // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed +#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED + producesTemporarily("edm::DeviceProduct"); + producesTemporarily("edm::DeviceProduct"); +#endif + } void produce(device::Event& event, device::EventSetup const& setup) override { const reco::PFClusterParamsDeviceCollection& params = setup.getData(pfClusParamsToken); diff --git a/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/CaloRecHitSoAProducer.cc b/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/CaloRecHitSoAProducer.cc index 4b483b0c6a987..c9e7646f519b9 100644 --- a/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/CaloRecHitSoAProducer.cc +++ b/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/CaloRecHitSoAProducer.cc @@ -25,7 +25,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { CaloRecHitSoAProducer(edm::ParameterSet const& config) : recHitsToken_(consumes(config.getParameter("src"))), deviceToken_(produces()), - synchronise_(config.getUntrackedParameter("synchronise")) {} + synchronise_(config.getUntrackedParameter("synchronise")) { + // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed +#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED + producesTemporarily("edm::DeviceProduct"); +#endif + } void produce(edm::StreamID sid, device::Event& event, device::EventSetup const&) const override { const edm::SortedCollection& recHits = event.get(recHitsToken_); diff --git a/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/PFRecHitSoAProducer.cc b/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/PFRecHitSoAProducer.cc index ab191cb54c0fb..8c67d92658f3e 100644 --- a/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/PFRecHitSoAProducer.cc +++ b/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/PFRecHitSoAProducer.cc @@ -22,6 +22,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { : topologyToken_(esConsumes(config.getParameter("topology"))), pfRecHitsToken_(produces()), synchronise_(config.getUntrackedParameter("synchronise")) { + // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed +#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED + producesTemporarily("edm::DeviceProduct"); +#endif + const std::vector producers = config.getParameter>("producers"); recHitsToken_.reserve(producers.size()); for (const edm::ParameterSet& producer : producers) { diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtuplet.cc b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtuplet.cc index c16aed2e0b1e8..6d402f29a24da 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtuplet.cc +++ b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtuplet.cc @@ -58,7 +58,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { cpeToken_(esConsumes(edm::ESInputTag("", iConfig.getParameter("CPE")))), tokenHit_(consumes(iConfig.getParameter("pixelRecHitSrc"))), tokenTrack_(produces()), - deviceAlgo_(iConfig) {} + deviceAlgo_(iConfig) { + // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed +#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED + if constexpr (std::is_same_v) { + producesTemporarily("edm::DeviceProduct"); + } +#endif + } template void CAHitNtupletAlpaka::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { diff --git a/RecoTracker/PixelVertexFinding/plugins/alpaka/PixelVertexProducerAlpaka.cc b/RecoTracker/PixelVertexFinding/plugins/alpaka/PixelVertexProducerAlpaka.cc index d572a181ccf85..0da09be7ca235 100644 --- a/RecoTracker/PixelVertexFinding/plugins/alpaka/PixelVertexProducerAlpaka.cc +++ b/RecoTracker/PixelVertexFinding/plugins/alpaka/PixelVertexProducerAlpaka.cc @@ -64,7 +64,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { ptMin_(conf.getParameter("PtMin")), // 0.5 GeV ptMax_(conf.getParameter("PtMax")), // 75. Onsumes tokenDeviceTrack_(consumes(conf.getParameter("pixelTrackSrc"))), - tokenDeviceVertex_(produces()) {} + tokenDeviceVertex_(produces()) { + // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed +#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED + producesTemporarily("edm::DeviceProduct"); +#endif + } template void PixelVertexProducerAlpaka::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { diff --git a/RecoVertex/BeamSpotProducer/plugins/alpaka/BeamSpotDeviceProducer.cc b/RecoVertex/BeamSpotProducer/plugins/alpaka/BeamSpotDeviceProducer.cc index bd597164827fa..03c15013632d8 100644 --- a/RecoVertex/BeamSpotProducer/plugins/alpaka/BeamSpotDeviceProducer.cc +++ b/RecoVertex/BeamSpotProducer/plugins/alpaka/BeamSpotDeviceProducer.cc @@ -15,7 +15,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { class BeamSpotDeviceProducer : public global::EDProducer<> { public: BeamSpotDeviceProducer(edm::ParameterSet const& config) - : legacyToken_{consumes(config.getParameter("src"))}, deviceToken_{produces()} {} + : legacyToken_{consumes(config.getParameter("src"))}, deviceToken_{produces()} { + // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed +#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED + producesTemporarily("edm::DeviceProduct"); +#endif + } void produce(edm::StreamID, device::Event& event, device::EventSetup const& setup) const override { reco::BeamSpot const& beamspot = event.get(legacyToken_);