Skip to content

Commit 41af7a8

Browse files
committed
ITS: hole-tracking
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent 07a49eb commit 41af7a8

17 files changed

Lines changed: 1285 additions & 667 deletions

Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/TimeFrameGPU.h

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ class TimeFrameGPU final : public TimeFrame<NLayers>
3131
using typename TimeFrame<NLayers>::ROFOverlapTableN;
3232
using typename TimeFrame<NLayers>::ROFVertexLookupTableN;
3333
using typename TimeFrame<NLayers>::ROFMaskTableN;
34+
using typename TimeFrame<NLayers>::TrackingTopologyN;
3435
using typename TimeFrame<NLayers>::TrackSeedN;
36+
static constexpr int MaxTransitions = TrackingTopologyN::MaxTransitions;
37+
static constexpr int MaxCells = TrackingTopologyN::MaxCells;
38+
static constexpr int MaxStreams = MaxCells > NLayers ? MaxCells : NLayers;
3539

3640
public:
3741
TimeFrameGPU() = default;
@@ -43,7 +47,9 @@ class TimeFrameGPU final : public TimeFrame<NLayers>
4347
void registerHostMemory(const int);
4448
void unregisterHostMemory(const int);
4549
void initialise(const TrackingParameters&, int maxLayers);
50+
void initialise(const TrackingParameters&, int maxLayers, int iteration);
4651
void loadIndexTableUtils();
52+
void loadTrackingTopologies();
4753
void loadTrackingFrameInfoDevice(const int);
4854
void createTrackingFrameInfoDeviceArray();
4955
void loadUnsortedClustersDevice(const int);
@@ -85,7 +91,7 @@ class TimeFrameGPU final : public TimeFrame<NLayers>
8591
void createNeighboursLUTDevice(const int, const unsigned int);
8692
void createTrackITSExtDevice(const size_t);
8793
void downloadTrackITSExtDevice();
88-
void downloadCellsNeighboursDevice(std::vector<bounded_vector<std::pair<int, int>>>&, const int);
94+
void downloadCellsNeighboursDevice(std::vector<bounded_vector<CellNeighbour>>&, const int);
8995
void downloadNeighboursLUTDevice(bounded_vector<int>&, const int);
9096
void downloadCellsDevice();
9197
void downloadCellsLUTDevice();
@@ -109,6 +115,7 @@ class TimeFrameGPU final : public TimeFrame<NLayers>
109115
const auto getDeviceROFOverlapTableView() { return mDeviceROFOverlapTableView; }
110116
const auto getDeviceROFVertexLookupTableView() { return mDeviceROFVertexLookupTableView; }
111117
const auto getDeviceROFMaskTableView() { return mDeviceROFMaskTableView; }
118+
const auto getDeviceTrackingTopologyView() const { return mDeviceTrackingTopologyView; }
112119
int* getDeviceROFramesClusters(const int layer) { return mROFramesClustersDevice[layer]; }
113120
auto& getTrackITSExt() { return mTrackITSExt; }
114121
Vertex* getDeviceVertices() { return mPrimaryVerticesDevice; }
@@ -120,10 +127,9 @@ class TimeFrameGPU final : public TimeFrame<NLayers>
120127
TrackITSExt* getDeviceTrackITSExt() { return mTrackITSExtDevice; }
121128
int* getDeviceNeighboursLUT(const int layer) { return mNeighboursLUTDevice[layer]; }
122129
gsl::span<int*> getDeviceNeighboursLUTs() { return mNeighboursLUTDevice; }
123-
gpuPair<int, int>* getDeviceNeighbourPairs(const int layer) { return mNeighbourPairsDevice[layer]; }
124-
std::array<int*, NLayers - 2>& getDeviceNeighboursAll() { return mNeighboursDevice; }
125-
int* getDeviceNeighbours(const int layer) { return mNeighboursDevice[layer]; }
126-
int** getDeviceNeighboursArray() { return mNeighboursDevice.data(); }
130+
CellNeighbour** getDeviceArrayNeighbours() { return mNeighboursDeviceArray; }
131+
std::array<CellNeighbour*, MaxCells>& getDeviceNeighboursAll() { return mNeighboursDevice; }
132+
CellNeighbour* getDeviceNeighbours(const int layer) { return mNeighboursDevice[layer]; }
127133
TrackingFrameInfo* getDeviceTrackingFrameInfo(const int);
128134
const TrackingFrameInfo** getDeviceArrayTrackingFrameInfo() const { return mTrackingFrameInfoDeviceArray; }
129135
const Cluster** getDeviceArrayClusters() const { return mClustersDeviceArray; }
@@ -147,10 +153,10 @@ class TimeFrameGPU final : public TimeFrame<NLayers>
147153
void setDevicePropagator(const o2::base::PropagatorImpl<float>* p) final { this->mPropagatorDevice = p; }
148154

