forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGPUParam.cxx
More file actions
192 lines (172 loc) · 7.12 KB
/
GPUParam.cxx
File metadata and controls
192 lines (172 loc) · 7.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file GPUParam.cxx
/// \author David Rohr, Sergey Gorbunov
#include "GPUParam.h"
#include "GPUParamRTC.h"
#include "GPUDef.h"
#include "GPUCommonMath.h"
#include "GPUCommonConstants.h"
#include "GPUTPCGMPolynomialFieldManager.h"
#include "GPUDataTypes.h"
#include "GPUConstantMem.h"
#include "DetectorsBase/Propagator.h"
#include "GPUTPCGeometry.h"
using namespace o2::gpu;
#include <cstring>
#include <tuple>
#include "utils/qconfigrtc.h"
void GPUParam::SetDefaults(float solenoidBz, bool assumeConstantBz)
{
memset((void*)this, 0, sizeof(*this));
new (&rec) GPUSettingsRec;
occupancyMap = nullptr;
occupancyTotal = 0;
#ifdef GPUCA_TPC_GEOMETRY_O2
const float kErrorsY[4] = {0.06, 0.24, 0.12, 0.1};
const float kErrorsZ[4] = {0.06, 0.24, 0.15, 0.1};
UpdateRun3ClusterErrors(kErrorsY, kErrorsZ);
#else
// clang-format off
const float kParamS0Par[2][3][6] =
{
{ { 6.45913474727e-04, 2.51547407970e-05, 1.57551113516e-02, 1.99872811635e-08, -5.86769729853e-03, 9.16301505640e-05 },
{ 9.71546804067e-04, 1.70938055817e-05, 2.17084009200e-02, 3.90275758377e-08, -1.68631039560e-03, 8.40498323669e-05 },
{ 7.27469159756e-05, 2.63869314949e-05, 3.29690799117e-02, -2.19274429725e-08, 1.77378822118e-02, 3.26595727529e-05 }
}, {
{ 1.46874145139e-03, 6.36232061879e-06, 1.28665426746e-02, 1.19409449439e-07, 1.15883778781e-02, 1.32179644424e-04 },
{ 1.15970033221e-03, 1.30452335725e-05, 1.87015570700e-02, 5.39766737973e-08, 1.64790824056e-02, 1.44115634612e-04 },
{ 6.27940462437e-04, 1.78520094778e-05, 2.83537860960e-02, 1.16867742150e-08, 5.02607785165e-02, 1.88510020962e-04 } }
};
const float kParamErrorsSeeding0[2][3][4] =
{
{ { 4.17516864836e-02, 1.87623649254e-04, 5.63788712025e-02, 5.38373768330e-01, },
{ 8.29434990883e-02, 2.03291710932e-04, 6.81538805366e-02, 9.70965325832e-01, },
{ 8.67543518543e-02, 2.10733342101e-04, 1.38366967440e-01, 2.55089461803e-01, }
}, {
{ 5.96254616976e-02, 8.62886518007e-05, 3.61776389182e-02, 4.79704320431e-01, },
{ 6.12571723759e-02, 7.23929333617e-05, 3.93057651818e-02, 9.29222583771e-01, },
{ 6.58465921879e-02, 1.03639606095e-04, 6.07583411038e-02, 9.90289509296e-01, } }
};
// clang-format on
for (int32_t i = 0; i < 2; i++) {
for (int32_t j = 0; j < 3; j++) {
for (int32_t k = 0; k < 6; k++) {
ParamS0Par[i][j][k] = kParamS0Par[i][j][k];
}
}
}
for (int32_t i = 0; i < 2; i++) {
for (int32_t j = 0; j < 3; j++) {
for (int32_t k = 0; k < 4; k++) {
ParamErrorsSeeding0[i][j][k] = kParamErrorsSeeding0[i][j][k];
}
}
}
#endif
UpdateBzOnly(solenoidBz, assumeConstantBz);
par.dodEdx = 0;
constexpr float plusZmin = 0.0529937;
constexpr float plusZmax = 249.778;
constexpr float minusZmin = -249.645;
constexpr float minusZmax = -0.0799937;
for (int32_t i = 0; i < GPUCA_NSECTORS; i++) {
const bool zPlus = (i < GPUCA_NSECTORS / 2);
SectorParam[i].ZMin = zPlus ? plusZmin : minusZmin;
SectorParam[i].ZMax = zPlus ? plusZmax : minusZmax;
int32_t tmp = i;
if (tmp >= GPUCA_NSECTORS / 2) {
tmp -= GPUCA_NSECTORS / 2;
}
if (tmp >= GPUCA_NSECTORS / 4) {
tmp -= GPUCA_NSECTORS / 2;
}
SectorParam[i].Alpha = 0.174533f + dAlpha * tmp;
SectorParam[i].CosAlpha = CAMath::Cos(SectorParam[i].Alpha);
SectorParam[i].SinAlpha = CAMath::Sin(SectorParam[i].Alpha);
SectorParam[i].AngleMin = SectorParam[i].Alpha - dAlpha / 2.f;
SectorParam[i].AngleMax = SectorParam[i].Alpha + dAlpha / 2.f;
}
par.continuousTracking = false;
continuousMaxTimeBin = 0;
tpcCutTimeBin = 0;
}
void GPUParam::UpdateSettings(const GPUSettingsGRP* g, const GPUSettingsProcessing* p, const GPURecoStepConfiguration* w, const GPUSettingsRecDynamic* d)
{
if (g) {
UpdateBzOnly(g->solenoidBzNominalGPU, g->constBz);
par.continuousTracking = g->grpContinuousMaxTimeBin != 0;
continuousMaxTimeBin = g->grpContinuousMaxTimeBin == -1 ? GPUSettings::TPC_MAX_TF_TIME_BIN : g->grpContinuousMaxTimeBin;
tpcCutTimeBin = g->tpcCutTimeBin;
}
qptB5Scaler = CAMath::Abs(bzkG) > 0.1f ? CAMath::Abs(bzkG) / 5.006680f : 1.f; // Repeat here, since passing in g is optional
if (p) {
UpdateRun3ClusterErrors(p->param.tpcErrorParamY, p->param.tpcErrorParamZ);
}
if (w) {
par.dodEdx = dodEdxEnabled = w->steps.isSet(GPUDataTypes::RecoStep::TPCdEdx);
if (dodEdxEnabled && p && p->tpcDownscaledEdx != 0) {
dodEdxEnabled = (rand() % 100) < p->tpcDownscaledEdx;
}
}
if (d) {
rec.dyn = *d;
}
}
void GPUParam::UpdateBzOnly(float newSolenoidBz, bool assumeConstantBz)
{
bzkG = newSolenoidBz;
bzCLight = bzkG * o2::gpu::gpu_common_constants::kCLight;
polynomialField.Reset();
if (assumeConstantBz) {
GPUTPCGMPolynomialFieldManager::GetPolynomialField(GPUTPCGMPolynomialFieldManager::kUniform, bzkG, polynomialField);
} else {
GPUTPCGMPolynomialFieldManager::GetPolynomialField(bzkG, polynomialField);
}
qptB5Scaler = CAMath::Abs(bzkG) > 0.1f ? CAMath::Abs(bzkG) / 5.006680f : 1.f;
}
void GPUParam::SetDefaults(const GPUSettingsGRP* g, const GPUSettingsRec* r, const GPUSettingsProcessing* p, const GPURecoStepConfiguration* w)
{
SetDefaults(g->solenoidBzNominalGPU, g->constBz);
if (r) {
rec = *r;
}
UpdateSettings(g, p, w);
}
void GPUParam::UpdateRun3ClusterErrors(const float* yErrorParam, const float* zErrorParam)
{
#ifdef GPUCA_TPC_GEOMETRY_O2
for (int32_t yz = 0; yz < 2; yz++) {
const float* param = yz ? zErrorParam : yErrorParam;
for (int32_t rowType = 0; rowType < 4; rowType++) {
constexpr int32_t regionMap[4] = {0, 4, 6, 8};
ParamErrors[yz][rowType][0] = param[0] * param[0];
ParamErrors[yz][rowType][1] = param[1] * param[1] * GPUTPCGeometry::PadHeightByRegion(regionMap[rowType]);
ParamErrors[yz][rowType][2] = param[2] * param[2] / GPUTPCGeometry::TPCLength() / GPUTPCGeometry::PadHeightByRegion(regionMap[rowType]);
ParamErrors[yz][rowType][3] = param[3] * param[3] * rec.tpc.clusterErrorOccupancyScaler * rec.tpc.clusterErrorOccupancyScaler;
}
}
#endif
}
void GPUParamRTC::setFrom(const GPUParam& param)
{
memcpy((void*)this, (void*)¶m, sizeof(param));
}
std::string GPUParamRTC::generateRTCCode(const GPUParam& param, bool useConstexpr)
{
return "#include <string>\n"
"#include <vector>\n"
"#include <cstdint>\n"
"#include <cstddef>\n"
"namespace o2::gpu { class GPUDisplayFrontendInterface; }\n" +
qConfigPrintRtc(std::make_tuple(¶m.rec.tpc, ¶m.rec.trd, ¶m.rec, ¶m.par), useConstexpr);
}
static_assert(sizeof(o2::gpu::GPUParam) == sizeof(o2::gpu::GPUParamRTC), "RTC param size mismatch");