Skip to content

Commit 59a4cf5

Browse files
Felix Schlepperf3sch
authored andcommitted
ITS: fix GPU tracking
- compute-sanitizer reveal malicious write past allocated table - ZBins for map lookup was not taken from params
1 parent f0eebb6 commit 59a4cf5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Detectors/ITSMFT/ITS/tracking/GPU/cuda/TrackingKernels.cu

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ GPUd() const int4 getBinsRect(const Cluster& currentCluster, const int layerInde
8484

8585
return int4{o2::gpu::CAMath::Max(0, utils.getZBinIndex(layerIndex + 1, zRangeMin)),
8686
utils.getPhiBinIndex(math_utils::getNormalizedPhi(phiRangeMin)),
87-
o2::gpu::CAMath::Min(ZBins - 1, utils.getZBinIndex(layerIndex + 1, zRangeMax)),
87+
o2::gpu::CAMath::Min(utils.getNzBins() - 1, utils.getZBinIndex(layerIndex + 1, zRangeMax)),
8888
utils.getPhiBinIndex(math_utils::getNormalizedPhi(phiRangeMax))};
8989
}
9090

@@ -1248,7 +1248,7 @@ void processNeighboursHandler(const int startLayer,
12481248
maxChi2ClusterAttachment,
12491249
propagator,
12501250
matCorrType);
1251-
auto t1 = updatedCellSeed.size();
1251+
12521252
GPUChkErrS(cudaFree(d_temp_storage));
12531253
int level = startLevel;
12541254
for (int iLayer{startLayer - 1}; iLayer > 0 && level > 2; --iLayer) {
@@ -1258,7 +1258,7 @@ void processNeighboursHandler(const int startLayer,
12581258
thrust::device_vector<CellSeed>().swap(updatedCellSeed);
12591259
thrust::device_vector<int>().swap(updatedCellId);
12601260
auto lastCellSeedSize{lastCellSeed.size()};
1261-
foundSeedsTable.resize(nCells[iLayer] + 1);
1261+
foundSeedsTable.resize(lastCellSeedSize + 1);
12621262
thrust::fill(foundSeedsTable.begin(), foundSeedsTable.end(), 0);
12631263
--level;
12641264
gpu::processNeighboursKernel<true><<<nBlocks, nThreads>>>(iLayer,
@@ -1282,14 +1282,14 @@ void processNeighboursHandler(const int startLayer,
12821282
temp_storage_bytes, // temp_storage_bytes
12831283
thrust::raw_pointer_cast(&foundSeedsTable[0]), // d_in
12841284
thrust::raw_pointer_cast(&foundSeedsTable[0]), // d_out
1285-
nCells[iLayer] + 1, // num_items
1285+
foundSeedsTable.size(), // num_i_items
12861286
0)); // NOLINT: this is the offset of the sum, not a pointer
12871287
GPUChkErrS(cudaMalloc(&d_temp_storage, temp_storage_bytes));
12881288
GPUChkErrS(cub::DeviceScan::ExclusiveSum(d_temp_storage, // d_temp_storage
12891289
temp_storage_bytes, // temp_storage_bytes
12901290
thrust::raw_pointer_cast(&foundSeedsTable[0]), // d_in
12911291
thrust::raw_pointer_cast(&foundSeedsTable[0]), // d_out
1292-
nCells[iLayer] + 1, // num_items
1292+
foundSeedsTable.size(), // num_i_items
12931293
0)); // NOLINT: this is the offset of the sum, not a pointer
12941294
auto foundSeeds{foundSeedsTable.back()};
12951295
updatedCellId.resize(foundSeeds);

0 commit comments

Comments
 (0)