149155
// Host-specific getters
150-
gsl::span<int, NLayers - 1> getNTracklets() { return mNTracklets; }
151-
gsl::span<int, NLayers - 2> getNCells() { return mNCells; }
156+
gsl::span<int> getNTracklets() { return {mNTracklets.data(), static_cast<gsl::span<int>::size_type>(this->mTrackingTopologyView.nTransitions)}; }
157+
gsl::span<int> getNCells() { return {mNCells.data(), static_cast<gsl::span<int>::size_type>(this->mTrackingTopologyView.nCells)}; }
152158
auto& getArrayNCells() { return mNCells; }
153-
gsl::span<int, NLayers - 3> getNNeighbours() { return mNNeighbours; }
159+
gsl::span<int> getNNeighbours() { return {mNNeighbours.data(), static_cast<gsl::span<int>::size_type>(this->mTrackingTopologyView.nCells)}; }
154160
auto& getArrayNNeighbours() { return mNNeighbours; }
155161

156162
// Host-available device getters
@@ -169,16 +175,18 @@ class TimeFrameGPU final : public TimeFrame<NLayers>
169175
void allocMem(void**, size_t, bool, int32_t = o2::gpu::GPUMemoryResource::MEMORY_GPU); // Abstract owned and unowned memory allocations on default stream
170176

171177
// Host-available device buffer sizes
172-
std::array<int, NLayers - 1> mNTracklets;
173-
std::array<int, NLayers - 2> mNCells;
174-
std::array<int, NLayers - 3> mNNeighbours;
178+
std::array<int, MaxTransitions> mNTracklets{};
179+
std::array<int, MaxCells> mNCells{};
180+
std::array<int, MaxCells> mNNeighbours{};
175181

176182
// Device pointers
177183
IndexTableUtilsN* mIndexTableUtilsDevice;
178184
// device navigation views
179185
ROFOverlapTableN::View mDeviceROFOverlapTableView;
180186
ROFVertexLookupTableN::View mDeviceROFVertexLookupTableView;
181187
ROFMaskTableN::View mDeviceROFMaskTableView;
188+
std::vector<TrackingTopologyN::View> mDeviceTrackerTopologyViews;
189+
TrackingTopologyN::View mDeviceTrackingTopologyView;
182190

183191
// Hybrid pref
184192
Vertex* mPrimaryVerticesDevice;
@@ -193,30 +201,29 @@ class TimeFrameGPU final : public TimeFrame<NLayers>
193201
const int** mClustersIndexTablesDeviceArray;
194202
uint8_t** mUsedClustersDeviceArray;
195203
const int** mROFramesClustersDeviceArray;
196-
std::array<Tracklet*, NLayers - 1> mTrackletsDevice;
197-
std::array<int*, NLayers - 1> mTrackletsLUTDevice;
198-
std::array<int*, NLayers - 2> mCellsLUTDevice;
199-
std::array<int*, NLayers - 3> mNeighboursLUTDevice;
204+
std::array<Tracklet*, MaxTransitions> mTrackletsDevice{};
205+
std::array<int*, MaxTransitions> mTrackletsLUTDevice{};
206+
std::array<int*, MaxCells> mCellsLUTDevice{};
207+
std::array<int*, MaxCells> mNeighboursLUTDevice{};
200208

201209
Tracklet** mTrackletsDeviceArray{nullptr};
202210
int** mCellsLUTDeviceArray{nullptr};
203-
int** mNeighboursCellDeviceArray{nullptr};
204211
int** mNeighboursCellLUTDeviceArray{nullptr};
205212
int** mTrackletsLUTDeviceArray{nullptr};
206-
std::array<CellSeed*, NLayers - 2> mCellsDevice;
213+
std::array<CellSeed*, MaxCells> mCellsDevice{};
207214
CellSeed** mCellsDeviceArray;
208-
std::array<int*, NLayers - 3> mNeighboursIndexTablesDevice;
215+
std::array<int*, MaxCells> mNeighboursIndexTablesDevice{};
209216
TrackSeedN* mTrackSeedsDevice{nullptr};
210217
int* mTrackSeedsLUTDevice{nullptr};
211218
unsigned int mNTracks{0};
212-
std::array<o2::track::TrackParCovF*, NLayers - 2> mCellSeedsDevice;
219+
std::array<o2::track::TrackParCovF*, MaxCells> mCellSeedsDevice{};
213220
o2::track::TrackParCovF** mCellSeedsDeviceArray;
214-
std::array<float*, NLayers - 2> mCellSeedsChi2Device;
221+
std::array<float*, MaxCells> mCellSeedsChi2Device{};
215222
float** mCellSeedsChi2DeviceArray;
216223

