Skip to content

Commit 51a5651

Browse files
committed
GPU: Change some defines to constexpr variables, some renaming
1 parent 1883e2d commit 51a5651

File tree

117 files changed

+650
-674
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+650
-674
lines changed

Detectors/TPC/calibration/src/CorrectdEdxDistortions.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ float o2::tpc::CorrectdEdxDistortions::getCorrection(const float time, unsigned
8787
const float ly = mTPCGeometry.LinearPad2Y(sector, padrow, pad);
8888

8989
// get correction at "pad + 0.5*padlength" pos1 and dont extrapolate/interpolate across GEM gaps
90-
const int row1 = ((padrow == mTPCGeometry.EndIROC() - 1) || (padrow == mTPCGeometry.EndOROC1() - 1) || (padrow == mTPCGeometry.EndOROC2() - 1)) ? padrow : std::clamp(padrow + 1, 0, GPUCA_NROWS - 1);
90+
const int row1 = ((padrow == mTPCGeometry.EndIROC() - 1) || (padrow == mTPCGeometry.EndOROC1() - 1) || (padrow == mTPCGeometry.EndOROC2() - 1)) ? padrow : std::clamp(padrow + 1, 0, o2::tpc::constants::MAXGLOBALPADROW - 1);
9191

9292
float lxT_1 = 0;
9393
float lyT_1 = 0;
@@ -101,7 +101,7 @@ float o2::tpc::CorrectdEdxDistortions::getCorrection(const float time, unsigned
101101
const float r_1_f = std::sqrt(lxT_1 * lxT_1 + lyT_1 * lyT_1);
102102

103103
// get correction at "pad - 0.5*padlength" pos0 and dont extrapolate/interpolate across GEM gaps
104-
const int row0 = ((padrow == mTPCGeometry.EndIROC()) || (padrow == mTPCGeometry.EndOROC1()) || (padrow == mTPCGeometry.EndOROC2())) ? padrow : std::clamp(padrow - 1, 0, GPUCA_NROWS - 1);
104+
const int row0 = ((padrow == mTPCGeometry.EndIROC()) || (padrow == mTPCGeometry.EndOROC1()) || (padrow == mTPCGeometry.EndOROC2())) ? padrow : std::clamp(padrow - 1, 0, o2::tpc::constants::MAXGLOBALPADROW - 1);
105105

106106
// check if previous pad row has enough pads
107107
const unsigned char pad0 = std::clamp(static_cast<int>(pad), 0, mTPCGeometry.NPads(row0) - 1);

Detectors/TPC/monitor/src/SimpleEventDisplayGUI.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ void SimpleEventDisplayGUI::showClusters(int roc, int row)
12271227
}
12281228
if (fillSingleTB && std::abs(cl.getTime() - timeBin) < 2) {
12291229
const auto ly = gpuGeom.LinearPad2Y(sector, irow, cl.getPad() + 0.5);
1230-
mClustersRowPad->SetNextPoint(gpuGeom.Row2X(irow), (sector >= GPUCA_NSECTORS / 2) ? -ly : ly);
1230+
mClustersRowPad->SetNextPoint(gpuGeom.Row2X(irow), (sector >= gpuGeom.NSECTORS / 2) ? -ly : ly);
12311231
}
12321232
}
12331233
// fmt::print("\n");

Detectors/TPC/workflow/src/EntropyEncoderSpec.cxx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void EntropyEncoderSpec::run(ProcessingContext& pc)
158158

159159
const auto& tinfo = pc.services().get<o2::framework::TimingInfo>();
160160
const auto firstIR = o2::InteractionRecord(0, tinfo.firstTForbit);
161-
const float totalT = std::max(mFastTransform->getMaxDriftTime(0), mFastTransform->getMaxDriftTime(GPUCA_NSECTORS / 2));
161+
const float totalT = std::max(mFastTransform->getMaxDriftTime(0), mFastTransform->getMaxDriftTime(GPUTPCGeometry::NSECTORS / 2));
162162

