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
25using namespace o2::gpu;
26
27#include <cstring>
28#include <tuple>
29
30#include "utils/qconfigrtc.h"
31
32void GPUParam::SetDefaults(float solenoidBz)
33{
34 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 par.dAlpha = 0.349066f;
87 UpdateBzOnly(solenoidBz);
88 par.dodEdx = 0;
89
90 constexpr float plusZmin = 0.0529937;
91 constexpr float plusZmax = 249.778;
92 constexpr float minusZmin = -249.645;
93 constexpr float minusZmax = -0.0799937;
94 for (int32_t i = 0; i < GPUCA_NSECTORS; i++) {
95 const bool zPlus = (i < GPUCA_NSECTORS / 2);
96 SectorParam[i].ZMin = zPlus ? plusZmin : minusZmin;
97 SectorParam[i].ZMax = zPlus ? plusZmax : minusZmax;
98 int32_t tmp = i;
99 if (tmp >= GPUCA_NSECTORS / 2) {
100 tmp -= GPUCA_NSECTORS / 2;
101 }
102 if (tmp >= GPUCA_NSECTORS / 4) {
103 tmp -= GPUCA_NSECTORS / 2;
104 }
105 SectorParam[i].Alpha = 0.174533f + par.dAlpha * tmp;
106 SectorParam[i].CosAlpha = CAMath::Cos(SectorParam[i].Alpha);
107 SectorParam[i].SinAlpha = CAMath::Sin(SectorParam[i].Alpha);
108 SectorParam[i].AngleMin = SectorParam[i].Alpha - par.dAlpha / 2.f;
109 SectorParam[i].AngleMax = SectorParam[i].Alpha + par.dAlpha / 2.f;
110 }
111
112 par.assumeConstantBz = false;
113 par.toyMCEventsFlag = false;
114 par.continuousTracking = false;
116 tpcCutTimeBin = 0;
117 par.debugLevel = 0;
118 par.earlyTpcTransform = false;
119}
120
121void GPUParam::UpdateSettings(const GPUSettingsGRP* g, const GPUSettingsProcessing* p, const GPURecoStepConfiguration* w, const GPUSettingsRecDynamic* d)
122{
123 if (g) {
124 UpdateBzOnly(g->solenoidBzNominalGPU);
125 par.assumeConstantBz = g->constBz;
126 par.toyMCEventsFlag = g->homemadeEvents;
127 par.continuousTracking = g->grpContinuousMaxTimeBin != 0;
128 continuousMaxTimeBin = g->grpContinuousMaxTimeBin == -1 ? GPUSettings::TPC_MAX_TF_TIME_BIN : g->grpContinuousMaxTimeBin;
129 tpcCutTimeBin = g->tpcCutTimeBin;
130 }
131 par.earlyTpcTransform = rec.tpc.forceEarlyTransform == -1 ? (!par.continuousTracking) : rec.tpc.forceEarlyTransform;
132 qptB5Scaler = CAMath::Abs(bzkG) > 0.1f ? CAMath::Abs(bzkG) / 5.006680f : 1.f; // Repeat here, since passing in g is optional
133 if (p) {
134 par.debugLevel = p->debugLevel;
135 UpdateRun3ClusterErrors(p->param.tpcErrorParamY, p->param.tpcErrorParamZ);
136 }
137 if (w) {
138 par.dodEdx = dodEdxDownscaled = w->steps.isSet(GPUDataTypes::RecoStep::TPCdEdx);
139 if (par.dodEdx && p && p->tpcDownscaledEdx != 0) {
140 dodEdxDownscaled = (rand() % 100) < p->tpcDownscaledEdx;
141 }
142 }
143 if (d) {
144 rec.dyn = *d;
145 }
146}
147
148void GPUParam::UpdateBzOnly(float newSolenoidBz)
149{
150 bzkG = newSolenoidBz;
151 bzCLight = bzkG * o2::gpu::gpu_common_constants::kCLight;
153 if (par.assumeConstantBz) {
155 } else {
157 }
158 qptB5Scaler = CAMath::Abs(bzkG) > 0.1f ? CAMath::Abs(bzkG) / 5.006680f : 1.f;
159}
160
161void GPUParam::SetDefaults(const GPUSettingsGRP* g, const GPUSettingsRec* r, const GPUSettingsProcessing* p, const GPURecoStepConfiguration* w)
162{
163 SetDefaults(g->solenoidBzNominalGPU);
164 if (r) {
165 rec = *r;
166 if (rec.fitPropagateBzOnly == -1) {
167 rec.fitPropagateBzOnly = rec.tpc.nWays - 1;
168 }
169 }
170 UpdateSettings(g, p, w);
171}
172
173void GPUParam::UpdateRun3ClusterErrors(const float* yErrorParam, const float* zErrorParam)
174{
175#ifdef GPUCA_TPC_GEOMETRY_O2
176 for (int32_t yz = 0; yz < 2; yz++) {
177 const float* param = yz ? zErrorParam : yErrorParam;
178 for (int32_t rowType = 0; rowType < 4; rowType++) {
179 constexpr int32_t regionMap[4] = {0, 4, 6, 8};
180 ParamErrors[yz][rowType][0] = param[0] * param[0];
181 ParamErrors[yz][rowType][1] = param[1] * param[1] * tpcGeometry.PadHeightByRegion(regionMap[rowType]);
182 ParamErrors[yz][rowType][2] = param[2] * param[2] / tpcGeometry.TPCLength() / tpcGeometry.PadHeightByRegion(regionMap[rowType]);
183 ParamErrors[yz][rowType][3] = param[3] * param[3] * rec.tpc.clusterErrorOccupancyScaler * rec.tpc.clusterErrorOccupancyScaler;
184 }
185 }
186#endif
187}
188
190{
191 memcpy((void*)this, (void*)&param, sizeof(param));
192}
193
194std::string GPUParamRTC::generateRTCCode(const GPUParam& param, bool useConstexpr)
195{
196 return "#ifndef GPUCA_GPUCODE_DEVICE\n"
197 "#include <string>\n"
198 "#include <vector>\n"
199 "#include <cstdint>\n"
200 "#include <cstddef>\n"
201 "#endif\n"
202 "namespace o2::gpu { class GPUDisplayFrontendInterface; }\n" +
203 qConfigPrintRtc(std::make_tuple(&param.rec.tpc, &param.rec.trd, &param.rec, &param.par), useConstexpr);
204}
205
206static_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:194
void setFrom(const GPUParam &param)
Definition GPUParam.cxx:189
void SetDefaults(float solenoidBz)
Definition GPUParam.cxx:32
void UpdateRun3ClusterErrors(const float *yErrorParam, const float *zErrorParam)
Definition GPUParam.cxx:173
void UpdateSettings(const GPUSettingsGRP *g, const GPUSettingsProcessing *p=nullptr, const GPURecoStepConfiguration *w=nullptr, const GPUSettingsRecDynamic *d=nullptr)
Definition GPUParam.cxx:121
void UpdateBzOnly(float newSolenoidBz)
Definition GPUParam.cxx:148