Project
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
GPUTPCCFChargeMapFiller.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 "ChargePos.h"
18#include "TPCPadGainCalib.h"
19
20using namespace o2::gpu;
21using namespace o2::gpu::tpccf;
22
23template <>
24GPUdii() void GPUTPCCFChargeMapFiller::Thread<GPUTPCCFChargeMapFiller::fillIndexMap>(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUSharedMemory& smem, processorType& clusterer)
25{
26 Array2D<uint32_t> indexMap(clusterer.mPindexMap);
27 fillIndexMapImpl(get_num_groups(0), get_local_size(0), get_group_id(0), get_local_id(0), clusterer.mPmemory->fragment, clusterer.mPdigits, indexMap, clusterer.mPmemory->counters.nDigitsInFragment);
28}
29
30GPUd() void GPUTPCCFChargeMapFiller::fillIndexMapImpl(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread,
31 const CfFragment& fragment,
32 const tpc::Digit* digits,
33 Array2D<uint32_t>& indexMap,
34 size_t maxDigit)
35{
36 size_t idx = get_global_id(0);
37 if (idx >= maxDigit) {
38 return;
39 }
40 CPU_ONLY(idx += fragment.digitsStart);
41 CPU_ONLY(tpc::Digit digit = digits[idx]);
42 CPU_ONLY(ChargePos pos(digit.getRow(), digit.getPad(), fragment.toLocal(digit.getTimeStamp())));
43 CPU_ONLY(indexMap.safeWrite(pos, idx));
44}
45
46template <>
47GPUdii() void GPUTPCCFChargeMapFiller::Thread<GPUTPCCFChargeMapFiller::fillFromDigits>(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUSharedMemory& smem, processorType& clusterer)
48{
49 Array2D<PackedCharge> chargeMap(reinterpret_cast<PackedCharge*>(clusterer.mPchargeMap));
50 fillFromDigitsImpl(get_num_groups(0), get_local_size(0), get_group_id(0), get_local_id(0), clusterer, clusterer.mPmemory->fragment, clusterer.mPmemory->counters.nPositions, clusterer.mPdigits, clusterer.mPpositions, chargeMap);
51}
52
53GPUd() void GPUTPCCFChargeMapFiller::fillFromDigitsImpl(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, processorType& clusterer, const CfFragment& fragment, size_t digitNum,
54 const tpc::Digit* digits,
55 ChargePos* positions,
56 Array2D<PackedCharge>& chargeMap)
57{
58 size_t idx = get_global_id(0);
59 if (idx >= digitNum) {
60 return;
61 }
62 tpc::Digit digit = digits[fragment.digitsStart + idx];
63
64 ChargePos pos(digit.getRow(), digit.getPad(), fragment.toLocal(digit.getTimeStamp()));
65 positions[idx] = pos;
66 float q = digit.getChargeFloat();
67 q *= clusterer.GetConstantMem()->calibObjects.tpcPadGain->getGainCorrection(clusterer.mISector, digit.getRow(), digit.getPad());
68 chargeMap[pos] = PackedCharge(q);
69}
70
71template <>
72GPUdii() void GPUTPCCFChargeMapFiller::Thread<GPUTPCCFChargeMapFiller::findFragmentStart>(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUSharedMemory& smem, processorType& clusterer, int8_t setPositions)
73{
74 if (iThread != 0 || iBlock != 0) {
75 return;
76 }
77
78 size_t nDigits = clusterer.mPmemory->counters.nDigits;
79 const tpc::Digit* digits = clusterer.mPdigits;
80 size_t st = findTransition(clusterer.mPmemory->fragment.first(), digits, nDigits, 0);
81 size_t end = findTransition(clusterer.mPmemory->fragment.last(), digits, nDigits, st);
82
83 clusterer.mPmemory->fragment.digitsStart = st;
84
85 size_t elems = end - st;
86
87 clusterer.mPmemory->counters.nDigitsInFragment = elems;
88 if (setPositions) {
89 clusterer.mPmemory->counters.nPositions = elems;
90 }
91}
92
93GPUd() size_t GPUTPCCFChargeMapFiller::findTransition(int32_t time, const tpc::Digit* digits, size_t nDigits, size_t lower)
94{
95 if (!nDigits) {
96 return 0;
97 }
98 size_t upper = nDigits - 1;
99
100 while (lower < upper) {
101 size_t middle = (lower + upper) / 2;
102
103 if (digits[middle].getTimeStamp() < time) {
104 lower = middle + 1;
105 } else if (middle == lower || digits[middle - 1].getTimeStamp() < time) {
106 return middle;
107 } else {
108 upper = middle - 1;
109 }
110 }
111 return lower;
112}
Definition of the TPC Digit.
int16_t time
Definition RawEventData.h:4
#define get_local_size(dim)
#define get_local_id(dim)
#define get_num_groups(dim)
#define get_global_id(dim)
#define get_group_id(dim)
GPUd() void GPUTPCCFChargeMapFiller
GPUdii() void GPUTPCCFChargeMapFiller
uint16_t pos
Definition RawData.h:3
benchmark::State & st
#define CPU_ONLY(x)
GLuint GLuint end
Definition glcorearb.h:469
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
uint64_t getTimeStamp(o2::framework::ProcessingContext &pc)
std::vector< Digit > digits