Skip to content

Commit 34ca1f8

Browse files
committed
More fixes
1 parent 6b2a2d4 commit 34ca1f8

7 files changed

Lines changed: 30 additions & 19 deletions

File tree

GPU/GPUTracking/Global/GPUChainTrackingClusterizer.cxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,8 +1059,9 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
10591059
return;
10601060
}
10611061

1062-
if (propagateMCLabels && fragment.index == 0) {
1063-
clusterer.PrepareMC();
1062+
if (propagateMCLabels) {
1063+
// AllocMCBuffers must be called for every fragment, to clear leftovers from previous fragment
1064+
clusterer.AllocMCBuffers();
10641065
clusterer.mPinputLabels = digitsMC->v[iSector];
10651066
if (clusterer.mPinputLabels == nullptr) {
10661067
GPUFatal("MC label container missing, sector %d", iSector);
@@ -1455,12 +1456,12 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
14551456
runKernel<GPUTPCCFMCLabelFlattener, GPUTPCCFMCLabelFlattener::setRowOffsets>({GetGrid(GPUTPCGeometry::NROWS, lane, GPUReconstruction::krnlDeviceType::CPU), {iSector}});
14561457
GPUTPCCFMCLabelFlattener::setGlobalOffsetsAndAllocate(clusterer, mcLinearLabels);
14571458
runKernel<GPUTPCCFMCLabelFlattener, GPUTPCCFMCLabelFlattener::flatten>({GetGrid(GPUTPCGeometry::NROWS, lane, GPUReconstruction::krnlDeviceType::CPU), {iSector}}, &mcLinearLabels);
1458-
clusterer.clearMCMemory();
1459+
clusterer.FreeMCBuffers();
14591460
assert(propagateMCLabels ? mcLinearLabels.header.size() == nClsTotal : true);
14601461
}
14611462
if (propagateMCLabels) {
14621463
for (int32_t lane = 0; lane < maxLane; lane++) {
1463-
processors()->tpcClusterer[iSectorBase + lane].clearMCMemory();
1464+
processors()->tpcClusterer[iSectorBase + lane].FreeMCBuffers();
14641465
}
14651466
}
14661467
if (buildNativeHost && buildNativeGPU && anyLaneHasData) {

GPU/GPUTracking/TPCClusterFinder/GPUTPCCFCheckPadBaseline.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,9 @@ GPUd() void GPUTPCCFHIPClusterizer::Thread<0>(int32_t nBlocks, int32_t nThreads,
518518
const auto* tails = GetHIPTails(clusterer, row);
519519
const auto& fragment = clusterer.mPmemory->fragment;
520520

521-
auto* clusterPosInRow = clusterer.mPhipClusterPosInRow + row * MaxHIPTailsPerRow;
521+
auto* clusterPosInRow = clusterer.mPhipClusterPosInRow
522+
? clusterer.mPhipClusterPosInRow + row * MaxHIPTailsPerRow
523+
: nullptr;
522524

523525
for (uint32_t iTail = iThread + 1; iTail <= nTails; iTail += nThreads) {
524526

GPU/GPUTracking/TPCClusterFinder/GPUTPCCFClusterizer.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ GPUdii() void GPUTPCCFClusterizer::computeClustersImpl(int32_t nBlocks, int32_t
3939
Charge charge = chargeMap[pos].unpack();
4040

4141
ClusterAccumulator pc;
42-
CPU_ONLY(labelAcc->collect(pos));
42+
CPU_ONLY(labelAcc->collect(pos, charge));
4343

4444
buildCluster(
4545
calib,
@@ -112,7 +112,7 @@ GPUdii() void GPUTPCCFClusterizer::updateClusterInner(
112112
PackedCharge p = buf[N * lid + i];
113113

114114
Charge q = cluster->updateInner(p, d);
115-
CPU_ONLY(labelAcc->collect(pos.delta(d)));
115+
CPU_ONLY(labelAcc->collect(pos.delta(d), q));
116116

117117
aboveThreshold |= (uint8_t(q > calib.tpc.cfInnerThreshold) << i);
118118
}
@@ -138,8 +138,8 @@ GPUdii() void GPUTPCCFClusterizer::updateClusterOuter(
138138

139139
Delta2 d = cfconsts::OuterNeighbors[i];
140140

141-
cluster->updateOuter(p, d);
142-
CPU_ONLY(labelAcc->collect(pos.delta(d)));
141+
[[maybe_unused]] Charge q = cluster->updateOuter(p, d);
142+
CPU_ONLY(labelAcc->collect(pos.delta(d), q));
143143
}
144144
}
145145

GPU/GPUTracking/TPCClusterFinder/GPUTPCClusterFinder.cxx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include "CfArray2D.h"
2828
#include "GPUTPCCFCheckPadBaseline.h"
2929

30+
#include <algorithm>
31+
3032
using namespace o2::gpu;
3133
using namespace o2::tpc;
3234

@@ -38,7 +40,7 @@ void GPUTPCClusterFinder::InitializeProcessor()
3840
GPUTPCClusterFinder::~GPUTPCClusterFinder()
3941
{
4042
delete[] mMinMaxCN;
41-
clearMCMemory();
43+
FreeMCBuffers();
4244
}
4345

4446
void* GPUTPCClusterFinder::SetPointersMemory(void* mem)
@@ -167,19 +169,19 @@ uint32_t GPUTPCClusterFinder::getNSteps(size_t items) const
167169
return c;
168170
}
169171

170-
void GPUTPCClusterFinder::PrepareMC()
172+
void GPUTPCClusterFinder::AllocMCBuffers()
171173
{
172174
assert(mNMaxClusterPerRow > 0);
173175

174-
clearMCMemory();
176+
FreeMCBuffers();
175177
size_t nItems = TPCMapMemoryLayout<decltype(*mPindexMap)>::items(mRec->GetProcessingSettings().overrideClusterizerFragmentLen);
176178
mPindexMap = new uint32_t[nItems];
177179
std::fill_n(mPindexMap, nItems, uint32_t(-1)); // TODO check performance of this call!
178180
mPlabelsByRow = new GPUTPCClusterMCInterimArray[GPUTPCGeometry::NROWS];
179181
mPlabelsInRow = new uint32_t[GPUTPCGeometry::NROWS];
180182
}
181183

182-
void GPUTPCClusterFinder::clearMCMemory()
184+
void GPUTPCClusterFinder::FreeMCBuffers()
183185
{
184186
delete[] mPindexMap;
185187
mPindexMap = nullptr;

GPU/GPUTracking/TPCClusterFinder/GPUTPCClusterFinder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ class GPUTPCClusterFinder : public GPUProcessor
9292
uint32_t getNSteps(size_t items) const;
9393
void SetNMaxDigits(size_t nDigits, size_t nPages, size_t nDigitsFragment, size_t nDigitsEndpointMax);
9494

95-
void PrepareMC();
96-
void clearMCMemory();
95+
void AllocMCBuffers();
96+
void FreeMCBuffers();
9797
#endif
9898
uint8_t* mPzs = nullptr;
9999
ZSOffset* mPzsOffsets = nullptr;

GPU/GPUTracking/TPCClusterFinder/MCLabelAccumulator.cxx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ MCLabelAccumulator::MCLabelAccumulator(GPUTPCClusterFinder& clusterer)
2828

2929
MCLabelAccumulator::~MCLabelAccumulator() {}
3030

31-
void MCLabelAccumulator::collect(const CfChargePos& pos)
31+
void MCLabelAccumulator::collect(const CfChargePos& pos, float q)
3232
{
33-
if (!engaged()) {
33+
if (q == 0 || !engaged()) {
3434
return;
3535
}
3636

@@ -60,11 +60,17 @@ void MCLabelAccumulator::collect(const CfChargePos& pos)
6060

6161
void MCLabelAccumulator::collectTail(tpccf::Row row, tpccf::Pad pad, uint16_t tailStart, uint16_t tailEnd)
6262
{
63+
if (!engaged()) {
64+
return;
65+
}
66+
6367
const auto basePos = CfChargePos{row, pad, 0};
6468

6569
for (uint16_t t = tailStart; t < tailEnd; t++) {
6670
const auto pos = basePos.delta({0, (int16_t)t});
67-
collect(pos);
71+
// Charge passed to collect() doesn't matter, collect() skips zero charges
72+
// But we know there's an interesting value, but it was zeroed in chargeMap by tail filter
73+
collect(pos, 1023.f);
6874
}
6975
}
7076

GPU/GPUTracking/TPCClusterFinder/MCLabelAccumulator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class MCLabelAccumulator
4545
MCLabelAccumulator(GPUTPCClusterFinder&);
4646
~MCLabelAccumulator(); // Explicit destructor to allow forward declaring MCCompLabel with std::vector
4747

48-
void collect(const CfChargePos& pos);
48+
void collect(const CfChargePos& pos, float q);
4949

5050
void collectTail(tpccf::Row row, tpccf::Pad pad, uint16_t tailStart, uint16_t tailEnd);
5151

0 commit comments

Comments
 (0)