Skip to content

Commit

Permalink
Merge pull request #44698 from makortel/productIDModuleTypeResolverWo…
Browse files Browse the repository at this point in the history
…rkaround

Workaround to produce exactly same data products in Serial and CUDA backends in Alpaka modules possibly used at HLT
  • Loading branch information
cmsbuild authored Apr 11, 2024
2 parents fc8422f + 2d853ef commit 647bef5
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
fedsToUnpack_{ps.getParameter<std::vector<int>>("FEDs")} {
config_.maxChannelsEB = ps.getParameter<uint32_t>("maxChannelsEB");
config_.maxChannelsEE = ps.getParameter<uint32_t>("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<alpaka_cuda_async::EcalDigiDeviceCollection>",
ps.getParameter<std::string>("digisLabelEB"));
producesTemporarily("edm::DeviceProduct<alpaka_cuda_async::EcalDigiDeviceCollection>",
ps.getParameter<std::string>("digisLabelEE"));
#endif
}

void EcalRawToDigiPortable::produce(device::Event& event, device::EventSetup const& setup) {
Expand Down
6 changes: 6 additions & 0 deletions HeterogeneousCore/AlpakaCore/interface/alpaka/ProducerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
return ProducerBaseAdaptor<ProducerBase, Tr>(*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::Transition::Event>(edm::TypeID(td.typeInfo()), std::move(instanceName));
}

static void prevalidate(edm::ConfigurationDescriptions& descriptions) {
Base::prevalidate(descriptions);
cms::alpakatools::module_backend_config(descriptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
multifitParametersToken_{esConsumes()},
ebDigisSizeHostBuf_{cms::alpakatools::make_host_buffer<uint32_t>()},
eeDigisSizeHostBuf_{cms::alpakatools::make_host_buffer<uint32_t>()} {
// 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<alpaka_cuda_async::EcalUncalibratedRecHitDeviceCollection>",
ps.getParameter<std::string>("recHitsLabelEB"));
producesTemporarily("edm::DeviceProduct<alpaka_cuda_async::EcalUncalibratedRecHitDeviceCollection>",
ps.getParameter<std::string>("recHitsLabelEE"));
#endif

std::pair<double, double> EBtimeFitLimits, EEtimeFitLimits;
EBtimeFitLimits.first = ps.getParameter<double>("EBtimeFitLimits_Lower");
EBtimeFitLimits.second = ps.getParameter<double>("EBtimeFitLimits_Upper");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
static_cast<float>(iConfig.getParameter<double>("VCaltoElectronGain_L1")),
static_cast<float>(iConfig.getParameter<double>("VCaltoElectronOffset")),
static_cast<float>(iConfig.getParameter<double>("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<alpaka_cuda_async::SiPixelDigisSoACollection>");
producesTemporarily("edm::DeviceProduct<alpaka_cuda_async::SiPixelDigiErrorsSoACollection>");
producesTemporarily("edm::DeviceProduct<alpaka_cuda_async::SiPixelClustersSoACollection>");
#endif

if (includeErrors_) {
digiErrorPutToken_ = produces();
fmtErrorToken_ = produces();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
tBeamSpot(consumes(iConfig.getParameter<edm::InputTag>("beamSpot"))),
tokenClusters_(consumes(iConfig.getParameter<edm::InputTag>("src"))),
tokenDigi_(consumes(iConfig.getParameter<edm::InputTag>("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<TrackerTraits, pixelTopology::Phase1>) {
producesTemporarily("edm::DeviceProduct<alpaka_cuda_async::TrackingRecHitSoAPhase1>");
}
#endif
}

template <typename TrackerTraits>
void SiPixelRecHitAlpaka<TrackerTraits>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
outputPFClusterSoA_Token_{produces()},
outputPFRHFractionSoA_Token_{produces()},
synchronise_(config.getParameter<bool>("synchronise")),
pfRecHitFractionAllocation_(config.getParameter<int>("pfRecHitFractionAllocation")) {}
pfRecHitFractionAllocation_(config.getParameter<int>("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<alpaka_cuda_async::reco::PFClusterDeviceCollection>");
producesTemporarily("edm::DeviceProduct<alpaka_cuda_async::reco::PFRecHitFractionDeviceCollection>");
#endif
}

void produce(device::Event& event, device::EventSetup const& setup) override {
const reco::PFClusterParamsDeviceCollection& params = setup.getData(pfClusParamsToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
CaloRecHitSoAProducer(edm::ParameterSet const& config)
: recHitsToken_(consumes(config.getParameter<edm::InputTag>("src"))),
deviceToken_(produces()),
synchronise_(config.getUntrackedParameter<bool>("synchronise")) {}
synchronise_(config.getUntrackedParameter<bool>("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<alpaka_cuda_async::reco::CaloRecHitDeviceCollection>");
#endif
}

void produce(edm::StreamID sid, device::Event& event, device::EventSetup const&) const override {
const edm::SortedCollection<typename CAL::CaloRecHitType>& recHits = event.get(recHitsToken_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
: topologyToken_(esConsumes(config.getParameter<edm::ESInputTag>("topology"))),
pfRecHitsToken_(produces()),
synchronise_(config.getUntrackedParameter<bool>("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<alpaka_cuda_async::reco::PFRecHitDeviceCollection>");
#endif

const std::vector<edm::ParameterSet> producers = config.getParameter<std::vector<edm::ParameterSet>>("producers");
recHitsToken_.reserve(producers.size());
for (const edm::ParameterSet& producer : producers) {
Expand Down
9 changes: 8 additions & 1 deletion RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtuplet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
cpeToken_(esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("CPE")))),
tokenHit_(consumes(iConfig.getParameter<edm::InputTag>("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<TrackerTraits, pixelTopology::Phase1>) {
producesTemporarily("edm::DeviceProduct<alpaka_cuda_async::pixelTrack::TracksSoACollectionPhase1>");
}
#endif
}

template <typename TrackerTraits>
void CAHitNtupletAlpaka<TrackerTraits>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
ptMin_(conf.getParameter<double>("PtMin")), // 0.5 GeV
ptMax_(conf.getParameter<double>("PtMax")), // 75. Onsumes
tokenDeviceTrack_(consumes(conf.getParameter<edm::InputTag>("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<alpaka_cuda_async::ZVertexSoACollection>");
#endif
}

template <typename TrackerTraits>
void PixelVertexProducerAlpaka<TrackerTraits>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
class BeamSpotDeviceProducer : public global::EDProducer<> {
public:
BeamSpotDeviceProducer(edm::ParameterSet const& config)
: legacyToken_{consumes(config.getParameter<edm::InputTag>("src"))}, deviceToken_{produces()} {}
: legacyToken_{consumes(config.getParameter<edm::InputTag>("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<alpaka_cuda_async::BeamSpotDevice>");
#endif
}

void produce(edm::StreamID, device::Event& event, device::EventSetup const& setup) const override {
reco::BeamSpot const& beamspot = event.get(legacyToken_);
Expand Down

0 comments on commit 647bef5

Please sign in to comment.