forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGPUTPCCompression.cxx
More file actions
131 lines (115 loc) · 6.29 KB
/
GPUTPCCompression.cxx
File metadata and controls
131 lines (115 loc) · 6.29 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
// 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 GPUTPCCompression.cxx
/// \author David Rohr
#include "GPUTPCCompression.h"
#include "GPUReconstruction.h"
#include "GPUO2DataTypes.h"
#include "GPUMemorySizeScalers.h"
#include "GPUDefParametersRuntime.h"
using namespace o2::gpu;
void GPUTPCCompression::InitializeProcessor() {}
void* GPUTPCCompression::SetPointersOutputGPU(void* mem)
{
SetPointersCompressedClusters(mem, *mOutputA, mOutputA->nAttachedClusters, mOutputA->nTracks, mOutputA->nUnattachedClusters, true);
return mem;
}
void* GPUTPCCompression::SetPointersOutputHost(void* mem)
{
computePointerWithoutAlignment(mem, mOutputFlat);
SetPointersCompressedClusters(mem, *mOutput, mOutput->nAttachedClusters, mOutput->nTracks, mOutput->nUnattachedClusters, true);
return mem;
}
void* GPUTPCCompression::SetPointersScratch(void* mem)
{
int32_t gatherMode = mRec->GetProcessingSettings().tpcCompressionGatherMode == -1 ? mRec->getGPUParameters(mRec->GetRecoStepsGPU() & GPUDataTypes::RecoStep::TPCCompression).par_COMP_GATHER_MODE : mRec->GetProcessingSettings().tpcCompressionGatherMode;
computePointerWithAlignment(mem, mClusterStatus, mMaxClusters);
if (gatherMode >= 2) {
computePointerWithAlignment(mem, mAttachedClusterFirstIndex, mMaxTracks);
}
if (gatherMode != 1) {
SetPointersCompressedClusters(mem, mPtrs, mMaxTrackClusters, mMaxTracks, mMaxClustersInCache, false);
}
return mem;
}
void* GPUTPCCompression::SetPointersOutput(void* mem)
{
int32_t gatherMode = mRec->GetProcessingSettings().tpcCompressionGatherMode == -1 ? mRec->getGPUParameters(mRec->GetRecoStepsGPU() & GPUDataTypes::RecoStep::TPCCompression).par_COMP_GATHER_MODE : mRec->GetProcessingSettings().tpcCompressionGatherMode;
computePointerWithAlignment(mem, mAttachedClusterFirstIndex, mMaxTrackClusters);
if (gatherMode == 1) {
SetPointersCompressedClusters(mem, mPtrs, mMaxTrackClusters, mMaxTracks, mMaxClustersInCache, false);
}
return mem;
}
template <class T>
void GPUTPCCompression::SetPointersCompressedClusters(void*& mem, T& c, uint32_t nClA, uint32_t nTr, uint32_t nClU, bool reducedClA)
{
computePointerWithAlignment(mem, c.qTotU, nClU); // Do not reorder, qTotU ist used as first address in GPUChainTracking::RunTPCCompression
computePointerWithAlignment(mem, c.qMaxU, nClU);
computePointerWithAlignment(mem, c.flagsU, nClU);
computePointerWithAlignment(mem, c.padDiffU, nClU);
computePointerWithAlignment(mem, c.timeDiffU, nClU);
computePointerWithAlignment(mem, c.sigmaPadU, nClU);
computePointerWithAlignment(mem, c.sigmaTimeU, nClU);
computePointerWithAlignment(mem, c.nSliceRowClusters, GPUCA_ROW_COUNT * NSECTORS);
uint32_t nClAreduced = reducedClA ? nClA - nTr : nClA;
if (!(mRec->GetParam().rec.tpc.compressionTypeMask & GPUSettings::CompressionTrackModel)) {
return; // Track model disabled, do not allocate memory
}
computePointerWithAlignment(mem, c.qTotA, nClA);
computePointerWithAlignment(mem, c.qMaxA, nClA);
computePointerWithAlignment(mem, c.flagsA, nClA);
computePointerWithAlignment(mem, c.rowDiffA, nClAreduced);
computePointerWithAlignment(mem, c.sliceLegDiffA, nClAreduced);
computePointerWithAlignment(mem, c.padResA, nClAreduced);
computePointerWithAlignment(mem, c.timeResA, nClAreduced);
computePointerWithAlignment(mem, c.sigmaPadA, nClA);
computePointerWithAlignment(mem, c.sigmaTimeA, nClA);
computePointerWithAlignment(mem, c.qPtA, nTr);
computePointerWithAlignment(mem, c.rowA, nTr);
computePointerWithAlignment(mem, c.sliceA, nTr);
computePointerWithAlignment(mem, c.timeA, nTr);
computePointerWithAlignment(mem, c.padA, nTr);
computePointerWithAlignment(mem, c.nTrackClusters, nTr);
}
void* GPUTPCCompression::SetPointersMemory(void* mem)
{
computePointerWithAlignment(mem, mMemory);
computePointerWithAlignment(mem, mOutput);
mOutputA = mOutput;
return mem;
}
void GPUTPCCompression::RegisterMemoryAllocation()
{
AllocateAndInitializeLate();
int32_t gatherMode = mRec->GetProcessingSettings().tpcCompressionGatherMode == -1 ? mRec->getGPUParameters(mRec->GetRecoStepsGPU() & GPUDataTypes::RecoStep::TPCCompression).par_COMP_GATHER_MODE : mRec->GetProcessingSettings().tpcCompressionGatherMode;
mMemoryResOutputHost = mRec->RegisterMemoryAllocation(this, &GPUTPCCompression::SetPointersOutputHost, GPUMemoryResource::MEMORY_OUTPUT_FLAG | GPUMemoryResource::MEMORY_HOST | GPUMemoryResource::MEMORY_CUSTOM, "TPCCompressionOutputHost");
if (gatherMode == 3) {
mMemoryResOutputGPU = mRec->RegisterMemoryAllocation(this, &GPUTPCCompression::SetPointersOutputGPU, GPUMemoryResource::MEMORY_SCRATCH | GPUMemoryResource::MEMORY_GPU | GPUMemoryResource::MEMORY_CUSTOM | GPUMemoryResource::MEMORY_STACK, "TPCCompressionOutputGPU");
}
uint32_t stackScratch = (gatherMode != 3) ? GPUMemoryResource::MEMORY_STACK : 0;
if (gatherMode < 2) {
mRec->RegisterMemoryAllocation(this, &GPUTPCCompression::SetPointersOutput, GPUMemoryResource::MEMORY_OUTPUT | stackScratch, "TPCCompressionOutput");
}
mRec->RegisterMemoryAllocation(this, &GPUTPCCompression::SetPointersScratch, GPUMemoryResource::MEMORY_SCRATCH | stackScratch, "TPCCompressionScratch");
mRec->RegisterMemoryAllocation(this, &GPUTPCCompression::SetPointersMemory, GPUMemoryResource::MEMORY_PERMANENT, "TPCCompressionMemory");
}
void GPUTPCCompression::SetMaxData(const GPUTrackingInOutPointers& io)
{
mMaxClusters = io.clustersNative->nClustersTotal;
mMaxClusterFactorBase1024 = mMaxClusters > 100000000 ? mRec->MemoryScalers()->NTPCUnattachedHitsBase1024(mRec->GetParam().rec.tpc.rejectionStrategy) : 1024;
mMaxClustersInCache = mMaxClusters * mMaxClusterFactorBase1024 / 1024;
mMaxTrackClusters = mRec->GetConstantMem().tpcMerger.NOutputTrackClusters();
mMaxTracks = mRec->GetConstantMem().tpcMerger.NOutputTracks();
if (mMaxClusters % 16) {
mMaxClusters += 16 - (mMaxClusters % 16);
}
}