-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathGPUTPCTrackingData.h
More file actions
184 lines (147 loc) · 8.53 KB
/
GPUTPCTrackingData.h
File metadata and controls
184 lines (147 loc) · 8.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file GPUTPCTrackingData.h
/// \author Matthias Kretz, Sergey Gorbunov, David Rohr
#ifndef GPUTPCSECTORDATA_H
#define GPUTPCSECTORDATA_H
#include "GPUTPCDef.h"
#include "GPUTPCRow.h"
#include "GPUCommonMath.h"
#include "GPUParam.h"
#include "GPUProcessor.h"
namespace o2::gpu
{
struct GPUTPCClusterData;
class GPUTPCHit;
class GPUTPCTrackingData
{
public:
GPUTPCTrackingData() = default;
#ifndef GPUCA_GPUCODE_DEVICE
~GPUTPCTrackingData() = default;
void InitializeRows(const GPUParam& p);
void SetMaxData();
void SetClusterData(int32_t nClusters, int32_t clusterIdOffset);
void* SetPointersScratch(void* mem, bool idsOnGPU);
void* SetPointersLinks(void* mem);
void* SetPointersWeights(void* mem);
void* SetPointersClusterIds(void* mem, bool idsOnGPU);
void* SetPointersRows(void* mem);
#endif
GPUd() int32_t InitFromClusterData(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUconstantref() const GPUConstantMem* mem, int32_t iSector, float* tmpMinMax);
/**
* Return the number of hits in this sector.
*/
GPUhd() int32_t NumberOfHits() const { return mNumberOfHits; }
GPUhd() int32_t NumberOfHitsPlusAlign() const { return mNumberOfHitsPlusAlign; }
GPUhd() int32_t ClusterIdOffset() const { return mClusterIdOffset; }
/**
* Access to the hit links.
*
* The links values give the hit index in the row above/below. Or -1 if there is no link.
*/
GPUd() calink HitLinkUpData(const GPUTPCRow& row, const calink& hitIndex) const;
GPUd() calink HitLinkDownData(const GPUTPCRow& row, const calink& hitIndex) const;
GPUhdi() GPUglobalref() const cahit2* HitData(const GPUTPCRow& row) const { return &mHitData[row.mHitNumberOffset]; }
GPUhdi() GPUglobalref() cahit2* HitData(const GPUTPCRow& row) { return &mHitData[row.mHitNumberOffset]; }
GPUhd() GPUglobalref() const cahit2* HitData() const { return (mHitData); }
GPUdi() GPUglobalref() const calink* HitLinkUpData(const GPUTPCRow& row) const { return &mLinkUpData[row.mHitNumberOffset]; }
GPUdi() GPUglobalref() calink* HitLinkUpData(const GPUTPCRow& row) { return &mLinkUpData[row.mHitNumberOffset]; }
GPUdi() GPUglobalref() const calink* HitLinkDownData(const GPUTPCRow& row) const { return &mLinkDownData[row.mHitNumberOffset]; }
GPUdi() GPUglobalref() const calink* FirstHitInBin(const GPUTPCRow& row) const { return &mFirstHitInBin[row.mFirstHitInBinOffset]; }
GPUd() void SetHitLinkUpData(const GPUTPCRow& row, const calink& hitIndex, const calink& value);
GPUd() void SetHitLinkDownData(const GPUTPCRow& row, const calink& hitIndex, const calink& value);
/**
* Return the y and z coordinate(s) of the given hit(s).
*/
GPUd() cahit HitDataY(const GPUTPCRow& row, const uint32_t& hitIndex) const;
GPUd() cahit HitDataZ(const GPUTPCRow& row, const uint32_t& hitIndex) const;
GPUd() cahit2 HitData(const GPUTPCRow& row, const uint32_t& hitIndex) const;
/**
* For a given bin index, content tells how many hits there are in the preceding bins. This maps
* directly to the hit index in the given row.
*
* \param binIndexes in the range 0 to row.Grid.N + row.Grid.Ny + 3.
*/
GPUd() calink FirstHitInBin(const GPUTPCRow& row, calink binIndex) const;
/**
* If the given weight is higher than what is currently stored replace with the new weight.
*/
GPUd() void MaximizeHitWeight(const GPUTPCRow& row, uint32_t hitIndex, uint32_t weight);
GPUd() void SetHitWeight(const GPUTPCRow& row, uint32_t hitIndex, uint32_t weight);
/**
* Return the maximal weight the given hit got from one tracklet
*/
GPUd() int32_t HitWeight(const GPUTPCRow& row, uint32_t hitIndex) const;
/**
* Returns the index in the original GPUTPCClusterData object of the given hit
*/
GPUhd() int32_t ClusterDataIndex(const GPUTPCRow& row, uint32_t hitIndex) const;
GPUd() GPUglobalref() const int32_t* ClusterDataIndex() const { return mClusterDataIndex; }
GPUd() GPUglobalref() int32_t* ClusterDataIndex() { return mClusterDataIndex; }
/**
* Return the row object for the given row index.
*/
GPUhdi() GPUglobalref() const GPUTPCRow& Row(int32_t rowIndex) const { return mRows[rowIndex]; }
GPUhdi() GPUglobalref() GPUTPCRow* Rows() const { return mRows; }
GPUhdi() GPUglobalref() GPUAtomic(uint32_t) * HitWeights() { return (mHitWeights); }
private:
#ifndef GPUCA_GPUCODE
GPUTPCTrackingData& operator=(const GPUTPCTrackingData&) = delete; // ROOT 5 tries to use this if it is not private
GPUTPCTrackingData(const GPUTPCTrackingData&) = delete; //
#endif
GPUd() void CreateGrid(GPUconstantref() const GPUConstantMem* mem, GPUTPCRow* GPUrestrict() row, float yMin, float yMax, float zMin, float zMax);
GPUd() void SetRowGridEmpty(GPUTPCRow& GPUrestrict() row);
GPUd() static void GetMaxNBins(GPUconstantref() const GPUConstantMem* mem, GPUTPCRow* GPUrestrict() row, int32_t& maxY, int32_t& maxZ);
GPUd() uint32_t GetGridSize(uint32_t nHits, uint32_t nRows);
friend class GPUTPCNeighboursFinder;
friend class GPUTPCStartHitsFinder;
int32_t mNumberOfHits = 0; // the number of hits in this sector
int32_t mNumberOfHitsPlusAlign = 0;
int32_t mClusterIdOffset = 0;
GPUglobalref() GPUTPCRow* mRows = nullptr; // The row objects needed for most accessor functions
GPUglobalref() calink* mLinkUpData = nullptr; // hit index in the row above which is linked to the given (global) hit index
GPUglobalref() calink* mLinkDownData = nullptr; // hit index in the row below which is linked to the given (global) hit index
GPUglobalref() cahit2* mHitData = nullptr; // packed y,z coordinate of the given (global) hit index
GPUglobalref() int32_t* mClusterDataIndex = nullptr; // see ClusterDataIndex()
/*
* The size of the array is row.Grid.N + row.Grid.Ny + 3. The row.Grid.Ny + 3 is an optimization
* to remove the need for bounds checking. The last values are the same as the entry at [N - 1].
*/
GPUglobalref() calink* mFirstHitInBin; // see FirstHitInBin
GPUglobalref() GPUAtomic(uint32_t) * mHitWeights; // the weight of the longest tracklet crossed the cluster
};
GPUdi() calink GPUTPCTrackingData::HitLinkUpData(const GPUTPCRow& row, const calink& hitIndex) const { return mLinkUpData[row.mHitNumberOffset + hitIndex]; }
GPUdi() calink GPUTPCTrackingData::HitLinkDownData(const GPUTPCRow& row, const calink& hitIndex) const { return mLinkDownData[row.mHitNumberOffset + hitIndex]; }
GPUdi() void GPUTPCTrackingData::SetHitLinkUpData(const GPUTPCRow& row, const calink& hitIndex, const calink& value)
{
mLinkUpData[row.mHitNumberOffset + hitIndex] = value;
}
GPUdi() void GPUTPCTrackingData::SetHitLinkDownData(const GPUTPCRow& row, const calink& hitIndex, const calink& value)
{
mLinkDownData[row.mHitNumberOffset + hitIndex] = value;
}
GPUdi() cahit GPUTPCTrackingData::HitDataY(const GPUTPCRow& row, const uint32_t& hitIndex) const { return mHitData[row.mHitNumberOffset + hitIndex].x; }
GPUdi() cahit GPUTPCTrackingData::HitDataZ(const GPUTPCRow& row, const uint32_t& hitIndex) const { return mHitData[row.mHitNumberOffset + hitIndex].y; }
GPUdi() cahit2 GPUTPCTrackingData::HitData(const GPUTPCRow& row, const uint32_t& hitIndex) const { return mHitData[row.mHitNumberOffset + hitIndex]; }
GPUdi() calink GPUTPCTrackingData::FirstHitInBin(const GPUTPCRow& row, calink binIndex) const { return mFirstHitInBin[row.mFirstHitInBinOffset + binIndex]; }
GPUhdi() int32_t GPUTPCTrackingData::ClusterDataIndex(const GPUTPCRow& row, uint32_t hitIndex) const { return mClusterDataIndex[row.mHitNumberOffset + hitIndex]; }
GPUdi() void GPUTPCTrackingData::MaximizeHitWeight(const GPUTPCRow& row, uint32_t hitIndex, uint32_t weight)
{
CAMath::AtomicMax(&mHitWeights[row.mHitNumberOffset + hitIndex], weight);
}
GPUdi() void GPUTPCTrackingData::SetHitWeight(const GPUTPCRow& row, uint32_t hitIndex, uint32_t weight)
{
mHitWeights[row.mHitNumberOffset + hitIndex] = weight;
}
GPUdi() int32_t GPUTPCTrackingData::HitWeight(const GPUTPCRow& row, uint32_t hitIndex) const { return mHitWeights[row.mHitNumberOffset + hitIndex]; }
} // namespace o2::gpu
#endif // GPUTPCSECTORDATA_H