Project
Loading...
Searching...
No Matches
GPUTPCCFDeconvolution.cxx
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
16#include "CfConsts.h"
17#include "CfUtils.h"
18#include "ChargePos.h"
19#include "GPUDefMacros.h"
20
21using namespace o2::gpu;
22using namespace o2::gpu::tpccf;
23
24template <>
25GPUdii() void GPUTPCCFDeconvolution::Thread<0>(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUSharedMemory& smem, processorType& clusterer)
26{
27 Array2D<PackedCharge> chargeMap(reinterpret_cast<PackedCharge*>(clusterer.mPchargeMap));
28 Array2D<uint8_t> isPeakMap(clusterer.mPpeakMap);
29 GPUTPCCFDeconvolution::deconvolutionImpl(get_num_groups(0), get_local_size(0), get_group_id(0), get_local_id(0), smem, isPeakMap, chargeMap, clusterer.mPpositions, clusterer.mPmemory->counters.nPositions);
30}
31
32GPUdii() void GPUTPCCFDeconvolution::deconvolutionImpl(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUSharedMemory& smem,
33 const Array2D<uint8_t>& peakMap,
34 Array2D<PackedCharge>& chargeMap,
35 const ChargePos* positions,
36 const uint32_t digitnum)
37{
39
40 bool iamDummy = (idx >= digitnum);
41 idx = iamDummy ? digitnum - 1 : idx;
42
43 ChargePos pos = positions[idx];
44
45 bool iamPeak = CfUtils::isPeak(peakMap[pos]);
46
47 int8_t peakCount = (iamPeak) ? 1 : 0;
48
49 uint16_t ll = get_local_id(0);
50 uint16_t partId = ll;
51
52 uint16_t in3x3 = 0;
53 bool exclude3x3 = iamPeak || !pos.valid();
54 partId = CfUtils::partition<SCRATCH_PAD_WORK_GROUP_SIZE>(smem, ll, exclude3x3, SCRATCH_PAD_WORK_GROUP_SIZE, &in3x3);
55
56 if (partId < in3x3) {
57 smem.posBcast1[partId] = pos;
58 }
59 GPUbarrier();
60
61 CfUtils::blockLoad(
62 peakMap,
63 in3x3,
64 SCRATCH_PAD_WORK_GROUP_SIZE,
65 ll,
66 0,
67 8,
68 cfconsts::InnerNeighbors,
69 smem.posBcast1,
70 smem.buf);
71
72 uint8_t aboveThreshold = 0;
73 if (partId < in3x3) {
74 peakCount = countPeaksInner(partId, smem.buf, &aboveThreshold);
75 }
76
77 uint16_t in5x5 = 0;
78 partId = CfUtils::partition<SCRATCH_PAD_WORK_GROUP_SIZE>(smem, partId, peakCount > 0 && !exclude3x3, in3x3, &in5x5);
79
80 if (partId < in5x5) {
81 smem.posBcast1[partId] = pos;
82 smem.aboveThresholdBcast[partId] = aboveThreshold;
83 }
84 GPUbarrier();
85
86 CfUtils::condBlockLoad<uint8_t, true>(
87 peakMap,
88 in5x5,
89 SCRATCH_PAD_WORK_GROUP_SIZE,
90 ll,
91 0,
92 16,
93 cfconsts::OuterNeighbors,
94 smem.posBcast1,
95 smem.aboveThresholdBcast,
96 smem.buf);
97
98 if (partId < in5x5) {
99 peakCount = countPeaksOuter(partId, aboveThreshold, smem.buf);
100 peakCount *= -1;
101 }
102
103 if (iamDummy || !pos.valid()) {
104 return;
105 }
106
107 bool has3x3 = (peakCount > 0);
108 peakCount = CAMath::Abs(int32_t(peakCount));
109 bool split = (peakCount > 1);
110
111 peakCount = (peakCount == 0) ? 1 : peakCount;
112
113 PackedCharge charge = chargeMap[pos];
114 PackedCharge p(charge.unpack() / peakCount, has3x3, split);
115
116 chargeMap[pos] = p;
117}
118
119GPUdi() uint8_t GPUTPCCFDeconvolution::countPeaksInner(
120 uint16_t ll,
121 const uint8_t* isPeak,
122 uint8_t* aboveThreshold)
123{
124 uint8_t peaks = 0;
125 GPUCA_UNROLL(U(), U())
126 for (uint8_t i = 0; i < 8; i++) {
127 uint8_t p = isPeak[ll * 8 + i];
128 peaks += CfUtils::isPeak(p);
129 *aboveThreshold |= uint8_t(CfUtils::isAboveThreshold(p)) << i;
130 }
131
132 return peaks;
133}
134
135GPUdi() uint8_t GPUTPCCFDeconvolution::countPeaksOuter(
136 uint16_t ll,
137 uint8_t aboveThreshold,
138 const uint8_t* isPeak)
139{
140 uint8_t peaks = 0;
141 GPUCA_UNROLL(U(), U())
142 for (uint8_t i = 0; i < 16; i++) {
143 uint8_t p = isPeak[ll * 16 + i];
144 peaks += CfUtils::isPeak(p);
145 }
146
147 return peaks;
148}
int16_t charge
Definition RawEventData.h:5
int32_t i
#define get_local_size(dim)
#define get_local_id(dim)
#define get_num_groups(dim)
#define GPUbarrier()
#define get_global_id(dim)
#define get_group_id(dim)
#define GPUCA_UNROLL(optCu, optHi)
GPUdii() void GPUTPCCFDeconvolution
uint16_t pos
Definition RawData.h:3
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
uint8_t itsSharedClusterMap uint8_t
GPUdi() o2
Definition TrackTRD.h:38
std::vector< std::string > split(const std::string &str, char delimiter=',')
for(int irof=0;irof< 1000;irof++)