2020#include " ITStrackingGPU/Array.h"
2121#include " ITStrackingGPU/Vector.h"
2222#include " ITStrackingGPU/Stream.h"
23+ #include " ITStrackingGPU/TimeFrameChunk.h"
2324
2425#include < gsl/gsl>
2526
2627namespace o2
2728{
28- namespace gpu
29- {
30- class GPUChainITS ;
31- }
3229namespace its
3330{
34- template <typename T1, typename T2>
35- struct gpuPair {
36- T1 first;
37- T2 second;
38- };
39-
4031namespace gpu
4132{
4233
4334class DefaultGPUAllocator : public ExternalAllocator
4435{
4536 void * allocate (size_t size) override ;
4637};
47- template <int nLayers>
48- struct StaticTrackingParameters {
49- StaticTrackingParameters<nLayers>& operator =(const StaticTrackingParameters<nLayers>& t) = default ;
50- void set (const TrackingParameters& pars)
51- {
52- ClusterSharing = pars.ClusterSharing ;
53- MinTrackLength = pars.MinTrackLength ;
54- NSigmaCut = pars.NSigmaCut ;
55- PVres = pars.PVres ;
56- DeltaROF = pars.DeltaROF ;
57- ZBins = pars.ZBins ;
58- PhiBins = pars.PhiBins ;
59- CellDeltaTanLambdaSigma = pars.CellDeltaTanLambdaSigma ;
60- }
61-
62- // / General parameters
63- int ClusterSharing = 0 ;
64- int MinTrackLength = nLayers;
65- float NSigmaCut = 5 ;
66- float PVres = 1 .e-2f ;
67- int DeltaROF = 0 ;
68- int ZBins{256 };
69- int PhiBins{128 };
70-
71- // / Cell finding cuts
72- float CellDeltaTanLambdaSigma = 0 .007f ;
73- };
74-
75- enum class Task {
76- Tracker = 0 ,
77- Vertexer = 1
78- };
79-
80- template <int nLayers>
81- class GpuTimeFrameChunk
82- {
83- public:
84- static size_t computeScalingSizeBytes (const int , const TimeFrameGPUParameters&);
85- static size_t computeFixedSizeBytes (const TimeFrameGPUParameters&);
86- static size_t computeRofPerChunk (const TimeFrameGPUParameters&, const size_t );
87-
88- GpuTimeFrameChunk () = delete ;
89- GpuTimeFrameChunk (o2::its::TimeFrame* tf, TimeFrameGPUParameters& conf)
90- {
91- mTimeFramePtr = tf;
92- mTFGPUParams = &conf;
93- }
94- ~GpuTimeFrameChunk ();
95-
96- // / Most relevant operations
97- void allocate (const size_t , Stream&);
98- void reset (const Task, Stream&);
99- size_t loadDataOnDevice (const size_t , const size_t , const int , Stream&);
100-
101- // / Interface
102- Cluster* getDeviceClusters (const int );
103- int * getDeviceClusterExternalIndices (const int );
104- int * getDeviceIndexTables (const int );
105- Tracklet* getDeviceTracklets (const int );
106- int * getDeviceTrackletsLookupTables (const int );
107- CellSeed* getDeviceCells (const int );
108- int * getDeviceCellsLookupTables (const int );
109- int * getDeviceRoadsLookupTables (const int );
110- TimeFrameGPUParameters* getTimeFrameGPUParameters () const { return mTFGPUParams ; }
111-
112- int * getDeviceCUBTmpBuffer () { return mCUBTmpBufferDevice ; }
113- int * getDeviceFoundTracklets () { return mFoundTrackletsDevice ; }
114- int * getDeviceNFoundCells () { return mNFoundCellsDevice ; }
115- int * getDeviceCellNeigboursLookupTables (const int );
116- int * getDeviceCellNeighbours (const int );
117- CellSeed** getDeviceArrayCells () const { return mCellsDeviceArray ; }
118- int ** getDeviceArrayNeighboursCell () const { return mNeighboursCellDeviceArray ; }
119- int ** getDeviceArrayNeighboursCellLUT () const { return mNeighboursCellLookupTablesDeviceArray ; }
120-
121- // / Vertexer only
122- int * getDeviceNTrackletCluster (const int combid) { return mNTrackletsPerClusterDevice [combid]; }
123- Line* getDeviceLines () { return mLinesDevice ; };
124- int * getDeviceNFoundLines () { return mNFoundLinesDevice ; }
125- int * getDeviceNExclusiveFoundLines () { return mNExclusiveFoundLinesDevice ; }
126- unsigned char * getDeviceUsedTracklets () { return mUsedTrackletsDevice ; }
127- int * getDeviceClusteredLines () { return mClusteredLinesDevice ; }
128- size_t getNPopulatedRof () const { return mNPopulatedRof ; }
129-
130- private:
131- // / Host
132- std::array<gsl::span<const Cluster>, nLayers> mHostClusters ;
133- std::array<gsl::span<const int >, nLayers> mHostIndexTables ;
134-
135- // / Device
136- std::array<Cluster*, nLayers> mClustersDevice ;
137- std::array<int *, nLayers> mClusterExternalIndicesDevice ;
138- std::array<int *, nLayers> mIndexTablesDevice ;
139- std::array<Tracklet*, nLayers - 1 > mTrackletsDevice ;
140- std::array<int *, nLayers - 1 > mTrackletsLookupTablesDevice ;
141- std::array<CellSeed*, nLayers - 2 > mCellsDevice ;
142- // Road<nLayers - 2>* mRoadsDevice;
143- std::array<int *, nLayers - 2 > mCellsLookupTablesDevice ;
144- std::array<int *, nLayers - 3 > mNeighboursCellDevice ;
145- std::array<int *, nLayers - 3 > mNeighboursCellLookupTablesDevice ;
146- std::array<int *, nLayers - 2 > mRoadsLookupTablesDevice ;
147-
148- // These are to make them accessible using layer index
149- CellSeed** mCellsDeviceArray ;
150- int ** mNeighboursCellDeviceArray ;
151- int ** mNeighboursCellLookupTablesDeviceArray ;
152-
153- // Small accessory buffers
154- int * mCUBTmpBufferDevice ;
155- int * mFoundTrackletsDevice ;
156- int * mNFoundCellsDevice ;
157-
158- // / Vertexer only
159- Line* mLinesDevice ;
160- int * mNFoundLinesDevice ;
161- int * mNExclusiveFoundLinesDevice ;
162- unsigned char * mUsedTrackletsDevice ;
163- std::array<int *, 2 > mNTrackletsPerClusterDevice ;
164- int * mClusteredLinesDevice ;
165-
166- // / State and configuration
167- bool mAllocated = false ;
168- size_t mNRof = 0 ;
169- size_t mNPopulatedRof = 0 ;
170- o2::its::TimeFrame* mTimeFramePtr = nullptr ;
171- TimeFrameGPUParameters* mTFGPUParams = nullptr ;
172- };
17338
17439template <int nLayers = 7 >
17540class TimeFrameGPU : public TimeFrame
@@ -191,13 +56,19 @@ class TimeFrameGPU : public TimeFrame
19156 void loadClustersDevice ();
19257 void loadTrackletsDevice ();
19358 void loadCellsDevice ();
59+ void loadCellsLUT ();
19460 void loadTrackSeedsDevice ();
19561 void loadTrackSeedsChi2Device ();
19662 void loadRoadsDevice ();
19763 void loadTrackSeedsDevice (std::vector<CellSeed>&);
198- void createCellNeighboursDevice (const unsigned int & layer, std::vector<std::pair<int , int >>& neighbours);
64+ void createNeighboursDevice (const unsigned int & layer, std::vector<std::pair<int , int >>& neighbours);
65+ void createNeighboursLUTDevice (const int , const unsigned int );
19966 void createTrackITSExtDevice (std::vector<CellSeed>&);
20067 void downloadTrackITSExtDevice (std::vector<CellSeed>&);
68+ void downloadCellsNeighbours (std::vector<std::vector<std::pair<int , int >>>&, const int );
69+ void downloadNeighboursLUT (std::vector<int >&, const int );
70+ void downloadCellsDevice (const int );
71+ void unregisterRest ();
20172 void initDeviceChunks (const int , const int );
20273 template <Task task>
20374 size_t loadChunkData (const size_t , const size_t , const size_t );
@@ -224,17 +95,22 @@ class TimeFrameGPU : public TimeFrame
22495 // Hybrid
22596 Road<nLayers - 2 >* getDeviceRoads () { return mRoadsDevice ; }
22697 TrackITSExt* getDeviceTrackITSExt () { return mTrackITSExtDevice ; }
98+ int * getDeviceNeighboursLUT (const int layer) { return mNeighboursLUTDevice [layer]; }
22799 gpuPair<int , int >* getDeviceNeighbours (const int layer) { return mNeighboursDevice [layer]; }
228100 TrackingFrameInfo* getDeviceTrackingFrameInfo (const int );
229101 // TrackingFrameInfo** getDeviceArrayTrackingFrameInfo() { return mTrackingFrameInfoDeviceArray; }
230102 const TrackingFrameInfo** getDeviceArrayTrackingFrameInfo () const { return mTrackingFrameInfoDeviceArray ; }
231103 Cluster** getDeviceArrayClusters () const { return mClustersDeviceArray ; }
232104 Cluster** getDeviceArrayUnsortedClusters () const { return mUnsortedClustersDeviceArray ; }
233105 Tracklet** getDeviceArrayTracklets () const { return mTrackletsDeviceArray ; }
106+ int ** getDeviceArrayCellsLUT () const { return mCellsLUTDeviceArray ; }
107+ int ** getDeviceArrayNeighboursCellLUT () const { return mNeighboursCellLUTDeviceArray ; }
234108 CellSeed** getDeviceArrayCells () const { return mCellsDeviceArray ; }
235109 CellSeed* getDeviceTrackSeeds () { return mTrackSeedsDevice ; }
236110 o2::track::TrackParCovF** getDeviceArrayTrackSeeds () { return mCellSeedsDeviceArray ; }
237111 float ** getDeviceArrayTrackSeedsChi2 () { return mCellSeedsChi2DeviceArray ; }
112+ int * getDeviceNeighboursIndexTables (const int layer) { return mNeighboursIndexTablesDevice [layer]; }
113+
238114 void setDevicePropagator (const o2::base::PropagatorImpl<float >*) override ;
239115
240116 // Host-specific getters
@@ -263,7 +139,13 @@ class TimeFrameGPU : public TimeFrame
263139 Cluster** mUnsortedClustersDeviceArray ;
264140 std::array<Tracklet*, nLayers - 1 > mTrackletsDevice ;
265141 Tracklet** mTrackletsDeviceArray ;
142+ std::array<int *, nLayers - 2 > mCellsLUTDevice ;
143+ std::array<int *, nLayers - 3 > mNeighboursLUTDevice ;
144+ int ** mCellsLUTDeviceArray ;
145+ int ** mNeighboursCellDeviceArray ;
146+ int ** mNeighboursCellLUTDeviceArray ;
266147 std::array<CellSeed*, nLayers - 2 > mCellsDevice ;
148+ std::array<int *, nLayers - 2 > mNeighboursIndexTablesDevice ;
267149 CellSeed* mTrackSeedsDevice ;
268150 CellSeed** mCellsDeviceArray ;
269151 std::array<o2::track::TrackParCovF*, nLayers - 2 > mCellSeedsDevice ;
0 commit comments