ATLAS Offline Software
Loading...
Searching...
No Matches
TopoAutomatonSplittingImpl.h
Go to the documentation of this file.
1//
2// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3//
4// Dear emacs, this is -*- c++ -*-
5//
6
7#ifndef CALORECGPU_TOPOAUTOMATONSPLITTING_CUDA_H
8#define CALORECGPU_TOPOAUTOMATONSPLITTING_CUDA_H
9
12#include "CaloRecGPU/Helpers.h"
13#include "ExtraTagDefinitions.h"
14
15#include "FPHelpers.h"
16
18
19namespace TASplitting
20{
21
23//Any %?
24 {
25 using CaloRecGPU::Tag_1_1_12_32_18::Tag_1_1_12_32_18;
26
27 protected:
28
29 static constexpr uint32_t s_start_counter = 0xFFFU;
30 //12 bits.
31
33
35
36 [[nodiscard]] constexpr static uint32_t energy_to_storage(const uint32_t energy_pattern)
37 {
38 return EnergyFPFormat::template to_total_ordering<uint32_t>(energy_pattern);
39 }
40
41 [[nodiscard]] constexpr static uint32_t storage_to_energy(const uint32_t storage_pattern)
42 {
43 return EnergyFPFormat::template from_total_ordering<uint32_t>(storage_pattern);
44 }
45
46 public:
47
48 [[nodiscard]] constexpr static carrier counter_delta()
49 {
51 }
52
53 [[nodiscard]] constexpr int32_t index() const
54 {
55 return this->get_18_bits();
56 }
57
58 [[nodiscard]] constexpr static int32_t index(const TASTag tag)
59 {
60 return tag.index();
61 }
62
63 [[nodiscard]] constexpr int32_t counter() const
64 {
65 return this->get_12_bits();
66 }
67
68 [[nodiscard]] static constexpr int32_t counter(const TASTag tag)
69 {
70 return tag.counter();
71 }
72
73 [[nodiscard]] constexpr carrier update_cell(const uint32_t new_index, const uint32_t new_energy) const
74 {
75 return make_generic_tag(new_index, energy_to_storage(new_energy), 0, 0, 0) | (value & ~(s_18_bit_mask | s_32_bit_mask));
76 }
77
78 [[nodiscard]] constexpr carrier update_energy(const uint32_t new_energy) const
79 {
80 return (value & ~s_32_bit_mask) | (energy_to_storage(new_energy) << s_32_bit_offset);
81 }
82
83 [[nodiscard]] constexpr carrier clear_energy() const
84 {
85 return (value & ~s_32_bit_mask);
86 }
87
88 [[nodiscard]] constexpr carrier update_index(const uint32_t new_index) const
89 {
90 return (value & (~s_18_bit_mask)) | ( (carrier(new_index) << s_18_bit_offset) & s_18_bit_mask);
91 }
92
93 [[nodiscard]] constexpr carrier update_counter(const uint32_t new_counter) const
94 {
95 return (value & (~s_12_bit_mask)) | (carrier(new_counter) << s_12_bit_offset);
96 }
97
100 [[nodiscard]] static constexpr carrier make_maximum_tag(const int32_t index, const uint32_t energy_pattern, const bool is_primary)
101 {
102 return make_generic_tag(index, energy_to_storage(energy_pattern), s_start_counter, true, is_primary);
103 }
104
105 protected:
106
107 static constexpr carrier s_unassigned_tag = 1;
108
109 public:
110
111 [[nodiscard]] static constexpr carrier make_non_split_cluster_tag()
112 {
113 return s_unassigned_tag;
114 }
115
116 [[nodiscard]] constexpr bool is_valid() const
117 {
118 return value >= s_unassigned_tag;
119 }
120
121 [[nodiscard]] static constexpr bool is_valid(const TASTag tag)
122 {
123 return tag.is_valid();
124 }
125
126 [[nodiscard]] constexpr bool is_invalid() const
127 {
128 return !this->is_valid();
129 }
130
131 [[nodiscard]] static constexpr bool is_invalid(const TASTag tag)
132 {
133 return tag.is_invalid();
134 }
135
136 [[nodiscard]] constexpr bool is_part_of_splitter_cluster() const
137 {
138 return value > s_unassigned_tag;
139 }
140
141 [[nodiscard]] static constexpr bool is_part_of_splitter_cluster(const TASTag tag)
142 {
143 return tag.is_part_of_splitter_cluster();
144 }
145
146 [[nodiscard]] constexpr bool is_not_shared() const
147 {
148 return this->get_second_flag();
149 }
150
151 [[nodiscard]] constexpr static bool is_not_shared(const TASTag tag)
152 {
153 return tag.is_not_shared();
154 }
155
156 [[nodiscard]] constexpr bool is_shared() const
157 {
158 return !this->is_not_shared();
159 }
160
161 [[nodiscard]] constexpr static bool is_shared(const TASTag tag)
162 {
163 return tag.is_shared();
164 }
165
166 [[nodiscard]] constexpr carrier set_shared() const
167 {
168 return this->unset_second_flag();
169 }
170
171 [[nodiscard]] static constexpr carrier set_shared(const TASTag tag)
172 {
173 return tag.set_shared();
174 }
175
176 [[nodiscard]] constexpr carrier clear_shared() const
177 {
178 return this->set_second_flag();
179 }
180
181 [[nodiscard]] static constexpr carrier clear_shared(const TASTag tag)
182 {
183 return tag.clear_shared();
184 }
185
186 [[nodiscard]] constexpr carrier prepare_for_sharing(const TASTag other_tag) const
187 {
188 return (other_tag & (~s_second_flag_mask)) | s_first_flag_mask | s_12_bit_mask;
189 }
190
191 [[nodiscard]] constexpr bool is_first() const
192 {
193 return this->get_first_flag();
194 }
195
196 [[nodiscard]] static constexpr bool is_first(const TASTag tag)
197 {
198 return tag.is_first();
199 }
200
201 [[nodiscard]] constexpr carrier propagate() const
202 {
204 }
205
206 [[nodiscard]] static constexpr carrier propagate(const TASTag tag)
207 {
208 return tag.propagate();
209 }
210
211 protected:
212
213 static constexpr carrier s_secondary_maxima_eliminator_tag = 0xFFFFFFFFFFFFFFFFULL;
214
215 public:
216
217 [[nodiscard]] static constexpr carrier secondary_maxima_eliminator()
218 {
220 }
221
222 [[nodiscard]] constexpr bool is_secondary_maxima_eliminator() const
223 {
225 }
226
227 [[nodiscard]] static constexpr bool is_secondary_maxima_eliminator(const TASTag tag)
228 {
229 return tag.is_secondary_maxima_eliminator();
230 }
231
232 [[nodiscard]] constexpr bool is_primary_maximum() const
233 {
234 return this->get_first_flag();
235 }
236
237 [[nodiscard]] static constexpr bool is_primary_maximum(const TASTag tag)
238 {
239 return tag.is_primary_maximum();
240 }
241
242 [[nodiscard]] constexpr bool is_secondary_maximum() const
243 {
244 return !this->is_primary_maximum();
245 }
246
247 [[nodiscard]] static constexpr bool is_secondary_maximum(const TASTag tag)
248 {
249 return tag.is_secondary_maximum();
250 }
251
252 [[nodiscard]] constexpr carrier unset_secondary() const
253 {
254 return this->set_first_flag();
255 }
256
257 [[nodiscard]] static constexpr carrier unset_secondary(const TASTag tag)
258 {
259 return tag.unset_secondary();
260 }
261 };
262
264 {
267
270
272
276
279 //WARNING: the CPU version of the algorithm does not seem to have this option. Given the description,
280 // maybe it makes some sense to still allow this here? In our configuration we'll keep it disabled, but...
281
282 unsigned int neighbour_options;
283
284 static constexpr bool uses_this_sampling(const unsigned int pattern, const unsigned int sampling)
285 {
286 return (pattern >> sampling) & 1U;
287 }
288
289 constexpr bool uses_primary_sampling(const unsigned int sampling) const
290 {
292 }
293
294 constexpr bool uses_secondary_sampling(const unsigned int sampling) const
295 {
297 }
298
299 constexpr bool uses_sampling(const unsigned int sampling) const
300 {
302 }
303 };
304
318
320
322 const CaloRecGPU::ConstantDataHolder & instance_data,
323 const TASOptionsHolder & options,
324 const IGPUKernelSizeOptimizer & optimizer,
325 const bool synchronize = false,
327
329 const CaloRecGPU::ConstantDataHolder & instance_data,
330 const TASOptionsHolder & options,
331 const IGPUKernelSizeOptimizer & optimizer,
332 const bool synchronize = false,
334
336 const CaloRecGPU::ConstantDataHolder & instance_data,
337 const TASOptionsHolder & options,
338 const IGPUKernelSizeOptimizer & optimizer,
339 const bool synchronize = false,
341
343 const CaloRecGPU::ConstantDataHolder & instance_data,
344 const TASOptionsHolder & options,
345 const IGPUKernelSizeOptimizer & optimizer,
346 const bool synchronize = false,
348
350 const CaloRecGPU::ConstantDataHolder & instance_data,
351 const TASOptionsHolder & options,
352 const IGPUKernelSizeOptimizer & optimizer,
353 const bool synchronize = false,
355}
356
357#endif //CALORECGPU_TOPOAUTOMATONSPLITTING_CUDA_H
Contains functions to deal with arbitrary IEEE754-like floating point formats.
Holds CPU and GPU versions of the geometry and cell noise information, which are assumed to be consta...
Definition DataHolders.h:27
Holds the mutable per-event information (clusters and cells) and provides utilities to convert betwee...
Definition DataHolders.h:73
Interface for GPU kernel size optimization (allowing adjustment of kernel sizes to the properties of ...
SimpleHolder< T, MemoryContext::CUDAGPU, true > CUDA_object
Holds an object of type T in CUDA GPU memory.
SimpleHolder< T, MemoryContext::CPU, true > CPU_object
Holds an object of type T in CPU memory.
IEEE754_like< 23, 8 > StandardFloat
Definition FPHelpers.h:832
void cellWeightingAndFinalization(CaloRecGPU::EventDataHolder &holder, const CaloRecGPU::ConstantDataHolder &instance_data, const TASOptionsHolder &options, const IGPUKernelSizeOptimizer &optimizer, const bool synchronize=false, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream_to_use={})
void fillNeighbours(CaloRecGPU::EventDataHolder &holder, const CaloRecGPU::ConstantDataHolder &instance_data, const TASOptionsHolder &options, const IGPUKernelSizeOptimizer &optimizer, const bool synchronize=false, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream_to_use={})
void splitClusterGrowing(CaloRecGPU::EventDataHolder &holder, const CaloRecGPU::ConstantDataHolder &instance_data, const TASOptionsHolder &options, const IGPUKernelSizeOptimizer &optimizer, const bool synchronize=false, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream_to_use={})
void register_kernels(IGPUKernelSizeOptimizer &optimizer)
void findLocalMaxima(CaloRecGPU::EventDataHolder &holder, const CaloRecGPU::ConstantDataHolder &instance_data, const TASOptionsHolder &options, const IGPUKernelSizeOptimizer &optimizer, const bool synchronize=false, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream_to_use={})
void excludeSecondaryMaxima(CaloRecGPU::EventDataHolder &holder, const CaloRecGPU::ConstantDataHolder &instance_data, const TASOptionsHolder &options, const IGPUKernelSizeOptimizer &optimizer, const bool synchronize=false, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream_to_use={})
Definition index.py:1
CaloRecGPU::TagBase::carrier carrier
A tag with two bit flags, then 12 bits (for a counter), 32 bits (for a float) and 18 bits (for a cell...
static constexpr unsigned int s_32_bit_offset
constexpr uint32_t get_18_bits() const
static constexpr carrier s_32_bit_mask
constexpr uint32_t get_12_bits() const
constexpr carrier unset_second_flag() const
static constexpr carrier make_generic_tag(const uint32_t bits_18, const uint32_t bits_32, const uint32_t bits_12, const bool flag_2, const bool flag_1)
constexpr carrier set_second_flag() const
static constexpr unsigned int s_18_bit_offset
static constexpr carrier s_12_bit_mask
static constexpr carrier s_second_flag_mask
static constexpr carrier s_18_bit_mask
static constexpr carrier s_first_flag_mask
static constexpr unsigned int s_12_bit_offset
constexpr bool get_second_flag() const
constexpr carrier set_first_flag() const
constexpr bool get_first_flag() const
void sendToGPU(const bool clear_CPU=false)
CaloRecGPU::Helpers::CPU_object< TopoAutomatonSplittingOptions > m_options
CaloRecGPU::Helpers::CUDA_object< TopoAutomatonSplittingOptions > m_options_dev
static constexpr uint32_t s_start_counter
constexpr carrier prepare_for_sharing(const TASTag other_tag) const
static constexpr carrier secondary_maxima_eliminator()
constexpr int32_t index() const
static constexpr carrier clear_shared(const TASTag tag)
constexpr int32_t counter() const
constexpr bool is_not_shared() const
static constexpr bool is_valid(const TASTag tag)
constexpr bool is_secondary_maximum() const
static constexpr bool is_part_of_splitter_cluster(const TASTag tag)
constexpr bool is_part_of_splitter_cluster() const
FloatingPointHelpers::StandardFloat EnergyFPFormat
static constexpr bool is_not_shared(const TASTag tag)
static constexpr carrier s_tag_propagation_delta
static constexpr bool is_secondary_maximum(const TASTag tag)
constexpr bool is_shared() const
static constexpr int32_t index(const TASTag tag)
constexpr carrier clear_energy() const
static constexpr carrier make_maximum_tag(const int32_t index, const uint32_t energy_pattern, const bool is_primary)
Expects maximum_energy_pattern to be the bit pattern of the float that represents the energy.
constexpr bool is_valid() const
static constexpr uint32_t energy_to_storage(const uint32_t energy_pattern)
static constexpr carrier make_non_split_cluster_tag()
constexpr bool is_secondary_maxima_eliminator() const
constexpr carrier unset_secondary() const
constexpr carrier clear_shared() const
constexpr bool is_invalid() const
static constexpr bool is_primary_maximum(const TASTag tag)
static constexpr carrier set_shared(const TASTag tag)
static constexpr bool is_shared(const TASTag tag)
static constexpr bool is_invalid(const TASTag tag)
constexpr carrier propagate() const
constexpr carrier set_shared() const
constexpr bool is_first() const
constexpr carrier update_index(const uint32_t new_index) const
constexpr carrier update_counter(const uint32_t new_counter) const
constexpr carrier update_energy(const uint32_t new_energy) const
static constexpr carrier unset_secondary(const TASTag tag)
constexpr carrier update_cell(const uint32_t new_index, const uint32_t new_energy) const
static constexpr carrier s_unassigned_tag
static constexpr bool is_secondary_maxima_eliminator(const TASTag tag)
static constexpr uint32_t storage_to_energy(const uint32_t storage_pattern)
static constexpr carrier s_secondary_maxima_eliminator_tag
static constexpr carrier counter_delta()
static constexpr int32_t counter(const TASTag tag)
constexpr bool is_primary_maximum() const
static constexpr carrier propagate(const TASTag tag)
static constexpr bool is_first(const TASTag tag)
constexpr bool uses_secondary_sampling(const unsigned int sampling) const
constexpr bool uses_primary_sampling(const unsigned int sampling) const
static constexpr bool uses_this_sampling(const unsigned int pattern, const unsigned int sampling)
constexpr bool uses_sampling(const unsigned int sampling) const