2121#include " ITStracking/Configuration.h"
2222#include " ITStracking/TrackExtensionHypothesis.h"
2323#include " ITStrackingGPU/Utils.h"
24+ #include " ITStrackingGPU/ClusterLinesGPU.h"
2425
2526namespace o2 ::its::gpu
2627{
@@ -54,10 +55,14 @@ class TimeFrameGPU : public TimeFrame<NLayers>
5455 void createTrackingFrameInfoDeviceArray (const int = NLayers);
5556 void loadUnsortedClustersDevice (const int );
5657 void createUnsortedClustersDeviceArray (const int = NLayers);
57- void loadClustersDevice (const int );
5858 void createClustersDeviceArray (const int = NLayers);
5959 void loadClustersIndexTables (const int );
6060 void createClustersIndexTablesArray (const int = NLayers);
61+ void createClustersDevice (const int );
62+ void createClustersIndexTables (const int );
63+ void createClusterRadiiDevice ();
64+ void uploadClusterRadii ();
65+ void sortClustersDevice (const int layer, const TrackingParameters& trkParam);
6166 void createUsedClustersDevice (const int );
6267 void createUsedClustersDeviceArray (const int = NLayers);
6368 void loadUsedClustersDevice ();
@@ -87,6 +92,35 @@ class TimeFrameGPU : public TimeFrame<NLayers>
8792 void createTrackExtensionScratchDevice (const int nThreads, const int maxHypotheses);
8893 void downloadTrackITSExtDevice ();
8994
95+ // Seeding-vertexer
96+ void createClusterOwnersDeviceArray ();
97+ void createClusterOwnersDevice ();
98+ void resetClusterOwnersDevice ();
99+ void createClusterSortScratchDevice (const int layer);
100+
101+ protected:
102+ void prepareClusters (const TrackingParameters& trkParam, const int maxLayers) override
103+ {
104+ if (maxLayers < NLayers) { // only if former seeding vertexer is run
105+ TimeFrame<NLayers>::prepareClusters (trkParam, maxLayers);
106+ }
107+ }
108+ void allocateClusterSortStorage (const TrackingParameters& trkParam, const int maxLayers) override
109+ {
110+ if (maxLayers < NLayers) { // only if former seeding vertexer is run
111+ TimeFrame<NLayers>::allocateClusterSortStorage (trkParam, maxLayers);
112+ }
113+ }
114+
115+ public:
116+ void createLinesDevice (const int nCells);
117+ void createDiamondDevice (const Vertex& diamond);
118+ unsigned int downloadLinesDevice ();
119+ unsigned int getNLines ();
120+ const auto & getHostLines () const { return mLinesHost ; }
121+ const auto & getHostLineRof () const { return mLineRofHost ; }
122+ const auto & getHostLineClusters () const { return mLineClustersHost ; }
123+
90124 // / synchronization
91125 auto & getStream (const size_t stream) { return mGpuStreams [stream]; }
92126 auto & getStreams () { return mGpuStreams ; }
@@ -111,6 +145,19 @@ class TimeFrameGPU : public TimeFrame<NLayers>
111145 auto & getTrackITSExt () { return mTrackITSExt ; }
112146 auto & getTrackIndices () { return mTrackIndices ; }
113147 Vertex* getDeviceVertices () { return mPrimaryVerticesDevice ; }
148+ int * getDeviceROFramesClusters (const int layer) { return mROFramesClustersDevice [layer]; }
149+ int * getDeviceClusterSortKeys (const int layer) { return mClusterSortKeysDevice [layer]; }
150+ int * getDeviceClusterSortPerm (const int layer) { return mClusterSortPermDevice [layer]; }
151+ Cluster* getDeviceUnsortedClusters (const int layer) { return mUnsortedClustersDevice [layer]; }
152+ Cluster* getDeviceClusters (const int layer) { return mClustersDevice [layer]; }
153+ int * getDeviceClustersIndexTable (const int layer) { return mClustersIndexTablesDevice [layer]; }
154+ const float * getDeviceMinRs () const { return mClusterMinRDevice ; }
155+ const float * getDeviceMaxRs () const { return mClusterMaxRDevice ; }
156+ int * getDeviceROFramesPV () { return mROFramesPVDevice ; }
157+ unsigned char * getDeviceUsedClusters (const int );
158+ const o2::base::Propagator* getChainPropagator ();
159+ bool arePersistentTablesLoaded () { return mPersistentTablesLoaded ; }
160+ void setPersistentTablesLoaded (bool setValue) { mPersistentTablesLoaded = setValue; }
114161
115162 // Hybrid
116163 TrackITSExt* getDeviceTrackITSExt () { return mTrackITSExtDevice ; }
@@ -119,6 +166,45 @@ class TimeFrameGPU : public TimeFrame<NLayers>
119166 TrackExtensionHypothesis<NLayers>* getDeviceNextTrackExtensionHypotheses () { return mNextTrackExtensionHypothesesDevice ; }
120167 int * getDeviceNeighboursLUT (const int layer) { return mNeighboursLUTDevice [layer]; }
121168 CellNeighbour** getDeviceArrayNeighbours () { return mNeighboursDeviceArray ; }
169+ unsigned long long ** getDeviceArrayClusterOwners () { return mClusterOwnersDeviceArray ; }
170+ GPULine* getDeviceLines () { return mLinesDevice ; }
171+ int * getDeviceLineSlots () { return mLineSlotsDevice ; }
172+ int * getDeviceLineRof () { return mLineRofDevice ; }
173+ int * getDeviceLineClusters () { return mLineClustersDevice ; }
174+ float * getDeviceLineChi2 () { return mLineChi2Device ; }
175+ float * getDeviceLinePt () { return mLinePtDevice ; }
176+ float * getDeviceLineZs () { return mLineZsDevice ; }
177+ gpu::LineTime* getDeviceLineTimes () { return mLineTimesDevice ; }
178+ int * getDeviceLineSortedIdx () { return mLinesSortedIdx ; }
179+ LineProjSoA getLineProjSoA () { return {mLineZsDevice , mLineTimesDevice , mLinesSortedIdx , mLineRofDevice }; }
180+ LineProjSoA getLineProjSortedSoA () { return {mLineZsSortedDevice , mLineTimesSortedDevice , mLinesSortedIdx , mLineRofSortedDevice }; }
181+ int * getDeviceRofLineOffsets () { return mRofLineOffsetsDevice ; }
182+ int * getDeviceLineDensity () { return mLineDensityDevice ; }
183+ gpu::LineWindow* getDeviceLineWin () { return mLineWinDevice ; }
184+ uint8_t * getDeviceLineIsPeak () { return mLineIsPeakDevice ; }
185+ int * getDeviceLineDensityFine () { return mLineDensityFineDevice ; }
186+ gpu::LineWindow* getDeviceLineWinFine () { return mLineWinFineDevice ; }
187+ uint8_t * getDeviceLineIsPeakFine () { return mLineIsPeakFineDevice ; }
188+ int * getDevicePeakScan () { return mPeakScanDevice ; }
189+ int * getDevicePeakLineIdx () { return mPeakLineIdxDevice ; }
190+ int * getDevicePeakOffsets () { return mPeakOffsetsDevice ; }
191+ const int * getDeviceNPeaks () { return mPeakOffsetsDevice + this ->getNrof (1 ); }
192+ VertexCand* getDeviceVertexCands () { return mVertexCandsDevice ; }
193+ int * getDeviceMemberOffsets () { return mMemberOffsetsDevice ; }
194+ int * getDeviceMemberLines () { return mMemberLinesDevice ; }
195+ int downloadVertexCandsDevice ();
196+ int getNMembers () const { return mNMembers ; }
197+ void downloadMemberOffsetsDevice (); // (MC only)
198+ void createMemberLinesMCDevice (const int nMembers); // (MC only)
199+ void downloadMemberLinesDevice (); // (MC only)
200+ const auto & getHostVertexCands () const { return mVertexCandsHost ; }
201+ const auto & getHostPeakOffsets () const { return mPeakOffsetsHost ; }
202+ const auto & getHostMemberOffsets () const { return mMemberOffsetsHost ; }
203+ const auto & getHostMemberLines () const { return mMemberLinesHost ; }
204+ std::vector<o2::MCCompLabel>& getLineLabelFlat () { return mLineLabelFlatHost ; }
205+ const std::vector<o2::MCCompLabel>& getLineLabelFlat () const { return mLineLabelFlatHost ; }
206+ Vertex* getDeviceDiamond () { return mDiamondDevice ; }
207+ std::array<CellNeighbour*, MaxCells>& getDeviceNeighboursAll () { return mNeighboursDevice ; }
122208 CellNeighbour* getDeviceNeighbours (const int layer) { return mNeighboursDevice [layer]; }
123209 const TrackingFrameInfo** getDeviceArrayTrackingFrameInfo () const { return mTrackingFrameInfoDeviceArray ; }
124210 const Cluster** getDeviceArrayClusters () const { return mClustersDeviceArray ; }
@@ -215,6 +301,11 @@ class TimeFrameGPU : public TimeFrame<NLayers>
215301 const int ** mClustersIndexTablesDeviceArray {nullptr };
216302 uint8_t ** mUsedClustersDeviceArray {nullptr };
217303 const int ** mROFramesClustersDeviceArray {nullptr };
304+ int * mROFramesPVDevice ;
305+ std::array<int *, NLayers> mClusterSortKeysDevice {};
306+ std::array<int *, NLayers> mClusterSortPermDevice {};
307+ float * mClusterMinRDevice {nullptr };
308+ float * mClusterMaxRDevice {nullptr };
218309 std::array<Tracklet*, MaxLinks> mTrackletsDevice {};
219310 std::array<int *, MaxLinks> mTrackletsLUTDevice {};
220311 std::array<int *, MaxCells> mCellsLUTDevice {};
@@ -239,6 +330,47 @@ class TimeFrameGPU : public TimeFrame<NLayers>
239330 CellNeighbour** mNeighboursDeviceArray {nullptr };
240331 std::array<TrackingFrameInfo*, NLayers> mTrackingFrameInfoDevice {};
241332 const TrackingFrameInfo** mTrackingFrameInfoDeviceArray {nullptr };
333+ std::array<unsigned long long *, 3 > mClusterOwnersDevice {};
334+ unsigned long long ** mClusterOwnersDeviceArray {nullptr };
335+ int * mLineSlotsDevice {nullptr };
336+ GPULine* mLinesDevice {nullptr };
337+ int * mLineRofDevice {nullptr };
338+ int * mLineClustersDevice {nullptr };
339+ float * mLineChi2Device {nullptr };
340+ float * mLinePtDevice {nullptr };
341+ float * mLineZsDevice {nullptr };
342+ gpu::LineTime* mLineTimesDevice {nullptr };
343+ float * mLineZsSortedDevice {nullptr };
344+ gpu::LineTime* mLineTimesSortedDevice {nullptr };
345+ int * mLinesSortedIdx {nullptr };
346+ int * mLineRofSortedDevice {nullptr }; // per (sorted) line's ROF
347+ int * mRofLineOffsetsDevice {nullptr }; // CSR offsets into the (rof,z)-sorted lines, size nRofs+1
348+ int * mLineDensityDevice {nullptr }; // per (sorted) line: count of time-compatible neighbours in its z-window
349+ gpu::LineWindow* mLineWinDevice {nullptr }; // per (sorted) line: [lo,hi) bounds of its z-window (sorted coords)
350+ uint8_t * mLineIsPeakDevice {nullptr }; // per (sorted) line: 1 if it is a local density peak (vertex candidate)
351+ int * mLineDensityFineDevice {nullptr };
352+ gpu::LineWindow* mLineWinFineDevice {nullptr };
353+ uint8_t * mLineIsPeakFineDevice {nullptr };
354+ int * mPeakScanDevice {nullptr }; // per (sorted) line: number of peaks strictly before it
355+ int * mPeakLineIdxDevice {nullptr }; // per peak slot: the sorted line index it came from
356+ int * mPeakOffsetsDevice {nullptr }; // CSR offsets into the compacted peaks
357+ VertexCand* mVertexCandsDevice {nullptr };
358+ int * mMemberOffsetsDevice {nullptr };
359+ int * mMemberLinesDevice {nullptr };
360+ int mNLinesCapacity {0 }; // = nCells the line buffers were sized for
361+ std::vector<GPULine> mLinesHost ;
362+ std::vector<int > mLineRofHost ;
363+ std::vector<int > mLineClustersHost ;
364+ std::vector<VertexCand> mVertexCandsHost ;
365+ std::vector<int > mPeakOffsetsHost ;
366+ std::vector<int > mMemberOffsetsHost ;
367+ std::vector<int > mMemberLinesHost ;
368+ std::vector<o2::MCCompLabel> mLineLabelFlatHost ;
369+ int mNMembers {0 };
370+ Vertex* mDiamondDevice {nullptr };
371+ bool mPersistentTablesLoaded {false };
372+ std::bitset<NLayers> mUnsortedClustersUploaded {};
373+ std::bitset<NLayers> mTrackingFrameInfoUploaded {};
242374
243375 // State
244376 Streams mGpuStreams ;
0 commit comments