Project
Loading...
Searching...
No Matches
TimeFrameGPU.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
12
13#ifndef TRACKINGITSGPU_INCLUDE_TIMEFRAMEGPU_H
14#define TRACKINGITSGPU_INCLUDE_TIMEFRAMEGPU_H
15
18
21
22#include <gsl/gsl>
23
24namespace o2
25{
26namespace its
27{
28namespace gpu
29{
30class Stream;
31
33{
34 void* allocate(size_t size) override;
35};
36
37template <int nLayers = 7>
38class TimeFrameGPU : public TimeFrame
39{
40 public:
43
45 void registerHostMemory(const int);
46 void unregisterHostMemory(const int);
47 void initialise(const int, const TrackingParameters&, const int, IndexTableUtils* utils = nullptr, const TimeFrameGPUParameters* pars = nullptr);
48 void initDevice(IndexTableUtils*, const TrackingParameters& trkParam, const TimeFrameGPUParameters&, const int, const int);
50 void loadIndexTableUtils(const int);
53 void loadClustersDevice(const int);
54 void loadClustersIndexTables(const int iteration);
55 void createUsedClustersDevice(const int);
58 void loadMultiplicityCutMask(const int);
59 void loadVertices(const int);
60
62 void createTrackletsLUTDevice(const int);
70 void loadTrackSeedsDevice(std::vector<CellSeed>&);
72 void createCellsBuffers(const int);
76 void createNeighboursDevice(const unsigned int layer, const unsigned int nNeighbours);
77 void createNeighboursDevice(const unsigned int layer, std::vector<std::pair<int, int>>& neighbours);
78 void createNeighboursLUTDevice(const int, const unsigned int);
80 void createTrackITSExtDevice(std::vector<CellSeed>&);
81 void downloadTrackITSExtDevice(std::vector<CellSeed>&);
82 void downloadCellsNeighboursDevice(std::vector<std::vector<std::pair<int, int>>>&, const int);
83 void downloadNeighboursLUTDevice(std::vector<int>&, const int);
87 template <Task task>
88 Stream& getStream(const size_t stream)
89 {
90 return *mGpuStreams[stream];
91 }
92 void wipe(const int);
93
95 int getNClustersInRofSpan(const int, const int, const int) const;
96 IndexTableUtils* getDeviceIndexTableUtils() { return mIndexTableUtilsDevice; }
97 int* getDeviceROFramesClusters(const int layer) { return mROFramesClustersDevice[layer]; }
98 std::vector<o2::its::TrackITSExt>& getTrackITSExt() { return mTrackITSExt; }
99 Vertex* getDeviceVertices() { return mPrimaryVerticesDevice; }
100 int* getDeviceROFramesPV() { return mROFramesPVDevice; }
101 unsigned char* getDeviceUsedClusters(const int);
103
104 // Hybrid
105 Road<nLayers - 2>* getDeviceRoads() { return mRoadsDevice; }
106 TrackITSExt* getDeviceTrackITSExt() { return mTrackITSExtDevice; }
107 int* getDeviceNeighboursLUT(const int layer) { return mNeighboursLUTDevice[layer]; }
108 gsl::span<int*> getDeviceNeighboursLUTs() { return mNeighboursLUTDevice; }
109 gpuPair<int, int>* getDeviceNeighbourPairs(const int layer) { return mNeighbourPairsDevice[layer]; }
110 std::array<int*, nLayers - 2>& getDeviceNeighboursAll() { return mNeighboursDevice; }
111 int* getDeviceNeighbours(const int layer) { return mNeighboursDevice[layer]; }
112 int** getDeviceNeighboursArray() { return mNeighboursDeviceArray; }
113 TrackingFrameInfo* getDeviceTrackingFrameInfo(const int);
114 const TrackingFrameInfo** getDeviceArrayTrackingFrameInfo() const { return mTrackingFrameInfoDeviceArray; }
115 const Cluster** getDeviceArrayClusters() const { return mClustersDeviceArray; }
116 const Cluster** getDeviceArrayUnsortedClusters() const { return mUnsortedClustersDeviceArray; }
117 const int** getDeviceArrayClustersIndexTables() const { return mClustersIndexTablesDeviceArray; }
118 std::vector<unsigned int> getClusterSizes();
119 const unsigned char** getDeviceArrayUsedClusters() const { return mUsedClustersDeviceArray; }
120 const int** getDeviceROframeClusters() const { return mROFrameClustersDeviceArray; }
121 Tracklet** getDeviceArrayTracklets() { return mTrackletsDeviceArray; }
122 int** getDeviceArrayTrackletsLUT() const { return mTrackletsLUTDeviceArray; }
123 int** getDeviceArrayCellsLUT() const { return mCellsLUTDeviceArray; }
124 int** getDeviceArrayNeighboursCellLUT() const { return mNeighboursCellLUTDeviceArray; }
125 CellSeed** getDeviceArrayCells() const { return mCellsDeviceArray; }
126 CellSeed* getDeviceTrackSeeds() { return mTrackSeedsDevice; }
127 o2::track::TrackParCovF** getDeviceArrayTrackSeeds() { return mCellSeedsDeviceArray; }
128 float** getDeviceArrayTrackSeedsChi2() { return mCellSeedsChi2DeviceArray; }
129 int* getDeviceNeighboursIndexTables(const int layer) { return mNeighboursIndexTablesDevice[layer]; }
130 uint8_t* getDeviceMultCutMask() { return mMultMaskDevice; }
131
133
134 // Host-specific getters
135 gsl::span<int, nLayers - 1> getNTracklets() { return mNTracklets; }
136 gsl::span<int, nLayers - 2> getNCells() { return mNCells; }
137 std::array<int, nLayers - 2>& getArrayNCells() { return mNCells; }
138
139 // Host-available device getters
140 gsl::span<int*> getDeviceTrackletsLUTs() { return mTrackletsLUTDevice; }
141 gsl::span<int*> getDeviceCellLUTs() { return mCellsLUTDevice; }
142 gsl::span<Tracklet*> getDeviceTracklet() { return mTrackletsDevice; }
143 gsl::span<CellSeed*> getDeviceCells() { return mCellsDevice; }
144
145 // Overridden getters
146 int getNumberOfCells() const;
147
148 private:
149 void allocMemAsync(void**, size_t, Stream*, bool); // Abstract owned and unowned memory allocations
150 bool mHostRegistered = false;
151 TimeFrameGPUParameters mGpuParams;
152
153 // Host-available device buffer sizes
154 std::array<int, nLayers - 1> mNTracklets;
155 std::array<int, nLayers - 2> mNCells;
156
157 // Device pointers
158 IndexTableUtils* mIndexTableUtilsDevice;
159
160 // Hybrid pref
161 uint8_t* mMultMaskDevice;
162 Vertex* mPrimaryVerticesDevice;
163 int* mROFramesPVDevice;
164 std::array<Cluster*, nLayers> mClustersDevice;
165 std::array<Cluster*, nLayers> mUnsortedClustersDevice;
166 std::array<int*, nLayers> mClustersIndexTablesDevice;
167 std::array<unsigned char*, nLayers> mUsedClustersDevice;
168 std::array<int*, nLayers> mROFramesClustersDevice;
169 const Cluster** mClustersDeviceArray;
170 const Cluster** mUnsortedClustersDeviceArray;
171 const int** mClustersIndexTablesDeviceArray;
172 const unsigned char** mUsedClustersDeviceArray;
173 const int** mROFrameClustersDeviceArray;
174 std::array<Tracklet*, nLayers - 1> mTrackletsDevice;
175 Tracklet** mTrackletsDeviceArray;
176 std::array<int*, nLayers - 1> mTrackletsLUTDevice;
177 std::array<int*, nLayers - 2> mCellsLUTDevice;
178 std::array<int*, nLayers - 3> mNeighboursLUTDevice;
179
180 int** mCellsLUTDeviceArray;
181 int** mNeighboursCellDeviceArray;
182 int** mNeighboursCellLUTDeviceArray;
183 int** mTrackletsLUTDeviceArray;
184 std::array<CellSeed*, nLayers - 2> mCellsDevice;
185 std::array<int*, nLayers - 2> mNeighboursIndexTablesDevice;
186 CellSeed* mTrackSeedsDevice;
187 CellSeed** mCellsDeviceArray;
188 std::array<o2::track::TrackParCovF*, nLayers - 2> mCellSeedsDevice;
189 o2::track::TrackParCovF** mCellSeedsDeviceArray;
190 std::array<float*, nLayers - 2> mCellSeedsChi2Device;
191 float** mCellSeedsChi2DeviceArray;
192
193 Road<nLayers - 2>* mRoadsDevice;
194 TrackITSExt* mTrackITSExtDevice;
195 std::array<gpuPair<int, int>*, nLayers - 2> mNeighbourPairsDevice;
196 std::array<int*, nLayers - 2> mNeighboursDevice;
197 int** mNeighboursDeviceArray;
198 std::array<TrackingFrameInfo*, nLayers> mTrackingFrameInfoDevice;
199 const TrackingFrameInfo** mTrackingFrameInfoDeviceArray;
200
201 // State
202 std::vector<Stream*> mGpuStreams;
203 size_t mAvailMemGB;
204 bool mFirstInit = true;
205
206 // Temporary buffer for storing output tracks from GPU tracking
207 std::vector<TrackITSExt> mTrackITSExt;
208};
209
210template <int nLayers>
211inline int TimeFrameGPU<nLayers>::getNClustersInRofSpan(const int rofIdstart, const int rofSpanSize, const int layerId) const
212{
213 return static_cast<int>(mROFramesClusters[layerId][(rofIdstart + rofSpanSize) < mROFramesClusters.size() ? rofIdstart + rofSpanSize : mROFramesClusters.size() - 1] - mROFramesClusters[layerId][rofIdstart]);
214}
215
216template <int nLayers>
217inline std::vector<unsigned int> TimeFrameGPU<nLayers>::getClusterSizes()
218{
219 std::vector<unsigned int> sizes(mUnsortedClusters.size());
220 std::transform(mUnsortedClusters.begin(), mUnsortedClusters.end(), sizes.begin(),
221 [](const auto& v) { return static_cast<unsigned int>(v.size()); });
222 return sizes;
223}
224
225template <int nLayers>
227{
228 return std::accumulate(mNCells.begin(), mNCells.end(), 0);
229}
230
231} // namespace gpu
232} // namespace its
233} // namespace o2
234#endif
GPU-compliant version of ClusterLines, for the moment separated, might create a common traits for Clu...
const TrackingFrameInfo ** getDeviceArrayTrackingFrameInfo() const
gsl::span< int * > getDeviceCellLUTs()
void createNeighboursDevice(const unsigned int layer, const unsigned int nNeighbours)
void loadROframeClustersDevice(const int)
IndexTableUtils * getDeviceIndexTableUtils()
const unsigned char ** getDeviceArrayUsedClusters() const
const int ** getDeviceArrayClustersIndexTables() const
void initDevice(IndexTableUtils *, const TrackingParameters &trkParam, const TimeFrameGPUParameters &, const int, const int)
void initialise(const int, const TrackingParameters &, const int, IndexTableUtils *utils=nullptr, const TimeFrameGPUParameters *pars=nullptr)
const Cluster ** getDeviceArrayUnsortedClusters() const
void loadTrackingFrameInfoDevice(const int)
int * getDeviceNeighbours(const int layer)
int * getDeviceNeighboursIndexTables(const int layer)
void downloadNeighboursLUTDevice(std::vector< int > &, const int)
void loadIndexTableUtils(const int)
float ** getDeviceArrayTrackSeedsChi2()
void createNeighboursLUTDevice(const int, const unsigned int)
Tracklet ** getDeviceArrayTracklets()
TrackingFrameInfo * getDeviceTrackingFrameInfo(const int)
void createTrackletsLUTDevice(const int)
int getNClustersInRofSpan(const int, const int, const int) const
interface
gsl::span< int, nLayers - 2 > getNCells()
void setDevicePropagator(const o2::base::PropagatorImpl< float > *) override
void createTrackITSExtDevice(std::vector< CellSeed > &)
std::array< int *, nLayers - 2 > & getDeviceNeighboursAll()
gsl::span< Tracklet * > getDeviceTracklet()
CellSeed ** getDeviceArrayCells() const
void createNeighboursDevice(const unsigned int layer, std::vector< std::pair< int, int > > &neighbours)
void loadVertices(const int)
int * getDeviceNeighboursLUT(const int layer)
std::vector< o2::its::TrackITSExt > & getTrackITSExt()
Road< nLayers - 2 > * getDeviceRoads()
void registerHostMemory(const int)
Most relevant operations.
void loadClustersIndexTables(const int iteration)
o2::track::TrackParCovF ** getDeviceArrayTrackSeeds()
void downloadTrackITSExtDevice(std::vector< CellSeed > &)
gsl::span< int * > getDeviceNeighboursLUTs()
std::vector< unsigned int > getClusterSizes()
const o2::base::Propagator * getChainPropagator()
int ** getDeviceArrayNeighboursCellLUT() const
void createUsedClustersDevice(const int)
const int ** getDeviceROframeClusters() const
gsl::span< CellSeed * > getDeviceCells()
int ** getDeviceArrayTrackletsLUT() const
gsl::span< int * > getDeviceTrackletsLUTs()
void createCellsBuffers(const int)
unsigned char * getDeviceUsedClusters(const int)
gpuPair< int, int > * getDeviceNeighbourPairs(const int layer)
std::array< int, nLayers - 2 > & getArrayNCells()
void loadClustersDevice(const int)
Stream & getStream(const size_t stream)
TrackITSExt * getDeviceTrackITSExt()
void loadMultiplicityCutMask(const int)
int ** getDeviceArrayCellsLUT() const
void loadUnsortedClustersDevice(const int)
void loadTrackSeedsDevice(std::vector< CellSeed > &)
int * getDeviceROFramesClusters(const int layer)
const Cluster ** getDeviceArrayClusters() const
void downloadCellsNeighboursDevice(std::vector< std::vector< std::pair< int, int > > > &, const int)
void unregisterHostMemory(const int)
gsl::span< int, nLayers - 1 > getNTracklets()
GLsizeiptr size
Definition glcorearb.h:659
const GLdouble * v
Definition glcorearb.h:832
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
Definition glcorearb.h:2595
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
GLuint GLuint stream
Definition glcorearb.h:1806
TrackParametrizationWithError< float > TrackParCovF
Definition Track.h:31
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Common utility functions.