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 "GPUDef.h"
19#include "GPUProcessor.h"
20#include "GPUCommonMath.h"
21#include "GPUParam.h"
23#include "GPUTPCGeometry.h"
24
25namespace o2::gpu
26{
27class GPUTPCGMMerger;
28
30{
33 friend class GPUChainTracking;
34
35 public:
36#ifndef GPUCA_GPUCODE
40
41 void* SetPointersOutputGPU(void* mem);
42 void* SetPointersOutputHost(void* mem);
43 void* SetPointersOutputPtrs(void* mem);
44 void* SetPointersOutput(void* mem);
45 void* SetPointersScratch(void* mem);
46 void* SetPointersMemory(void* mem);
47#endif
48
49 static constexpr uint32_t P_MAX_QMAX = 1 << 10;
50 static constexpr uint32_t P_MAX_QTOT = 5 * 5 * P_MAX_QMAX;
51 static constexpr uint32_t P_MAX_TIME = 1 << 24;
52 static constexpr uint32_t P_MAX_PAD = 1 << 16;
53 static constexpr uint32_t P_MAX_SIGMA = 1 << 8;
54 static constexpr uint32_t P_MAX_FLAGS = 1 << 8;
55 static constexpr uint32_t P_MAX_QPT = 1 << 8;
56
57 GPUd() static void truncateSignificantBitsCharge(uint16_t& charge, const GPUParam& param) { truncateSignificantBits(charge, param.rec.tpc.sigBitsCharge, P_MAX_QTOT); }
58 GPUd() static void truncateSignificantBitsChargeMax(uint16_t& charge, const GPUParam& param) { truncateSignificantBits(charge, param.rec.tpc.sigBitsCharge, P_MAX_QMAX); }
59 GPUd() static void truncateSignificantBitsWidth(uint8_t& width, const GPUParam& param) { truncateSignificantBits(width, param.rec.tpc.sigBitsWidth, P_MAX_SIGMA); }
60
61#ifndef GPUCA_GPUCODE
62 void DumpCompressedClusters(std::ostream& out);
63#endif
64 GPUd() bool rejectCluster(int32_t idx, const GPUParam& param, const GPUTrackingInOutPointers& ioPtrs) const;
65
67 struct memory {
68 uint32_t nStoredTracks = 0;
69 uint32_t nStoredAttachedClusters = 0;
70 uint32_t nStoredUnattachedClusters = 0;
71 };
72
73 constexpr static uint32_t NSECTORS = GPUTPCGeometry::NSECTORS;
74
77 o2::tpc::CompressedClusters* mOutputA = nullptr; // Always points to host buffer
79
80 memory* mMemory = nullptr;
81 uint32_t* mAttachedClusterFirstIndex = nullptr;
82 uint8_t* mClusterStatus = nullptr;
83
84 uint32_t mMaxTracks = 0;
85 uint32_t mMaxClusters = 0;
86 uint32_t mMaxTrackClusters = 0;
87 uint32_t mMaxClustersInCache = 0;
89
90 template <class T>
91 void SetPointersCompressedClusters(void*& mem, T& c, uint32_t nClA, uint32_t nTr, uint32_t nClU, bool reducedClA);
92 template <class T>
93 GPUd() static void truncateSignificantBits(T& val, uint32_t nBits, uint32_t max);
94
96 int16_t mMemoryResOutputGPU = -1;
97};
98
99template <class T>
100GPUdi() void GPUTPCCompression::truncateSignificantBits(T& v, uint32_t nBits, uint32_t max)
101{
102 if (nBits == 0) {
103 return;
104 }
105
106 uint32_t val = v;
107 uint32_t ldz = sizeof(uint32_t) * 8 - CAMath::Clz(val);
108 if (val && ldz > nBits) {
109 if (val & (1 << (ldz - nBits - 1))) {
110 val += (1 << (ldz - nBits - 1));
111 ldz = sizeof(uint32_t) * 8 - CAMath::Clz(val);
112 }
113 val &= ((1 << ldz) - 1) ^ ((1 << (ldz - nBits)) - 1);
114 if (val >= max) {
115 val = max - 1;
116 }
117 // GPUInfo("CHANGING X %x --> %x", (uint32_t) v, val);
118 v = val;
119 }
120}
121} // namespace o2::gpu
122
123#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
static constexpr uint32_t P_MAX_QTOT
GPUd() static void truncateSignificantBits(T &val
GPUd() static void truncateSignificantBitsWidth(uint8_t &width
static constexpr uint32_t P_MAX_QMAX
void * SetPointersOutputHost(void *mem)
static constexpr uint32_t P_MAX_TIME
void SetPointersCompressedClusters(void *&mem, T &c, uint32_t nClA, uint32_t nTr, uint32_t nClU, bool reducedClA)
static constexpr uint32_t P_MAX_QPT
void DumpCompressedClusters(std::ostream &out)
static constexpr uint32_t P_MAX_SIGMA
o2::tpc::CompressedClusters * mOutput
void * SetPointersMemory(void *mem)
void * SetPointersOutputGPU(void *mem)
static constexpr uint32_t NSECTORS
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
GPUd() static void truncateSignificantBitsCharge(uint16_t &charge
void * SetPointersOutputPtrs(void *mem)
void SetMaxData(const GPUTrackingInOutPointers &io)
static constexpr uint32_t P_MAX_PAD
static constexpr uint32_t P_MAX_FLAGS
void * SetPointersScratch(void *mem)
static constexpr uint32_t NSECTORS
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