163163
unsigned int offset = 0, lasti = 0;
164164
const unsigned int maxTime = (mParam->continuousMaxTimeBin + 1) * o2::tpc::ClusterNative::scaleTimePacked - 1;
@@ -205,23 +205,23 @@ void EntropyEncoderSpec::run(ProcessingContext& pc)
205205
}
206206
}
207207
offset = 0;
208-
unsigned int offsets[GPUCA_NSECTORS][GPUCA_NROWS];
209-
for (unsigned int i = 0; i < GPUCA_NSECTORS; i++) {
210-
for (unsigned int j = 0; j < GPUCA_NROWS; j++) {
211-
if (i * GPUCA_NROWS + j >= clusters.nSliceRows) {
208+
unsigned int offsets[GPUTPCGeometry::NSECTORS][GPUTPCGeometry::NROWS];
209+
for (unsigned int i = 0; i < GPUTPCGeometry::NSECTORS; i++) {
210+
for (unsigned int j = 0; j < GPUTPCGeometry::NROWS; j++) {
211+
if (i * GPUTPCGeometry::NROWS + j >= clusters.nSliceRows) {
212212
break;
213213
}
214214
offsets[i][j] = offset;
215-
offset += (i * GPUCA_NROWS + j >= clusters.nSliceRows) ? 0 : clusters.nSliceRowClusters[i * GPUCA_NROWS + j];
215+
offset += (i * GPUTPCGeometry::NROWS + j >= clusters.nSliceRows) ? 0 : clusters.nSliceRowClusters[i * GPUTPCGeometry::NROWS + j];
216216
}
217217
}
218218

219219
#ifdef WITH_OPENMP
220-
#pragma omp parallel for num_threads(mNThreads) schedule(static, (GPUCA_NSECTORS + mNThreads - 1) / mNThreads) // Static round-robin scheduling with one chunk per thread to ensure correct order of the final vector
220+
#pragma omp parallel for num_threads(mNThreads) schedule(static, (GPUTPCGeometry::NSECTORS + mNThreads - 1) / mNThreads) // Static round-robin scheduling with one chunk per thread to ensure correct order of the final vector
221221
#endif
222222
for (unsigned int ii = 0; ii < clusters.nSliceRows; ii++) {
223-
unsigned int i = ii / GPUCA_NROWS;
224-
unsigned int j = ii % GPUCA_NROWS;
223+
unsigned int i = ii / GPUTPCGeometry::NROWS;
224+
unsigned int j = ii % GPUTPCGeometry::NROWS;
225225
o2::tpc::ClusterNative preCl;
226226
#ifdef WITH_OPENMP
227227
int myThread = omp_get_thread_num();
@@ -240,7 +240,7 @@ void EntropyEncoderSpec::run(ProcessingContext& pc)
240240
const bool reject = mCTFCoder.getIRFramesSelector().check(o2::dataformats::IRFrame(chkVal, chkVal + 1), chkExt, 0) < 0;
241241
if (reject) {
242242
rejectHits[k] = true;
243-
clustersFiltered.nSliceRowClusters[i * GPUCA_NROWS + j]--;
243+
clustersFiltered.nSliceRowClusters[i * GPUTPCGeometry::NROWS + j]--;
244244
static std::atomic_flag lock = ATOMIC_FLAG_INIT;
245245
while (lock.test_and_set(std::memory_order_acquire)) {
246246
}
@@ -253,7 +253,7 @@ void EntropyEncoderSpec::run(ProcessingContext& pc)
253253
preCl = cl;
254254
}
255255
};
256-
unsigned int end = offsets[i][j] + clusters.nSliceRowClusters[i * GPUCA_NROWS + j];
256+
unsigned int end = offsets[i][j] + clusters.nSliceRowClusters[i * GPUTPCGeometry::NROWS + j];
257257
o2::gpu::TPCClusterDecompressionCore::decompressHits(clusters, offsets[i][j], end, checker);
258258
}
259259
tmpBuffer[0].first.reserve(clustersFiltered.nUnattachedClusters);

GPU/GPUTracking/Base/GPUConstantMem.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ namespace o2::gpu
4040
{
4141
struct GPUConstantMem {
4242
GPUParam param;
43-
GPUTPCTracker tpcTrackers[GPUCA_NSECTORS];
43+
GPUTPCTracker tpcTrackers[GPUTPCGeometry::NSECTORS];
4444
GPUTPCCompression tpcCompressor;
4545
GPUTPCDecompression tpcDecompressor;
4646
GPUTPCGMMerger tpcMerger;
4747
GPUTRDTrackerGPU trdTrackerGPU;
4848
GPUTRDTracker trdTrackerO2;
49-
GPUTPCClusterFinder tpcClusterer[GPUCA_NSECTORS];
49+
GPUTPCClusterFinder tpcClusterer[GPUTPCGeometry::NSECTORS];
5050
GPUTrackingRefitProcessor trackingRefit;
5151
GPUTrackingInOutPointers ioPtrs;
5252
GPUCalibObjectsConst calibObjects;
@@ -55,7 +55,7 @@ struct GPUConstantMem {
5555
GPUKernelDebugOutput debugOutput;
5656
#endif
5757
#ifdef GPUCA_HAS_ONNX
58-
GPUTPCNNClusterizer tpcNNClusterer[GPUCA_NSECTORS];
58+
GPUTPCNNClusterizer tpcNNClusterer[GPUTPCGeometry::NSECTORS];
5959
#endif
6060
template <int32_t I>
6161
GPUd() auto& getTRDTracker();

GPU/GPUTracking/Base/GPUParam.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,16 @@ void GPUParam::SetDefaults(float solenoidBz, bool assumeConstantBz)
9191
constexpr float plusZmax = 249.778;
9292
constexpr float minusZmin = -249.645;
9393
constexpr float minusZmax = -0.0799937;
94-
for (int32_t i = 0; i < GPUCA_NSECTORS; i++) {
95-
const bool zPlus = (i < GPUCA_NSECTORS / 2);
94+
for (uint32_t i = 0; i < GPUTPCGeometry::NSECTORS; i++) {
95+
const bool zPlus = (i < GPUTPCGeometry::NSECTORS / 2);
9696
SectorParam[i].ZMin = zPlus ? plusZmin : minusZmin;
9797
SectorParam[i].ZMax = zPlus ? plusZmax : minusZmax;
9898
int32_t tmp = i;
99-
if (tmp >= GPUCA_NSECTORS / 2) {
100-
tmp -= GPUCA_NSECTORS / 2;
99+
if (tmp >= (int32_t)GPUTPCGeometry::NSECTORS / 2) {
100+
tmp -= GPUTPCGeometry::NSECTORS / 2;
101101
}
102-
if (tmp >= GPUCA_NSECTORS / 4) {
103-
tmp -= GPUCA_NSECTORS / 2;
102+
if (tmp >= (int32_t)GPUTPCGeometry::NSECTORS / 4) {
103+
tmp -= GPUTPCGeometry::NSECTORS / 2;
104104
}
105105
SectorParam[i].Alpha = 0.174533f + dAlpha * tmp;
106106
SectorParam[i].CosAlpha = CAMath::Cos(SectorParam[i].Alpha);

GPU/GPUTracking/Base/GPUParam.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "GPUDef.h"
2121
#include "GPUSettings.h"
2222
#include "GPUTPCGMPolynomialField.h"
23+
#include "GPUTPCGeometry.h"
2324

2425
#if !defined(GPUCA_GPUCODE)
2526
namespace o2::base
@@ -65,7 +66,7 @@ struct GPUParam_t {
6566
uint32_t occupancyTotal; // Total occupancy in the TPC (nCl / nHbf)
6667
uint32_t occupancyMapSize; // Size of occupancy map
6768

68-
GPUParamSector SectorParam[GPUCA_NSECTORS];
69+
GPUParamSector SectorParam[GPUTPCGeometry::NSECTORS];
6970

7071
protected:
7172
#ifndef GPUCA_RUN2
@@ -87,13 +88,14 @@ struct GPUParam : public internal::GPUParam_t<GPUSettingsRec, GPUSettingsParam>
8788
void UpdateRun3ClusterErrors(const float* yErrorParam, const float* zErrorParam);
8889
#endif
8990

90-
GPUd() float Alpha(int32_t iSector) const
91+
GPUd() constexpr uint32_t tpcMinHitsB5(float qPtB5) const { return CAMath::Abs(qPtB5) > 10 ? 10 : (CAMath::Abs(qPtB5) > 5 ? 15 : 29); } // Minimum hits should depend on Pt, low Pt tracks can have few hits. 29 Hits default, 15 for < 200 mev, 10 for < 100 mev
92+
GPUd() constexpr float Alpha(int32_t iSector) const
9193
{
92-
if (iSector >= GPUCA_NSECTORS / 2) {
93-
iSector -= GPUCA_NSECTORS / 2;
94+
if (iSector >= (int32_t)GPUTPCGeometry::NSECTORS / 2) {
95+
iSector -= GPUTPCGeometry::NSECTORS / 2;
9496
}
95-
if (iSector >= GPUCA_NSECTORS / 4) {
96-
iSector -= GPUCA_NSECTORS / 2;
97+
if (iSector >= (int32_t)GPUTPCGeometry::NSECTORS / 4) {
98+
iSector -= GPUTPCGeometry::NSECTORS / 2;
9799
}
98100
return 0.174533f + dAlpha * iSector;
99101
}

GPU/GPUTracking/Base/GPUParam.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ GPUdi() float GPUParam::GetSystematicClusterErrorC122(float x, float y, uint8_t
116116
return 0.f;
117117
}
118118
constexpr float dEdgeInv = 18.f / CAMath::Pi();
119-
const float dy = (sector == (GPUCA_NSECTORS / 2 + 1) ? 0.5f : -0.5f) * (y / x) * dEdgeInv + 0.5f;
119+
const float dy = (sector == (GPUTPCGeometry::NSECTORS / 2 + 1) ? 0.5f : -0.5f) * (y / x) * dEdgeInv + 0.5f;
120120
const float errC12 = rec.tpc.sysClusErrorC12Norm * occupancyTotal * dy;
121121
return errC12 * errC12;
122122
}

GPU/GPUTracking/Base/GPUProcessor.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class GPUProcessor
6262
return *(T*)(mGPUProcessorType == PROCESSOR_TYPE_DEVICE ? mLinkedProcessor : this);
6363
}
6464

65-
template <size_t alignment = GPUCA_BUFFER_ALIGNMENT>
65+
template <size_t alignment = constants::GPU_BUFFER_ALIGNMENT>
6666
static constexpr inline size_t getAlignmentMod(size_t addr)
6767
{
6868
static_assert((alignment & (alignment - 1)) == 0, "Invalid alignment, not power of 2");
@@ -71,7 +71,7 @@ class GPUProcessor
7171
}
7272
return addr & (alignment - 1);
7373
}
74-
template <size_t alignment = GPUCA_BUFFER_ALIGNMENT>
74+
template <size_t alignment = constants::GPU_BUFFER_ALIGNMENT>
7575
static constexpr inline size_t getAlignment(size_t addr)
7676
{
7777
size_t mod = getAlignmentMod<alignment>(addr);
@@ -80,7 +80,7 @@ class GPUProcessor
8080
}
8181
return (alignment - mod);
8282
}
83-
template <size_t alignment = GPUCA_BUFFER_ALIGNMENT>
83+
template <size_t alignment = constants::GPU_BUFFER_ALIGNMENT>
8484
static constexpr inline size_t nextMultipleOf(size_t size)
8585
{
8686
return size + getAlignment<alignment>(size);
@@ -97,22 +97,22 @@ class GPUProcessor
9797
return (size + alignment - 1) & ~(alignment - 1);
9898
}
9999
}
100-
template <size_t alignment = GPUCA_BUFFER_ALIGNMENT>
100+
template <size_t alignment = constants::GPU_BUFFER_ALIGNMENT>
101101
static inline void* alignPointer(void* ptr)
102102
{
103103
return (reinterpret_cast<void*>(nextMultipleOf<alignment>(reinterpret_cast<size_t>(ptr))));
104104
}
105-
template <size_t alignment = GPUCA_BUFFER_ALIGNMENT>
105+
template <size_t alignment = constants::GPU_BUFFER_ALIGNMENT>
106106
static inline size_t getAlignmentMod(void* addr)
107107
{
108108
return (getAlignmentMod<alignment>(reinterpret_cast<size_t>(addr)));
109109
}
110-
template <size_t alignment = GPUCA_BUFFER_ALIGNMENT>
110+
template <size_t alignment = constants::GPU_BUFFER_ALIGNMENT>
111111
static inline size_t getAlignment(void* addr)
112112
{
113113
return (getAlignment<alignment>(reinterpret_cast<size_t>(addr)));
114114
}
115-
template <size_t alignment = GPUCA_BUFFER_ALIGNMENT, class S>
115+
template <size_t alignment = constants::GPU_BUFFER_ALIGNMENT, class S>
116116
static inline S* getPointerWithAlignment(size_t& basePtr, size_t nEntries = 1)
117117
{
118118
if (basePtr == 0) {
@@ -125,7 +125,7 @@ class GPUProcessor
125125
return retVal;
126126
}
127127

128-
template <size_t alignment = GPUCA_BUFFER_ALIGNMENT, class S>
128+
template <size_t alignment = constants::GPU_BUFFER_ALIGNMENT, class S>
129129
static inline S* getPointerWithAlignment(void*& basePtr, size_t nEntries = 1)
130130
{
131131
size_t tmp = (size_t)basePtr;
@@ -134,7 +134,7 @@ class GPUProcessor
134134
return retVal;
135135
}
136136

137-
template <size_t alignment = GPUCA_BUFFER_ALIGNMENT, class T, class S>
137+
template <size_t alignment = constants::GPU_BUFFER_ALIGNMENT, class T, class S>
138138
static inline void computePointerWithAlignment(T*& basePtr, S*& objPtr, size_t nEntries = 1)
139139
{
140140
size_t tmp = (size_t)basePtr;
@@ -145,8 +145,8 @@ class GPUProcessor
145145
template <class T, class S>
146146
static inline void computePointerWithoutAlignment(T*& basePtr, S*& objPtr, size_t nEntries = 1)
147147
{
148-
if ((size_t)basePtr < GPUCA_BUFFER_ALIGNMENT) {
149-
basePtr = (T*)GPUCA_BUFFER_ALIGNMENT;
148+
if ((size_t)basePtr < constants::GPU_BUFFER_ALIGNMENT) {
149+
basePtr = (T*)constants::GPU_BUFFER_ALIGNMENT;
150150
}
151151
size_t tmp = (size_t)basePtr;
152152
objPtr = reinterpret_cast<S*>(getPointerWithAlignment<1, char>(tmp, nEntries * sizeof(S)));

0 commit comments

Comments
 (0)