Project
Loading...
Searching...
No Matches
GPUParam.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
15#include "GPUParam.h"
16#include "GPUParamRTC.h"
17#include "GPUDef.h"
18#include "GPUCommonMath.h"
19#include "GPUCommonConstants.h"
21#include "GPUDataTypes.h"
22#include "GPUConstantMem.h"
24#include "GPUTPCGeometry.h"
25
26using namespace o2::gpu;
27
28#include <cstring>
29#include <tuple>
30
31#include "utils/qconfigrtc.h"
32
33void GPUParam::SetDefaults(float solenoidBz, bool assumeConstantBz)
34{
35 memset((void*)this, 0, sizeof(*this));
36 new (&rec) GPUSettingsRec;
37 occupancyMap = nullptr;
39
40#ifdef GPUCA_TPC_GEOMETRY_O2
41 const float kErrorsY[4] = {0.06, 0.24, 0.12, 0.1};
42 const float kErrorsZ[4] = {0.06, 0.24, 0.15, 0.1};
43
44 UpdateRun3ClusterErrors(kErrorsY, kErrorsZ);
45#else
46 // clang-format off
47 const float kParamS0Par[2][3][6] =
48 {
49 { { 6.45913474727e-04, 2.51547407970e-05, 1.57551113516e-02, 1.99872811635e-08, -5.86769729853e-03, 9.16301505640e-05 },
50 { 9.71546804067e-04, 1.70938055817e-05, 2.17084009200e-02, 3.90275758377e-08, -1.68631039560e-03, 8.40498323669e-05 },
51 { 7.27469159756e-05, 2.63869314949e-05, 3.29690799117e-02, -2.19274429725e-08, 1.77378822118e-02, 3.26595727529e-05 }
52 }, {
53 { 1.46874145139e-03, 6.36232061879e-06, 1.28665426746e-02, 1.19409449439e-07, 1.15883778781e-02, 1.32179644424e-04 },
54 { 1.15970033221e-03, 1.30452335725e-05, 1.87015570700e-02, 5.39766737973e-08, 1.64790824056e-02, 1.44115634612e-04 },
55 { 6.27940462437e-04, 1.78520094778e-05, 2.83537860960e-02, 1.16867742150e-08, 5.02607785165e-02, 1.88510020962e-04 } }
56 };
57 const float kParamErrorsSeeding0[2][3][4] =
58 {
59 { { 4.17516864836e-02, 1.87623649254e-04, 5.63788712025e-02, 5.38373768330e-01, },
60 { 8.29434990883e-02, 2.03291710932e-04, 6.81538805366e-02, 9.70965325832e-01, },
61 { 8.67543518543e-02, 2.10733342101e-04, 1.38366967440e-01, 2.55089461803e-01, }
62 }, {
63 { 5.96254616976e-02, 8.62886518007e-05, 3.61776389182e-02, 4.79704320431e-01, },
64 { 6.12571723759e-02, 7.23929333617e-05, 3.93057651818e-02, 9.29222583771e-01, },
65 { 6.58465921879e-02, 1.03639606095e-04, 6.07583411038e-02, 9.90289509296e-01, } }
66 };
67 // clang-format on
68
69 for (int32_t i = 0; i < 2; i++) {
70 for (int32_t j = 0; j < 3; j++) {
71 for (int32_t k = 0; k < 6; k++) {
72 ParamS0Par[i][j][k] = kParamS0Par[i][j][k];
73 }
74 }
75 }
76
77 for (int32_t i = 0; i < 2; i++) {
78 for (int32_t j = 0; j < 3; j++) {
79 for (int32_t k = 0; k < 4; k++) {
80 ParamErrorsSeeding0[i][j][k] = kParamErrorsSeeding0[i][j][k];
81 }
82 }
83 }
84#endif
85
86 UpdateBzOnly(solenoidBz, assumeConstantBz);
87 par.dodEdx = 0;
88
89 constexpr float plusZmin = 0.0529937;
90 constexpr float plusZmax = 249.778;
91 constexpr float minusZmin = -249.645;
92 constexpr float minusZmax = -0.0799937;
93 for (int32_t i = 0; i < GPUCA_NSECTORS; i++) {
94 const bool zPlus = (i < GPUCA_NSECTORS / 2);
95 SectorParam[i].ZMin = zPlus ? plusZmin : minusZmin;
96 SectorParam[i].ZMax = zPlus ? plusZmax : minusZmax;
97 int32_t tmp = i;
98 if (tmp >= GPUCA_NSECTORS / 2) {
99 tmp -= GPUCA_NSECTORS / 2;
100 }
101 if (tmp >= GPUCA_NSECTORS / 4) {
102 tmp -= GPUCA_NSECTORS / 2;
103 }
104 SectorParam[i].Alpha = 0.174533f + dAlpha * tmp;
105 SectorParam[i].CosAlpha = CAMath::Cos(SectorParam[i].Alpha);
106 SectorParam[i].SinAlpha = CAMath::Sin(SectorParam[i].Alpha);
109 }
110
111 par.continuousTracking = false;
113 tpcCutTimeBin = 0;
114 par.earlyTpcTransform = false;
115}
116
117void GPUParam::UpdateSettings(const GPUSettingsGRP* g, const GPUSettingsProcessing* p, const GPURecoStepConfiguration* w, const GPUSettingsRecDynamic* d)
118{
119 if (g) {
120 UpdateBzOnly(g->solenoidBzNominalGPU, g->constBz);
121 par.continuousTracking = g->grpContinuousMaxTimeBin != 0;
122 continuousMaxTimeBin = g->grpContinuousMaxTimeBin == -1 ? GPUSettings::TPC_MAX_TF_TIME_BIN : g->grpContinuousMaxTimeBin;
123 tpcCutTimeBin = g->tpcCutTimeBin;
124 }
125 par.earlyTpcTransform = rec.tpc.forceEarlyTransform == -1 ? (!par.continuousTracking) : rec.tpc.forceEarlyTransform;
126 qptB5Scaler = CAMath::Abs(bzkG) > 0.1f ? CAMath::Abs(bzkG) / 5.006680f : 1.f; // Repeat here, since passing in g is optional
127 if (p) {
128 UpdateRun3ClusterErrors(p->param.tpcErrorParamY, p->param.tpcErrorParamZ);
129 }
130 if (w) {
131 par.dodEdx = dodEdxEnabled = w->steps.isSet(GPUDataTypes::RecoStep::TPCdEdx);
132 if (dodEdxEnabled && p && p->tpcDownscaledEdx != 0) {
133 dodEdxEnabled = (rand() % 100) < p->tpcDownscaledEdx;
134 }
135 }
136 if (d) {
137 rec.dyn = *d;
138 }
139}
140
141void GPUParam::UpdateBzOnly(float newSolenoidBz, bool assumeConstantBz)
142{
143 bzkG = newSolenoidBz;
144 bzCLight = bzkG * o2::gpu::gpu_common_constants::kCLight;
146 if (assumeConstantBz) {
148 } else {
150 }
151 qptB5Scaler = CAMath::Abs(bzkG) > 0.1f ? CAMath::Abs(bzkG) / 5.006680f : 1.f;
152}
153
154void GPUParam::SetDefaults(const GPUSettingsGRP* g, const GPUSettingsRec* r, const GPUSettingsProcessing* p, const GPURecoStepConfiguration* w)
155{
156 SetDefaults(g->solenoidBzNominalGPU, g->constBz);
157 if (r) {
158 rec = *r;
159 if (rec.fitPropagateBzOnly == -1) {
160 rec.fitPropagateBzOnly = rec.tpc.nWays - 1;
161 }
162 }
163 UpdateSettings(g, p, w);
164}
165
166void GPUParam::UpdateRun3ClusterErrors(const float* yErrorParam, const float* zErrorParam)
167{
168#ifdef GPUCA_TPC_GEOMETRY_O2
169 for (int32_t yz = 0; yz < 2; yz++) {
170 const float* param = yz ? zErrorParam : yErrorParam;
171 for (int32_t rowType = 0; rowType < 4; rowType++) {
172 constexpr int32_t regionMap[4] = {0, 4, 6, 8};
173 ParamErrors[yz][rowType][0] = param[0] * param[0];
174 ParamErrors[yz][rowType][1] = param[1] * param[1] * GPUTPCGeometry::PadHeightByRegion(regionMap[rowType]);
175 ParamErrors[yz][rowType][2] = param[2] * param[2] / GPUTPCGeometry::TPCLength() / GPUTPCGeometry::PadHeightByRegion(regionMap[rowType]);
176 ParamErrors[yz][rowType][3] = param[3] * param[3] * rec.tpc.clusterErrorOccupancyScaler * rec.tpc.clusterErrorOccupancyScaler;
177 }
178 }
179#endif
180}
181
183{
184 memcpy((void*)this, (void*)&param, sizeof(param));
185}
186
187std::string GPUParamRTC::generateRTCCode(const GPUParam& param, bool useConstexpr)
188{
189 return "#include <string>\n"
190 "#include <vector>\n"
191 "#include <cstdint>\n"
192 "#include <cstddef>\n"
193 "namespace o2::gpu { class GPUDisplayFrontendInterface; }\n" +
194 qConfigPrintRtc(std::make_tuple(&param.rec.tpc, &param.rec.trd, &param.rec, &param.par), useConstexpr);
195}
196
197static_assert(sizeof(o2::gpu::GPUParam) == sizeof(o2::gpu::GPUParamRTC), "RTC param size mismatch");
int32_t i
#define GPUCA_NSECTORS
uint32_t j
Definition RawData.h:0
static int32_t GetPolynomialField(float nominalFieldkG, o2::gpu::GPUTPCGMPolynomialField &field)
static constexpr const uint32_t TPC_MAX_TF_TIME_BIN
Definition GPUSettings.h:47
GLboolean GLboolean g
Definition glcorearb.h:1233
GLboolean r
Definition glcorearb.h:1233
GLenum GLfloat param
Definition glcorearb.h:271
GLubyte GLubyte GLubyte GLubyte w
Definition glcorearb.h:852
static std::string generateRTCCode(const GPUParam &param, bool useConstexpr)
Definition GPUParam.cxx:187
void setFrom(const GPUParam &param)
Definition GPUParam.cxx:182
void UpdateRun3ClusterErrors(const float *yErrorParam, const float *zErrorParam)
Definition GPUParam.cxx:166
void UpdateSettings(const GPUSettingsGRP *g, const GPUSettingsProcessing *p=nullptr, const GPURecoStepConfiguration *w=nullptr, const GPUSettingsRecDynamic *d=nullptr)
Definition GPUParam.cxx:117
void SetDefaults(float solenoidBz, bool assumeConstantBz)
Definition GPUParam.cxx:33
void UpdateBzOnly(float newSolenoidBz, bool assumeConstantBz)
Definition GPUParam.cxx:141