Project
Loading...
Searching...
No Matches
GPUTPCCompression.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.
11
14
15#ifndef GPUTPCCOMPRESSION_H
16#define GPUTPCCOMPRESSION_H
17
18#include "GPUCommonDef.h"
19
20#include "GPUDef.h"
21#include "GPUProcessor.h"
22#include "GPUCommonMath.h"
23#include "GPUParam.h"
25#include "GPUTPCGeometry.h"
26
27namespace o2::gpu
28{
29class GPUTPCGMMerger;
30
32{
35 friend class GPUChainTracking;
36
37 public:
38#ifndef GPUCA_GPUCODE
42
43 void* SetPointersOutputGPU(void* mem);
44 void* SetPointersOutputHost(void* mem);
45 void* SetPointersOutputPtrs(void* mem);
46 void* SetPointersOutput(void* mem);
47 void* SetPointersScratch(void* mem);
48 void* SetPointersMemory(void* mem);
49#endif
50
51 static GPUglobalconstexpr() uint32_t P_MAX_QMAX = 1 << 10;
52 static GPUglobalconstexpr() uint32_t P_MAX_REGULAR_QTOT = 5 * 5 * P_MAX_QMAX;
53 static GPUglobalconstexpr() uint32_t P_MAX_SATURATED_QTOT = 1 << 16; // Need two different limits as saturated clusters use full u16 range for qTot
54 static GPUglobalconstexpr() uint32_t P_MAX_TIME = 1 << 24;
55 static GPUglobalconstexpr() uint32_t P_MAX_PAD = 1 << 16;
56 static GPUglobalconstexpr() uint32_t P_MAX_SIGMA = 1 << 8;
57 static GPUglobalconstexpr() uint32_t P_MAX_FLAGS = 1 << 8;
58 static GPUglobalconstexpr() uint32_t P_MAX_QPT = 1 << 8;
59
60 GPUd() static void truncateSignificantBitsCharge(uint16_t& charge, const GPUParam& param) { truncateSignificantBits(charge, param.rec.tpc.sigBitsCharge, P_MAX_REGULAR_QTOT); }
61 GPUd() static void truncateSignificantBitsChargeMax(uint16_t& charge, const GPUParam& param) { truncateSignificantBits(charge, param.rec.tpc.sigBitsCharge, P_MAX_QMAX); }
62 GPUd() static void truncateSignificantBitsWidth(uint8_t& width, const GPUParam& param) { truncateSignificantBits(width, param.rec.tpc.sigBitsWidth, P_MAX_SIGMA); }
63
64#ifndef GPUCA_GPUCODE
65 void DumpCompressedClusters(std::ostream& out);
66#endif
67 GPUd() bool rejectCluster(int32_t idx, const GPUParam& param, const GPUTrackingInOutPointers& ioPtrs) const;
68
70 struct memory {
71 uint32_t nStoredTracks = 0;
72 uint32_t nStoredAttachedClusters = 0;
73 uint32_t nStoredUnattachedClusters = 0;
74 };
75
76 GPUglobalconstexpr() static uint32_t NSECTORS = GPUTPCGeometry::NSECTORS;
77
78 o2::tpc::CompressedClustersPtrs mPtrs;
79 o2::tpc::CompressedClusters* mOutput = nullptr;
80 o2::tpc::CompressedClusters* mOutputA = nullptr; // Always points to host buffer
81 o2::tpc::CompressedClustersFlat* mOutputFlat = nullptr;
82
83 memory* mMemory = nullptr;
84 uint32_t* mAttachedClusterFirstIndex = nullptr;
85 uint8_t* mClusterStatus = nullptr;
86
87 uint32_t mMaxTracks = 0;
88 uint32_t mMaxClusters = 0;
89 uint32_t mMaxTrackClusters = 0;
90 uint32_t mMaxClustersInCache = 0;
92
93 template <class T>
94 void SetPointersCompressedClusters(void*& mem, T& c, uint32_t nClA, uint32_t nTr, uint32_t nClU, bool reducedClA);
95 template <class T>
96 GPUd() static void truncateSignificantBits(T& val, uint32_t nBits, uint32_t max);
97
99 int16_t mMemoryResOutputGPU = -1;
100};
101
102template <class T>
103GPUdi() void GPUTPCCompression::truncateSignificantBits(T& v, uint32_t nBits, uint32_t max)
104{
105 if (nBits == 0) {
106 return;
107 }
108
109 uint32_t val = v;
110 uint32_t ldz = sizeof(uint32_t) * 8 - CAMath::Clz(val);
111 if (val && ldz > nBits) {
112 if (val & (1 << (ldz - nBits - 1))) {
113 val += (1 << (ldz - nBits - 1));
114 ldz = sizeof(uint32_t) * 8 - CAMath::Clz(val);
115 }
116 val &= ((1 << ldz) - 1) ^ ((1 << (ldz - nBits)) - 1);
117 if (val >= max) {
118 val = max - 1;
119 }
120 // GPUInfo("CHANGING X %x --> %x", (uint32_t) v, val);
121 v = val;
122 }
123}
124} // namespace o2::gpu
125
126#endif
Container to store compressed TPC cluster data.
int16_t charge
Definition RawEventData.h:5
#define protected
uint32_t c
Definition RawData.h:2
GPUd() static void truncateSignificantBitsChargeMax(uint16_t &charge
GPUd() static void truncateSignificantBitsWidth(uint8_t &width
void * SetPointersOutputHost(void *mem)
void SetPointersCompressedClusters(void *&mem, T &c, uint32_t nClA, uint32_t nTr, uint32_t nClU, bool reducedClA)
void DumpCompressedClusters(std::ostream &out)
o2::tpc::CompressedClusters * mOutput
void * SetPointersMemory(void *mem)
void * SetPointersOutputGPU(void *mem)
o2::tpc::CompressedClusters * mOutputA
GPUd() bool rejectCluster(int32_t idx
o2::tpc::CompressedClustersPtrs mPtrs
void * SetPointersOutput(void *mem)
const GPUParam const GPUTrackingInOutPointers &ioPtrs const
o2::tpc::CompressedClustersFlat * mOutputFlat
void * SetPointersOutputPtrs(void *mem)
void SetMaxData(const GPUTrackingInOutPointers &io)
GPUglobalconstexpr() static uint32_t NSECTORS
void * SetPointersScratch(void *mem)
static GPUglobalconstexpr() uint32_t P_MAX_QMAX
const GLdouble * v
Definition glcorearb.h:832
GLint GLsizei width
Definition glcorearb.h:270
GLuint GLfloat * val
Definition glcorearb.h:1582
GLenum GLfloat param
Definition glcorearb.h:271
GPUdi() o2
Definition TrackTRD.h:39
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...