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
24namespace o2::gpu
25{
26class GPUTPCGMMerger;
27
29{
32 friend class GPUChainTracking;
33
34 public:
35#ifndef GPUCA_GPUCODE
39
40 void* SetPointersOutputGPU(void* mem);
41 void* SetPointersOutputHost(void* mem);
42 void* SetPointersOutputPtrs(void* mem);
43 void* SetPointersOutput(void* mem);
44 void* SetPointersScratch(void* mem);
45 void* SetPointersMemory(void* mem);
46#endif
47
48 static constexpr uint32_t P_MAX_QMAX = 1 << 10;
49 static constexpr uint32_t P_MAX_QTOT = 5 * 5 * P_MAX_QMAX;
50 static constexpr uint32_t P_MAX_TIME = 1 << 24;
51 static constexpr uint32_t P_MAX_PAD = 1 << 16;
52 static constexpr uint32_t P_MAX_SIGMA = 1 << 8;
53 static constexpr uint32_t P_MAX_FLAGS = 1 << 8;
54 static constexpr uint32_t P_MAX_QPT = 1 << 8;
55
56 GPUd() static void truncateSignificantBitsCharge(uint16_t& charge, const GPUParam& param) { truncateSignificantBits(charge, param.rec.tpc.sigBitsCharge, P_MAX_QTOT); }
57 GPUd() static void truncateSignificantBitsChargeMax(uint16_t& charge, const GPUParam& param) { truncateSignificantBits(charge, param.rec.tpc.sigBitsCharge, P_MAX_QMAX); }
58 GPUd() static void truncateSignificantBitsWidth(uint8_t& width, const GPUParam& param) { truncateSignificantBits(width, param.rec.tpc.sigBitsWidth, P_MAX_SIGMA); }
59
60#ifndef GPUCA_GPUCODE
61 void DumpCompressedClusters(std::ostream& out);
62#endif
63
64 protected:
65 struct memory {
66 uint32_t nStoredTracks = 0;
69 };
70
71 constexpr static uint32_t NSECTORS = GPUCA_NSECTORS;
72
75 o2::tpc::CompressedClusters* mOutputA = nullptr; // Always points to host buffer
77
78 memory* mMemory = nullptr;
79 uint32_t* mAttachedClusterFirstIndex = nullptr;
80 uint8_t* mClusterStatus = nullptr;
81
82 uint32_t mMaxTracks = 0;
83 uint32_t mMaxClusters = 0;
84 uint32_t mMaxTrackClusters = 0;
85 uint32_t mMaxClustersInCache = 0;
87
88 template <class T>
89 void SetPointersCompressedClusters(void*& mem, T& c, uint32_t nClA, uint32_t nTr, uint32_t nClU, bool reducedClA);
90 template <class T>
91 GPUd() static void truncateSignificantBits(T& val, uint32_t nBits, uint32_t max);
92
94 int16_t mMemoryResOutputGPU = -1;
95};
96
97template <class T>
98GPUdi() void GPUTPCCompression::truncateSignificantBits(T& v, uint32_t nBits, uint32_t max)
99{
100 if (nBits == 0) {
101 return;
102 }
103
104 uint32_t val = v;
105 uint32_t ldz = sizeof(uint32_t) * 8 - CAMath::Clz(val);
106 if (val && ldz > nBits) {
107 if (val & (1 << (ldz - nBits - 1))) {
108 val += (1 << (ldz - nBits - 1));
109 ldz = sizeof(uint32_t) * 8 - CAMath::Clz(val);
110 }
111 val &= ((1 << ldz) - 1) ^ ((1 << (ldz - nBits)) - 1);
112 if (val >= max) {
113 val = max - 1;
114 }
115 // GPUInfo("CHANGING X %x --> %x", (uint32_t) v, val);
116 v = val;
117 }
118}
119} // namespace o2::gpu
120
121#endif
Container to store compressed TPC cluster data.
int16_t charge
Definition RawEventData.h:5
#define GPUCA_NSECTORS
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
o2::tpc::CompressedClustersPtrs mPtrs
void * SetPointersOutput(void *mem)
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)
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:38