Project
Loading...
Searching...
No Matches
GPUTPCCFDecodeZS.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 O2_GPU_DECODE_ZS_H
16#define O2_GPU_DECODE_ZS_H
17
18#include "clusterFinderDefs.h"
19#include "GPUGeneralKernels.h"
20#include "GPUConstantMem.h"
21#include "TPCBase/PadPos.h"
25
26namespace o2::gpu
27{
28
29class GPUTPCClusterFinder;
30
32{
33 public:
34 struct GPUSharedMemory /*: public GPUKernelTemplate::GPUSharedMemoryScan64<int32_t, GPUCA_WARP_SIZE>*/ {
35 CA_SHARED_STORAGE(uint32_t ZSPage[o2::tpc::TPCZSHDR::TPC_ZS_PAGE_SIZE / sizeof(uint32_t)]);
37 uint32_t nRowsRegion;
40 uint32_t rowStride;
41 GPUAtomic(uint32_t) rowOffsetCounter;
42 };
43
44 enum K : int32_t {
46 };
47
48 static GPUd() void decode(GPUTPCClusterFinder& clusterer, GPUSharedMemory& s, int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, int32_t firstHBF);
49
52 {
53 return processors.tpcClusterer;
54 }
55
56 GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep()
57 {
58 return GPUDataTypes::RecoStep::TPCClusterFinding;
59 }
60
61 template <int32_t iKernel = defaultKernel, typename... Args>
62 GPUd() static void Thread(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUSharedMemory& smem, processorType& clusterer, Args... args);
63};
64
66{
67
68 public:
71 {
72 return processors.tpcClusterer;
73 }
74
75 GPUhdi() constexpr static GPUDataTypes::RecoStep GetRecoStep()
76 {
77 return GPUDataTypes::RecoStep::TPCClusterFinding;
78 }
79
80 template <class Decoder>
81 GPUd() static void Decode(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, typename Decoder::GPUSharedMemory& smem, processorType& clusterer, int32_t firstHBF);
82
83 GPUd() static o2::tpc::PadPos GetPadAndRowFromFEC(processorType& clusterer, int32_t cru, int32_t rawFecChannel, int32_t fecInPartition);
84 GPUd() static void WriteCharge(processorType& clusterer, float charge, o2::tpc::PadPos pos, tpccf::TPCFragmentTime localTime, size_t positionOffset);
85 GPUd() static uint16_t FillWithInvalid(processorType& clusterer, int32_t iThread, int32_t nThreads, uint32_t pageDigitOffset, uint16_t nSamples);
86
87 GPUdi() static const uint8_t* ConsumeBytes(const uint8_t*& page, size_t nbytes)
88 {
89 const uint8_t* oldPage = page;
90 page += nbytes;
91 return oldPage;
92 }
93
94 GPUdi() static uint8_t ConsumeByte(const uint8_t*& page)
95 {
96 return *(page++);
97 }
98
99 template <typename T>
100 GPUdi() static const T* ConsumeHeader(const uint8_t*& page)
101 {
102 assert(size_t(page) % alignof(T) == 0);
103 return reinterpret_cast<const T*>(ConsumeBytes(page, sizeof(T)));
104 }
105
106 template <typename T = uint8_t>
107 GPUdi() static const T* Peek(const uint8_t* page, ptrdiff_t offset = 0)
108 {
109 // if ((size_t(page) + offset) % alignof(T) != 0) {
110 // printf("page = %zu, offset = %zu, alignof = %zu\n", size_t(page), offset, alignof(T));
111 // }
112 assert((size_t(page) + offset) % alignof(T) == 0);
113 return reinterpret_cast<const T*>(page + offset);
114 }
115
116 GPUdi() static float ADCToFloat(uint32_t adc, uint32_t decodeMask, float decodeBitsFactor)
117 {
118 return float(adc & decodeMask) * decodeBitsFactor;
119 }
120};
121
123{
124 public:
125 // constants for decoding
126 static inline constexpr int32_t DECODE_BITS = o2::tpc::TPCZSHDRV2::TPC_ZS_NBITS_V34;
127 static inline constexpr float DECODE_BITS_FACTOR = 1.f / (1 << (DECODE_BITS - 10));
128 static inline constexpr uint32_t DECODE_MASK = (1 << DECODE_BITS) - 1;
129
130 struct GPUSharedMemory : GPUKernelTemplate::GPUSharedMemoryWarpScan64<uint8_t, GPUCA_GET_THREAD_COUNT(GPUCA_LB_GPUTPCCFDecodeZSLink)> {
131 // CA_SHARED_STORAGE(uint32_t ZSPage[o2::tpc::TPCZSHDR::TPC_ZS_PAGE_SIZE / sizeof(uint32_t)]);
132 };
133
134 template <int32_t iKernel = defaultKernel, typename... Args>
135 GPUd() static void Thread(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUSharedMemory& smem, processorType& clusterer, Args... args);
136
137 GPUd() static size_t DecodePage(GPUSharedMemory& smem, processorType& clusterer, int32_t iBlock, int32_t nThreads, int32_t iThread, const uint8_t* page, uint32_t pageDigitOffset, int32_t firstHBF);
138
139 GPUd() static void GetChannelBitmask(const tpc::zerosupp_link_based::CommonHeader& tbHdr, uint32_t* chan);
140 GPUd() static bool ChannelIsActive(const uint32_t* chan, uint8_t chanIndex);
141
142 GPUd() static void DecodeTBSingleThread(processorType& clusterer, const uint8_t* adcData, uint32_t nAdc, const uint32_t* channelMask, int32_t timeBin, int32_t cru, int32_t fecInPartition, uint32_t pageDigitOffset);
143 GPUd() static void DecodeTBMultiThread(processorType& clusterer, int32_t iThread, GPUSharedMemory& smem, const uint8_t* adcData, uint32_t nAdc, const uint32_t* channelMask, int32_t timeBin, int32_t cru, int32_t fecInPartition, uint32_t pageDigitOffset);
144};
145
147{
148 public:
149 // constants for decoding
150 static inline constexpr int32_t DECODE_BITS = o2::tpc::TPCZSHDRV2::TPC_ZS_NBITS_V34;
151 static inline constexpr float DECODE_BITS_FACTOR = 1.f / (1 << (DECODE_BITS - 10));
152 static inline constexpr uint32_t DECODE_MASK = (1 << DECODE_BITS) - 1;
153
154 static inline constexpr int32_t MaxNLinksPerTimebin = 16;
155
156 struct GPUSharedMemory : GPUKernelTemplate::GPUSharedMemoryWarpScan64<uint8_t, GPUCA_GET_THREAD_COUNT(GPUCA_LB_GPUTPCCFDecodeZSDenseLink)> {
157 // CA_SHARED_STORAGE(uint32_t ZSPage[o2::tpc::TPCZSHDR::TPC_ZS_PAGE_SIZE / sizeof(uint32_t)]);
158 uint16_t samplesPerLinkEnd[MaxNLinksPerTimebin]; // Offset from end of TB link header to first sample not in this link
159 uint8_t linkIds[MaxNLinksPerTimebin];
160 uint8_t rawFECChannels[MaxNLinksPerTimebin * 80];
161 };
162
163 template <int32_t iKernel = defaultKernel, typename... Args>
164 GPUd() static void Thread(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUSharedMemory& smem, processorType& clusterer, Args... args);
165
166 GPUd() static uint32_t DecodePage(GPUSharedMemory& smem, processorType& clusterer, int32_t iBlock, int32_t nThreads, int32_t iThread, const uint8_t* page, uint32_t pageDigitOffset, int32_t firstHBF);
167
168 GPUd() static bool ChannelIsActive(const uint8_t* chan, uint16_t chanIndex);
169
170 template <bool DecodeInParallel, bool PayloadExtendsToNextPage>
171 GPUd() static uint16_t DecodeTB(processorType& clusterer, GPUSharedMemory& smem, int32_t iThread, const uint8_t*& page, uint32_t pageDigitOffset, const header::RAWDataHeader* rawDataHeader, int32_t firstHBF, int32_t cru, const uint8_t* payloadEnd, const uint8_t* nextPage);
172
173 template <bool PayloadExtendsToNextPage>
174 GPUd() static uint16_t DecodeTBSingleThread(processorType& clusterer, const uint8_t*& page, uint32_t pageDigitOffset, const header::RAWDataHeader* rawDataHeader, int32_t firstHBF, int32_t cru, const uint8_t* payloadEnd, const uint8_t* nextPage);
175
176 template <bool PayloadExtendsToNextPage>
177 GPUd() static uint16_t DecodeTBMultiThread(processorType& clusterer, GPUSharedMemory& smem, const int32_t iThread, const uint8_t*& page, uint32_t pageDigitOffset, const header::RAWDataHeader* rawDataHeader, int32_t firstHBF, int32_t cru, const uint8_t* payloadEnd, const uint8_t* nextPage);
178};
179
180} // namespace o2::gpu
181
182#endif
int16_t charge
Definition RawEventData.h:5
#define GPUd()
uint16_t pos
Definition RawData.h:3
definitions to deal with the link based zero suppression format
Definitions of TPC Zero Suppression Data Headers.
int32_t int32_t int32_t processorType & processors
GPUhdi() const expr static GPUDataTypes
GPUdi() static uint8_t ConsumeByte(const uint8_t *&page)
GPUdi() static const T *Peek(const uint8_t *page
GPUdi() static const T *ConsumeHeader(const uint8_t *&page)
GPUhdi() static processorType *Processor(GPUConstantMem &processors)
static GPUSharedMemory int32_t int32_t int32_t iBlock
GPUd() static void Thread(int32_t nBlocks
static GPUSharedMemory int32_t nBlocks
int32_t int32_t int32_t GPUSharedMemory processorType & clusterer
static GPUSharedMemory int32_t int32_t nThreads
GPUhdi() const expr static GPUDataTypes
static GPUSharedMemory int32_t int32_t int32_t int32_t iThread
static GPUSharedMemory int32_t int32_t int32_t int32_t int32_t firstHBF
int32_t int32_t int32_t GPUSharedMemory & smem
int32_t int32_t int32_t GPUSharedMemory processorType Args args
static GPUSharedMemory & s
GLintptr offset
Definition glcorearb.h:660
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GPUdi() o2
Definition TrackTRD.h:38
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
CA_SHARED_STORAGE(uint32_t ZSPage[o2::tpc::TPCZSHDR::TPC_ZS_PAGE_SIZE/sizeof(uint32_t)])
uint32_t RowClusterOffset[o2::tpc::TPCZSHDR::TPC_MAX_ZS_ROW_IN_ENDPOINT]
GPUAtomic(uint32_t) rowOffsetCounter
static constexpr unsigned int TPC_ZS_NBITS_V34
static constexpr size_t TPC_MAX_ZS_ROW_IN_ENDPOINT
static constexpr size_t TPC_ZS_PAGE_SIZE
coder decode(ctfImage, triggersD, clustersD)
ArrayADC adc