217224
TrackITSExt* mTrackITSExtDevice;
218-
std::array<gpuPair<int, int>*, NLayers - 2> mNeighbourPairsDevice;
219-
std::array<int*, NLayers - 2> mNeighboursDevice;
225+
std::array<CellNeighbour*, MaxCells> mNeighboursDevice{};
226+
CellNeighbour** mNeighboursDeviceArray{nullptr};
220227
std::array<TrackingFrameInfo*, NLayers> mTrackingFrameInfoDevice;
221228
const TrackingFrameInfo** mTrackingFrameInfoDeviceArray;
222229

@@ -245,19 +252,19 @@ inline std::vector<unsigned int> TimeFrameGPU<NLayers>::getClusterSizes()
245252
template <int NLayers>
246253
inline size_t TimeFrameGPU<NLayers>::getNumberOfTracklets() const
247254
{
248-
return std::accumulate(mNTracklets.begin(), mNTracklets.end(), 0);
255+
return std::accumulate(mNTracklets.begin(), mNTracklets.begin() + this->mTrackingTopologyView.nTransitions, 0);
249256
}
250257

251258
template <int NLayers>
252259
inline size_t TimeFrameGPU<NLayers>::getNumberOfCells() const
253260
{
254-
return std::accumulate(mNCells.begin(), mNCells.end(), 0);
261+
return std::accumulate(mNCells.begin(), mNCells.begin() + this->mTrackingTopologyView.nCells, 0);
255262
}
256263

257264
template <int NLayers>
258265
inline size_t TimeFrameGPU<NLayers>::getNumberOfNeighbours() const
259266
{
260-
return std::accumulate(mNNeighbours.begin(), mNNeighbours.end(), 0);
267+
return std::accumulate(mNNeighbours.begin(), mNNeighbours.begin() + this->mTrackingTopologyView.nCells, 0);
261268
}
262269

