6 #include "CLUEAlgoAlpaka.h" 16 template <
typename TAcc,
typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
18 const unsigned int numer_of_clusters,
19 const HGCalSoARecHitsDeviceCollection::ConstView input_rechits_soa,
20 const HGCalSoARecHitsExtraDeviceCollection::ConstView input_clusters_soa,
28 auto clIdx = input_clusters_soa[
i].clusterIndex();
31 if (input_clusters_soa[
i].isSeed() == 1) {
32 outputs[clIdx].seed() = input_rechits_soa[
i].detid();
41 template <
typename TAcc,
typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
43 const unsigned int numer_of_clusters,
46 const HGCalSoARecHitsDeviceCollection::ConstView input_rechits_soa,
47 const HGCalSoARecHitsExtraDeviceCollection::ConstView input_clusters_soa,
51 for (int32_t hit_index :
uniform_elements(acc, input_rechits_soa.metadata().size())) {
52 const int cluster_index = input_clusters_soa[hit_index].clusterIndex();
61 int clusterSeed = outputs_service[cluster_index].maxEnergyIndex();
62 float clusterEnergy = (clusterSeed ==
kInvalidIndex) ? 0.
f : input_rechits_soa[clusterSeed].
weight();
64 while (input_rechits_soa[hit_index].
weight() > clusterEnergy) {
69 int seed = alpaka::atomicCas(acc, &outputs_service[cluster_index].maxEnergyIndex(), clusterSeed, hit_index);
70 if (
seed == hit_index) {
86 template <
typename TAcc,
typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
88 const unsigned int numer_of_clusters,
91 const HGCalSoARecHitsDeviceCollection::ConstView input_rechits_soa,
92 const HGCalSoARecHitsExtraDeviceCollection::ConstView input_clusters_soa,
96 for (int32_t hit_index :
uniform_elements(acc, input_rechits_soa.metadata().size())) {
97 const int cluster_index = input_clusters_soa[hit_index].clusterIndex();
103 const int max_energy_index = outputs_service[cluster_index].maxEnergyIndex();
106 const float d1 = input_rechits_soa[hit_index].dim1() - input_rechits_soa[max_energy_index].dim1();
107 const float d2 = input_rechits_soa[hit_index].dim2() - input_rechits_soa[max_energy_index].dim2();
112 outputs_service[cluster_index].total_weight()),
124 template <
typename TAcc,
typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
126 const unsigned int numer_of_clusters,
129 const HGCalSoARecHitsDeviceCollection::ConstView input_rechits_soa,
130 const HGCalSoARecHitsExtraDeviceCollection::ConstView input_clusters_soa,
135 const int max_energy_index = outputs_service[cluster_index].maxEnergyIndex();
137 if (outputs_service[cluster_index].total_weight_log() > 0.
f) {
138 float inv_tot_weight = 1.f / outputs_service[cluster_index].total_weight_log();
139 outputs[cluster_index].x() *= inv_tot_weight;
140 outputs[cluster_index].y() *= inv_tot_weight;
142 outputs[cluster_index].x() = input_rechits_soa[max_energy_index].dim1();
143 outputs[cluster_index].y() = input_rechits_soa[max_energy_index].dim2();
145 outputs[cluster_index].z() = input_rechits_soa[max_energy_index].dim3();
151 const unsigned int size,
154 const HGCalSoARecHitsDeviceCollection::ConstView input_rechits_soa,
155 const HGCalSoARecHitsExtraDeviceCollection::ConstView input_clusters_soa,
158 auto x = cms::alpakatools::make_device_view<float>(
queue,
outputs.x(), size);
159 alpaka::memset(
queue,
x, 0x0);
160 auto y = cms::alpakatools::make_device_view<float>(
queue,
outputs.y(), size);
161 alpaka::memset(
queue, y, 0x0);
162 auto z = cms::alpakatools::make_device_view<float>(
queue,
outputs.z(), size);
163 alpaka::memset(
queue, z, 0x0);
164 auto seed = cms::alpakatools::make_device_view<int>(
queue,
outputs.seed(), size);
166 auto energy = cms::alpakatools::make_device_view<float>(
queue,
outputs.energy(), size);
168 auto cells = cms::alpakatools::make_device_view<int>(
queue,
outputs.cells(), size);
170 auto total_weight = cms::alpakatools::make_device_view<float>(
queue, outputs_service.total_weight(), size);
171 alpaka::memset(
queue, total_weight, 0x0);
172 auto total_weight_log = cms::alpakatools::make_device_view<float>(
queue, outputs_service.total_weight_log(), size);
173 alpaka::memset(
queue, total_weight_log, 0x0);
174 auto maxEnergyValue = cms::alpakatools::make_device_view<float>(
queue, outputs_service.maxEnergyValue(), size);
175 alpaka::memset(
queue, maxEnergyValue, 0x0);
176 auto maxEnergyIndex = cms::alpakatools::make_device_view<int>(
queue, outputs_service.maxEnergyIndex(), size);
188 auto workDiv = make_workdiv<Acc1D>(groups,
items);
192 alpaka::exec<Acc1D>(
queue,
202 alpaka::exec<Acc1D>(
queue,
213 auto workDivClusters = make_workdiv<Acc1D>(group_clusters,
items);
214 alpaka::exec<Acc1D>(
queue,
constexpr auto kInvalidIndex
static constexpr uint8_t kInvalidIndexByte
static constexpr int kInvalidCluster
static constexpr float d1
T1 atomicAdd(T1 *a, T2 b)