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 "GPUDataTypesIO.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/qconfig_rtc.h"
32
33void GPUParam::SetDefaults(float solenoidBz, bool assumeConstantBz)
34{
35 memset((void*)this, 0, sizeof(*this));
36 new (&rec) GPUSettingsRec;
37 occupancyMap = nullptr;
40
41#ifndef GPUCA_RUN2
42 const float kErrorsY[4] = {0.06, 0.24, 0.12, 0.1};
43 const float kErrorsZ[4] = {0.06, 0.24, 0.15, 0.1};
44
45 UpdateRun3ClusterErrors(kErrorsY, kErrorsZ);
46#else
47 // clang-format off
48 const float kParamS0Par[2][3][6] =
49 {
50 { { 6.45913474727e-04, 2.51547407970e-05, 1.57551113516e-02, 1.99872811635e-08, -5.86769729853e-03, 9.16301505640e-05 },
51 { 9.71546804067e-04, 1.70938055817e-05, 2.17084009200e-02, 3.90275758377e-08, -1.68631039560e-03, 8.40498323669e-05 },
52 { 7.27469159756e-05, 2.63869314949e-05, 3.29690799117e-02, -2.19274429725e-08, 1.77378822118e-02, 3.26595727529e-05 }
53 }, {
54 { 1.46874145139e-03, 6.36232061879e-06, 1.28665426746e-02, 1.19409449439e-07, 1.15883778781e-02, 1.32179644424e-04 },
55 { 1.15970033221e-03, 1.30452335725e-05, 1.87015570700e-02, 5.39766737973e-08, 1.64790824056e-02, 1.44115634612e-04 },
56 { 6.27940462437e-04, 1.78520094778e-05, 2.83537860960e-02, 1.16867742150e-08, 5.02607785165e-02, 1.88510020962e-04 } }
57 };
58 const float kParamErrorsSeeding0[2][3][4] =
59 {
60 { { 4.17516864836e-02, 1.87623649254e-04, 5.63788712025e-02, 5.38373768330e-01, },
61 { 8.29434990883e-02, 2.03291710932e-04, 6.81538805366e-02, 9.70965325832e-01, },
62 { 8.67543518543e-02, 2.10733342101e-04, 1.38366967440e-01, 2.55089461803e-01, }
63 }, {
64 { 5.96254616976e-02, 8.62886518007e-05, 3.61776389182e-02, 4.79704320431e-01, },
65 { 6.12571723759e-02, 7.23929333617e-05, 3.93057651818e-02, 9.29222583771e-01, },
66 { 6.58465921879e-02, 1.03639606095e-04, 6.07583411038e-02, 9.90289509296e-01, } }
67 };
68 // clang-format on
69
70 for (int32_t i = 0; i < 2; i++) {
71 for (int32_t j = 0; j < 3; j++) {
72 for (int32_t k = 0; k < 6; k++) {
73 ParamS0Par[i][j][k] = kParamS0Par[i][j][k];
74 }
75 }
76 }
77
78 for (int32_t i = 0; i < 2; i++) {
79 for (int32_t j = 0; j < 3; j++) {
80 for (int32_t k = 0; k < 4; k++) {
81 ParamErrorsSeeding0[i][j][k] = kParamErrorsSeeding0[i][j][k];
82 }
83 }
84 }
85#endif
86
87 UpdateBzOnly(solenoidBz, assumeConstantBz);
88 par.dodEdx = 0;
89
90 par.continuousTracking = false;
92 tpcCutTimeBin = 0;
93}
94
95void GPUParam::UpdateSettings(const GPUSettingsGRP* g, const GPUSettingsProcessing* p, const GPURecoStepConfiguration* w, const GPUSettingsRecDynamic* d)
96{
97 if (g) {
98 UpdateBzOnly(g->solenoidBzNominalGPU, g->constBz);
99 par.continuousTracking = g->grpContinuousMaxTimeBin != 0;
100 continuousMaxTimeBin = g->grpContinuousMaxTimeBin == -1 ? GPUSettings::TPC_MAX_TF_TIME_BIN : g->grpContinuousMaxTimeBin;
101 tpcCutTimeBin = g->tpcCutTimeBin;
102 }
103 qptB5Scaler = CAMath::Abs(bzkG) > 0.1f ? CAMath::Abs(bzkG) / 5.006680f : 1.f; // Repeat here, since passing in g is optional
104 if (p) {
105 UpdateRun3ClusterErrors(p->param.tpcErrorParamY, p->param.tpcErrorParamZ);
106 }
107 if (w) {
108 par.dodEdx = dodEdxEnabled = w->steps.isSet(gpudatatypes::RecoStep::TPCdEdx);
109 if (dodEdxEnabled && p && p->tpcDownscaledEdx != 0) {
110 dodEdxEnabled = (rand() % 100) < p->tpcDownscaledEdx;
111 }
112 }
113 if (d) {
114 rec.dyn = *d;
115 }
116}
117
118void GPUParam::UpdateBzOnly(float newSolenoidBz, bool assumeConstantBz)
119{
120 bzkG = newSolenoidBz;
121 bzCLight = bzkG * o2::gpu::gpu_common_constants::kCLight;
123 if (assumeConstantBz) {
125 } else {
127 }
128 qptB5Scaler = CAMath::Abs(bzkG) > 0.1f ? CAMath::Abs(bzkG) / 5.006680f : 1.f;
129}
130
131void GPUParam::SetDefaults(const GPUSettingsGRP* g, const GPUSettingsRec* r, const GPUSettingsProcessing* p, const GPURecoStepConfiguration* w)
132{
133 SetDefaults(g->solenoidBzNominalGPU, g->constBz);
134 if (r) {
135 rec = *r;
136 }
137 UpdateSettings(g, p, w);
138}
139
140void GPUParam::UpdateRun3ClusterErrors(const float* yErrorParam, const float* zErrorParam)
141{
142#ifndef GPUCA_RUN2
143 for (int32_t yz = 0; yz < 2; yz++) {
144 const float* param = yz ? zErrorParam : yErrorParam;
145 for (int32_t rowType = 0; rowType < 4; rowType++) {
146 constexpr int32_t regionMap[4] = {0, 4, 6, 8};
147 ParamErrors[yz][rowType][0] = param[0] * param[0];
148 ParamErrors[yz][rowType][1] = param[1] * param[1] * GPUTPCGeometry::PadHeightByRegion(regionMap[rowType]);
149 ParamErrors[yz][rowType][2] = param[2] * param[2] / GPUTPCGeometry::TPCLength() / GPUTPCGeometry::PadHeightByRegion(regionMap[rowType]);
150 ParamErrors[yz][rowType][3] = param[3] * param[3] * rec.tpc.clusterErrorOccupancyScaler * rec.tpc.clusterErrorOccupancyScaler;
151 }
152 }
153#endif
154}
155
157{
158 memcpy((void*)this, (void*)&param, sizeof(param));
159}
160
161std::string GPUParamRTC::generateRTCCode(const GPUParam& param, bool useConstexpr)
162{
163 return "#include <string>\n"
164 "#include <vector>\n"
165 "#include <cstdint>\n"
166 "#include <cstddef>\n"
167 "namespace o2::gpu { class GPUDisplayFrontendInterface; }\n" +
168 qConfigPrintRtc(std::make_tuple(&param.rec.tpc, &param.rec.trd, &param.rec, &param.par), useConstexpr);
169}
170
171static_assert(sizeof(o2::gpu::GPUParam) == sizeof(o2::gpu::GPUParamRTC), "RTC param size mismatch");
#define rand()
int32_t i
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
uint32_t j
Definition RawData.h:0
static int32_t GetPolynomialField(float nominalFieldkG, o2::gpu::GPUTPCGMPolynomialField &field)
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:161
void setFrom(const GPUParam &param)
Definition GPUParam.cxx:156
void SetDefaults(float solenoidBz, bool assumeConstantBz=false)
Definition GPUParam.cxx:33
void UpdateRun3ClusterErrors(const float *yErrorParam, const float *zErrorParam)
Definition GPUParam.cxx:140
void UpdateSettings(const GPUSettingsGRP *g, const GPUSettingsProcessing *p=nullptr, const GPURecoStepConfiguration *w=nullptr, const GPUSettingsRecDynamic *d=nullptr)
Definition GPUParam.cxx:95
void UpdateBzOnly(float newSolenoidBz, bool assumeConstantBz=false)
Definition GPUParam.cxx:118