From 8ccf6b52b97ef8dd279963f063b3903e3f156c10 Mon Sep 17 00:00:00 2001 From: jsamudio Date: Wed, 2 Oct 2024 10:21:47 -0500 Subject: [PATCH] Rename variables and adjust allocation syntax Adjust formatting Rename data member and remove unnecessary include --- .../plugins/alpaka/PFClusterSoAProducer.cc | 54 ++++++++++--------- .../alpaka/PFClusterSoAProducerKernel.dev.cc | 38 ++++++------- .../alpaka/PFClusterSoAProducerKernel.h | 33 ++++++------ 3 files changed, 63 insertions(+), 62 deletions(-) diff --git a/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducer.cc b/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducer.cc index c2f3cbf920da3..65c0e4f5c33f3 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducer.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducer.cc @@ -24,7 +24,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { inputPFRecHitSoA_Token_{consumes(config.getParameter("pfRecHits"))}, outputPFClusterSoA_Token_{produces()}, outputPFRHFractionSoA_Token_{produces()}, - num_rhf_{cms::alpakatools::make_host_buffer()}, + numRHF_{cms::alpakatools::make_host_buffer()}, synchronise_(config.getParameter("synchronise")) {} void acquire(device::Event const& event, device::EventSetup const& setup) override { @@ -35,22 +35,22 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { if (pfRecHits->metadata().size() != 0) nRH = pfRecHits->size(); - pfClusteringVars_ = std::make_optional(nRH, event.queue()); - pfClusteringEdgeVars_ = std::make_optional(nRH * 8, event.queue()); - pfClusters_ = std::make_optional(nRH, event.queue()); + pfClusteringVars_.emplace(nRH, event.queue()); + pfClusteringEdgeVars_.emplace(nRH * 8, event.queue()); + pfClusters_.emplace(nRH, event.queue()); - *num_rhf_ = 0; + *numRHF_ = 0; if (nRH != 0) { PFClusterProducerKernel kernel(event.queue(), pfRecHits); - kernel.step1(event.queue(), - params, - topology, - *pfClusteringVars_, - *pfClusteringEdgeVars_, - pfRecHits, - *pfClusters_, - num_rhf_.data()); + kernel.seedTopoAndContract(event.queue(), + params, + topology, + *pfClusteringVars_, + *pfClusteringEdgeVars_, + pfRecHits, + *pfClusters_, + numRHF_.data()); } } @@ -59,29 +59,32 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { const reco::PFRecHitHCALTopologyDeviceCollection& topology = setup.getData(topologyToken_); const reco::PFRecHitHostCollection& pfRecHits = event.get(inputPFRecHitSoA_Token_); int nRH = 0; + + std::optional pfrhFractions; + if (pfRecHits->metadata().size() != 0) nRH = pfRecHits->size(); if (nRH != 0) { - pfrhFractions_ = std::make_optional(*num_rhf_.data(), event.queue()); + pfrhFractions.emplace(*numRHF_.data(), event.queue()); PFClusterProducerKernel kernel(event.queue(), pfRecHits); - kernel.step2(event.queue(), - params, - topology, - *pfClusteringVars_, - *pfClusteringEdgeVars_, - pfRecHits, - *pfClusters_, - *pfrhFractions_); + kernel.cluster(event.queue(), + params, + topology, + *pfClusteringVars_, + *pfClusteringEdgeVars_, + pfRecHits, + *pfClusters_, + *pfrhFractions); } else { - pfrhFractions_ = std::make_optional(0, event.queue()); + pfrhFractions.emplace(0, event.queue()); } if (synchronise_) alpaka::wait(event.queue()); event.emplace(outputPFClusterSoA_Token_, std::move(*pfClusters_)); - event.emplace(outputPFRHFractionSoA_Token_, std::move(*pfrhFractions_)); + event.emplace(outputPFRHFractionSoA_Token_, std::move(*pfrhFractions)); } static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { @@ -99,11 +102,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { const edm::EDGetTokenT inputPFRecHitSoA_Token_; const device::EDPutToken outputPFClusterSoA_Token_; const device::EDPutToken outputPFRHFractionSoA_Token_; - cms::alpakatools::host_buffer num_rhf_; + cms::alpakatools::host_buffer numRHF_; std::optional pfClusteringVars_; std::optional pfClusteringEdgeVars_; std::optional pfClusters_; - std::optional pfrhFractions_; const bool synchronise_; }; diff --git a/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducerKernel.dev.cc b/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducerKernel.dev.cc index c79ee50863e80..74ee0037fa003 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducerKernel.dev.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducerKernel.dev.cc @@ -1199,7 +1199,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { reco::PFClusteringVarsDeviceCollection::View pfClusteringVars, reco::PFClusterDeviceCollection::View clusterView, uint32_t* __restrict__ nSeeds, - uint32_t* __restrict__ num_rhf_) const { + uint32_t* __restrict__ nRHF) const { const int nRH = pfRecHits.size(); int& totalSeedOffset = alpaka::declareSharedVar(acc); int& totalSeedFracOffset = alpaka::declareSharedVar(acc); @@ -1302,7 +1302,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { pfClusteringVars.pcrhFracSize() = totalSeedFracOffset; pfClusteringVars.nRHFracs() = totalSeedFracOffset; clusterView.nRHFracs() = totalSeedFracOffset; - *num_rhf_ = totalSeedFracOffset; + *nRHF = totalSeedFracOffset; clusterView.nSeeds() = *nSeeds; clusterView.nTopos() = pfClusteringVars.nTopos(); @@ -1468,14 +1468,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { alpaka::memset(queue, nSeeds, 0x00); // Reset nSeeds } - void PFClusterProducerKernel::step1(Queue& queue, - const reco::PFClusterParamsDeviceCollection& params, - const reco::PFRecHitHCALTopologyDeviceCollection& topology, - reco::PFClusteringVarsDeviceCollection& pfClusteringVars, - reco::PFClusteringEdgeVarsDeviceCollection& pfClusteringEdgeVars, - const reco::PFRecHitHostCollection& pfRecHits, - reco::PFClusterDeviceCollection& pfClusters, - uint32_t* __restrict__ num_rhf_) { + void PFClusterProducerKernel::seedTopoAndContract(Queue& queue, + const reco::PFClusterParamsDeviceCollection& params, + const reco::PFRecHitHCALTopologyDeviceCollection& topology, + reco::PFClusteringVarsDeviceCollection& pfClusteringVars, + reco::PFClusteringEdgeVarsDeviceCollection& pfClusteringEdgeVars, + const reco::PFRecHitHostCollection& pfRecHits, + reco::PFClusterDeviceCollection& pfClusters, + uint32_t* __restrict__ nRHF) { const int nRH = pfRecHits->size(); const int threadsPerBlock = 256; const int blocks = divide_up_by(nRH, threadsPerBlock); @@ -1525,17 +1525,17 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { pfClusteringVars.view(), pfClusters.view(), nSeeds.data(), - num_rhf_); + nRHF); } - void PFClusterProducerKernel::step2(Queue& queue, - const reco::PFClusterParamsDeviceCollection& params, - const reco::PFRecHitHCALTopologyDeviceCollection& topology, - reco::PFClusteringVarsDeviceCollection& pfClusteringVars, - reco::PFClusteringEdgeVarsDeviceCollection& pfClusteringEdgeVars, - const reco::PFRecHitHostCollection& pfRecHits, - reco::PFClusterDeviceCollection& pfClusters, - reco::PFRecHitFractionDeviceCollection& pfrhFractions) { + void PFClusterProducerKernel::cluster(Queue& queue, + const reco::PFClusterParamsDeviceCollection& params, + const reco::PFRecHitHCALTopologyDeviceCollection& topology, + reco::PFClusteringVarsDeviceCollection& pfClusteringVars, + reco::PFClusteringEdgeVarsDeviceCollection& pfClusteringEdgeVars, + const reco::PFRecHitHostCollection& pfRecHits, + reco::PFClusterDeviceCollection& pfClusters, + reco::PFRecHitFractionDeviceCollection& pfrhFractions) { const int nRH = pfRecHits->size(); // fillRhfIndex diff --git a/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducerKernel.h b/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducerKernel.h index 50b37d42833e2..32c68a64f4b24 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducerKernel.h +++ b/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducerKernel.h @@ -4,7 +4,6 @@ #include "DataFormats/ParticleFlowReco/interface/alpaka/PFRecHitDeviceCollection.h" #include "DataFormats/ParticleFlowReco/interface/PFRecHitHostCollection.h" #include "DataFormats/ParticleFlowReco/interface/alpaka/PFClusterDeviceCollection.h" -#include "DataFormats/ParticleFlowReco/interface/PFClusterHostCollection.h" #include "DataFormats/ParticleFlowReco/interface/alpaka/PFRecHitFractionDeviceCollection.h" #include "RecoParticleFlow/PFClusterProducer/interface/alpaka/PFClusterParamsDeviceCollection.h" #include "RecoParticleFlow/PFClusterProducer/interface/alpaka/PFClusteringVarsDeviceCollection.h" @@ -40,23 +39,23 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { public: PFClusterProducerKernel(Queue& queue, const reco::PFRecHitHostCollection& pfRecHits); - void step1(Queue& queue, - const reco::PFClusterParamsDeviceCollection& params, - const reco::PFRecHitHCALTopologyDeviceCollection& topology, - reco::PFClusteringVarsDeviceCollection& pfClusteringVars, - reco::PFClusteringEdgeVarsDeviceCollection& pfClusteringEdgeVars, - const reco::PFRecHitHostCollection& pfRecHits, - reco::PFClusterDeviceCollection& pfClusters, - uint32_t* __restrict__ num_rhf_); + void seedTopoAndContract(Queue& queue, + const reco::PFClusterParamsDeviceCollection& params, + const reco::PFRecHitHCALTopologyDeviceCollection& topology, + reco::PFClusteringVarsDeviceCollection& pfClusteringVars, + reco::PFClusteringEdgeVarsDeviceCollection& pfClusteringEdgeVars, + const reco::PFRecHitHostCollection& pfRecHits, + reco::PFClusterDeviceCollection& pfClusters, + uint32_t* __restrict__ nRHF); - void step2(Queue& queue, - const reco::PFClusterParamsDeviceCollection& params, - const reco::PFRecHitHCALTopologyDeviceCollection& topology, - reco::PFClusteringVarsDeviceCollection& pfClusteringVars, - reco::PFClusteringEdgeVarsDeviceCollection& pfClusteringEdgeVars, - const reco::PFRecHitHostCollection& pfRecHits, - reco::PFClusterDeviceCollection& pfClusters, - reco::PFRecHitFractionDeviceCollection& pfrhFractions); + void cluster(Queue& queue, + const reco::PFClusterParamsDeviceCollection& params, + const reco::PFRecHitHCALTopologyDeviceCollection& topology, + reco::PFClusteringVarsDeviceCollection& pfClusteringVars, + reco::PFClusteringEdgeVarsDeviceCollection& pfClusteringEdgeVars, + const reco::PFRecHitHostCollection& pfRecHits, + reco::PFClusterDeviceCollection& pfClusters, + reco::PFRecHitFractionDeviceCollection& pfrhFractions); private: cms::alpakatools::device_buffer nSeeds;