263270
} // namespace o2::its::gpu

Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/TrackingKernels.h

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "ITStracking/BoundedAllocator.h"
1919
#include "ITStracking/ROFLookupTables.h"
20+
#include "ITStracking/TrackingTopology.h"
2021
#include "ITStracking/Definitions.h"
2122
#include "ITStrackingGPU/Utils.h"
2223
#include "DetectorsBase/Propagator.h"
@@ -25,6 +26,7 @@
2526
namespace o2::its
2627
{
2728
class CellSeed;
29+
struct CellNeighbour;
2830
template <int>
2931
class TrackSeed;
3032
class TrackingFrameInfo;
@@ -53,13 +55,14 @@ void countTrackletsInROFsHandler(const IndexTableUtils<NLayers>* utils,
5355
gsl::span<int*> trackletsLUTsHost,
5456
const bool selectUPCVertices,
5557
const float NSigmaCut,
56-
bounded_vector<float>& phiCuts,
58+
const typename TrackingTopology<NLayers>::View topology,
59+
bounded_vector<float>& transitionPhiCuts,
5760
const float resolutionPV,
5861
std::array<float, NLayers>& minR,
5962
std::array<float, NLayers>& maxR,
6063
bounded_vector<float>& resolutions,
6164
std::vector<float>& radii,
62-
bounded_vector<float>& mulScatAng,
65+
bounded_vector<float>& transitionMSAngles,
6366
o2::its::ExternalAllocator* alloc,
6467
gpu::Streams& streams);
6568

@@ -84,13 +87,14 @@ void computeTrackletsInROFsHandler(const IndexTableUtils<NLayers>* utils,
8487
gsl::span<int*> trackletsLUTsHost,
8588
const bool selectUPCVertices,
8689
const float NSigmaCut,
87-
bounded_vector<float>& phiCuts,
90+
const typename TrackingTopology<NLayers>::View topology,
91+
bounded_vector<float>& transitionPhiCuts,
8892
const float resolutionPV,
8993
std::array<float, NLayers>& minR,
9094
std::array<float, NLayers>& maxR,
9195
bounded_vector<float>& resolutions,
9296
std::vector<float>& radii,
93-
bounded_vector<float>& mulScatAng,
97+
bounded_vector<float>& transitionMSAngles,
9498
o2::its::ExternalAllocator* alloc,
9599
gpu::Streams& streams);
96100

@@ -101,7 +105,8 @@ void countCellsHandler(const Cluster** sortedClusters,
101105
Tracklet** tracklets,
102106
int** trackletsLUT,
103107
const int nTracklets,
104-
const int layer,
108+
const int cellTopologyId,
109+
const typename TrackingTopology<NLayers>::View topology,
105110
CellSeed* cells,
106111
int** cellsLUTsDeviceArray,
107112
int* cellsLUTsHost,
@@ -120,7 +125,8 @@ void computeCellsHandler(const Cluster** sortedClusters,
120125
Tracklet** tracklets,
121126
int** trackletsLUT,
122127
const int nTracklets,
123-
const int layer,
128+
const int cellTopologyId,
129+
const typename TrackingTopology<NLayers>::View topology,
124130
CellSeed* cells,
125131
int** cellsLUTsDeviceArray,
126132
int* cellsLUTsHost,
@@ -133,32 +139,34 @@ void computeCellsHandler(const Cluster** sortedClusters,
133139

134140
template <int NLayers>
135141
void countCellNeighboursHandler(CellSeed** cellsLayersDevice,
136-
int* neighboursLUTs,
142+
int* neighboursCursor,
137143
int** cellsLUTs,
138-
gpuPair<int, int>* cellNeighbours,
139-
int* neighboursIndexTable,
140-
const Tracklet** tracklets,
144+
const int sourceCellTopologyId,
145+
const int targetCellTopologyId,
146+
const typename TrackingTopology<NLayers>::View topology,
141147
const float maxChi2ClusterAttachment,
142148
const float bz,
143-
const int layerIndex,
144149
const unsigned int nCells,
145-
const unsigned int nCellsNext,
146150
const int maxCellNeighbours,
147-
o2::its::ExternalAllocator* alloc,
148151
gpu::Stream& stream);
149152

153+
void scanCellNeighboursHandler(int* neighboursCursor,
154+
int* neighboursLUT,
155+
const unsigned int nCells,
156+
o2::its::ExternalAllocator* alloc,
157+
gpu::Stream& stream);
158+
150159
template <int NLayers>
151160
void computeCellNeighboursHandler(CellSeed** cellsLayersDevice,
152-
int* neighboursLUTs,
161+
int* neighboursCursor,
153162
int** cellsLUTs,
154-
gpuPair<int, int>* cellNeighbours,
155-
int* neighboursIndexTable,
156-
const Tracklet** tracklets,
163+
CellNeighbour* cellNeighbours,
164+
const int sourceCellTopologyId,
165+
const int targetCellTopologyId,
166+
const typename TrackingTopology<NLayers>::View topology,
157167
const float maxChi2ClusterAttachment,
158168
const float bz,
159-
const int layerIndex,
160169
const unsigned int nCells,
161-
const unsigned int nCellsNext,
162170
const int maxCellNeighbours,
163171
gpu::Stream& stream);
164172

@@ -171,17 +179,23 @@ int filterCellNeighboursHandler(gpuPair<int, int>*,
171179
template <int NLayers>
172180
void processNeighboursHandler(const int startLayer,
173181
const int startLevel,
182+
const int defaultCellTopologyId,
183+
const typename TrackingTopology<NLayers>::View topology,
174184
CellSeed** allCellSeeds,
175185
CellSeed* currentCellSeeds,
176-
std::array<int, NLayers - 2>& nCells,
186+
const int* currentCellTopologyIds,
187+
const int* currentCellIds,
188+
std::array<int, TrackingTopology<NLayers>::MaxCells>& nCells,
177189
const unsigned char** usedClusters,
178-
std::array<int*, NLayers - 2>& neighbours,
179-
gsl::span<int*> neighboursDeviceLUTs,
190+
CellNeighbour** neighbours,
191+
int** neighboursDeviceLUTs,
180192
const TrackingFrameInfo** foundTrackingFrameInfo,
181193
bounded_vector<TrackSeed<NLayers>>& seedsHost,
182194
const float bz,
183195
const float MaxChi2ClusterAttachment,
184196
const float maxChi2NDF,
197+
const int maxHoles,
198+
const LayerMask holeLayerMask,
185199
const std::vector<float>& layerxX0Host,
186200
const o2::base::Propagator* propagator,
187201
const o2::base::PropagatorF::MatCorrType matCorrType,

0 commit comments

Comments
 (0)