Skip to content

Commit e39344f

Browse files
committed
GPU: Add compile-time option to do some ZS format checks during TPC ZS decoding
1 parent a466680 commit e39344f

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

GPU/GPUTracking/Global/GPUErrorCodes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ GPUCA_ERROR_CODE(21, ERROR_CF_CLUSTER_OVERFLOW)
3838
GPUCA_ERROR_CODE(22, ERROR_CF_ROW_CLUSTER_OVERFLOW)
3939
GPUCA_ERROR_CODE(23, ERROR_CF_GLOBAL_CLUSTER_OVERFLOW)
4040
GPUCA_ERROR_CODE(24, MAX_OVERFLOW_ERROR_NUMBER) // Overflow errors are detected as errno <= MAX_OVERFLOW_ERROR_NUMBER
41+
GPUCA_ERROR_CODE(25, ERROR_TPCZS_INVALID_ROW)
42+
GPUCA_ERROR_CODE(26, ERROR_TPCZS_INVALID_NADC)
43+
44+
// #define GPUCA_CHECK_TPCZS_CORRUPTION

GPU/GPUTracking/TPCClusterFinder/GPUTPCCFDecodeZS.cxx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ GPUdii() void GPUTPCCFDecodeZSLink::Thread<0>(int nBlocks, int nThreads, int iBl
240240
#endif
241241
}
242242

243+
int nDecoded = 0;
243244
const auto* decHdr = ConsumeHeader<TPCZSHDRV2>(page);
244245
ConsumeBytes(page, decHdr->firstZSDataOffset * 16);
245246

@@ -257,6 +258,7 @@ GPUdii() void GPUTPCCFDecodeZSLink::Thread<0>(int nBlocks, int nThreads, int iBl
257258
unsigned int nAdc = CAMath::Popcount(channelMask[0]) + CAMath::Popcount(channelMask[1]) + CAMath::Popcount(channelMask[2]);
258259

259260
bool inFragment = fragment.contains(timeBin);
261+
nDecoded += nAdc;
260262

261263
// TimeBin not in fragment: Skip this timebin header and fill positions with dummy values instead
262264
if (not inFragment) {
@@ -293,6 +295,17 @@ GPUdii() void GPUTPCCFDecodeZSLink::Thread<0>(int nBlocks, int nThreads, int iBl
293295
#endif
294296
pageDigitOffset += nAdc;
295297
} // for (unsigned int t = 0; t < decHdr->nTimebinHeaders; t++)
298+
(void)nDecoded;
299+
#ifdef GPUCA_CHECK_TPCZS_CORRUPTION
300+
if (iThread == 0 && nDecoded != decHdr->nADCsamples) {
301+
clusterer.raiseError(GPUErrors::ERROR_TPCZS_INVALID_NADC, clusterer.mISlice, decHdr->nADCsamples, nDecoded);
302+
/*#ifndef GPUCA_GPUCODE
303+
FILE* foo = fopen("dump.bin", "w+b");
304+
fwrite(pageSrc, 1, o2::raw::RDHUtils::getMemorySize(*rdHdr), foo);
305+
fclose(foo);
306+
#endif*/
307+
}
308+
#endif
296309
} // [CPU] for (unsigned int j = minJ; j < maxJ; j++)
297310
} // [CPU] for (unsigned int i = clusterer.mMinMaxCN[endpoint].minC; i < clusterer.mMinMaxCN[endpoint].maxC; i++)
298311
}
@@ -447,12 +460,14 @@ GPUd() void GPUTPCCFDecodeZSLink::WriteCharge(processorType& clusterer, unsigned
447460
{
448461
const unsigned int slice = clusterer.mISlice;
449462
ChargePos* positions = clusterer.mPpositions;
450-
if (padAndRow.getRow() >= GPUCA_ROW_COUNT) { // FIXME: to be removed once TPC does not send corrupt data any more
463+
#ifdef GPUCA_CHECK_TPCZS_CORRUPTION
464+
if (padAndRow.getRow() >= GPUCA_ROW_COUNT) {
451465
constexpr ChargePos INVALID_POS(UCHAR_MAX, UCHAR_MAX, INVALID_TIME_BIN);
452466
positions[positionOffset] = INVALID_POS;
467+
clusterer.raiseError(GPUErrors::ERROR_CF_ROW_CLUSTER_OVERFLOW, clusterer.mISlice * 1000 + padAndRow.getRow(), 0, 0);
453468
return;
454469
}
455-
470+
#endif
456471
Array2D<PackedCharge> chargeMap(reinterpret_cast<PackedCharge*>(clusterer.mPchargeMap));
457472

458473
ChargePos pos(padAndRow.getRow(), padAndRow.getPad(), localTime);

0 commit comments

Comments
 (0)