Skip to content

Commit ef0c205

Browse files
committed
GPU: Fix standalone dump: don't dump MC labels when there are no clusters / etc.
1 parent 4fcadb0 commit ef0c205

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

GPU/GPUTracking/Base/GPUReconstruction.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ class GPUReconstruction
292292

293293
// Private helper functions for reading / writing / allocating IO buffer from/to file
294294
template <class T, class S>
295-
void DumpData(FILE* fp, const T* const* entries, const S* num, InOutPointerType type);
295+
unsigned int DumpData(FILE* fp, const T* const* entries, const S* num, InOutPointerType type);
296296
template <class T, class S>
297297
size_t ReadData(FILE* fp, const T** entries, S* num, std::unique_ptr<T[]>* mem, InOutPointerType type, T** nonConstPtrs = nullptr);
298298
template <class T>
@@ -508,15 +508,15 @@ inline void GPUReconstruction::SetupGPUProcessor(T* proc, bool allocate)
508508
}
509509

510510
template <class T, class S>
511-
inline void GPUReconstruction::DumpData(FILE* fp, const T* const* entries, const S* num, InOutPointerType type)
511+
inline unsigned int GPUReconstruction::DumpData(FILE* fp, const T* const* entries, const S* num, InOutPointerType type)
512512
{
513513
int count = getNIOTypeMultiplicity(type);
514514
unsigned int numTotal = 0;
515515
for (int i = 0; i < count; i++) {
516516
numTotal += num[i];
517517
}
518518
if (numTotal == 0) {
519-
return;
519+
return 0;
520520
}
521521
fwrite(&type, sizeof(type), 1, fp);
522522
for (int i = 0; i < count; i++) {
@@ -525,6 +525,10 @@ inline void GPUReconstruction::DumpData(FILE* fp, const T* const* entries, const
525525
fwrite(entries[i], sizeof(*entries[i]), num[i], fp);
526526
}
527527
}
528+
if (mProcessingSettings.debugLevel >= 2) {
529+
GPUInfo("Dumped %lld %s", (long long int)numTotal, IOTYPENAMES[type]);
530+
}
531+
return numTotal;
528532
}
529533

530534
template <class T, class S>

GPU/GPUTracking/Global/GPUChain.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ class GPUChain
127127
mRec->AllocateIOMemoryHelper<T>(n, ptr, u);
128128
}
129129
template <class T, class S>
130-
inline void DumpData(FILE* fp, const T* const* entries, const S* num, InOutPointerType type)
130+
inline unsigned int DumpData(FILE* fp, const T* const* entries, const S* num, InOutPointerType type)
131131
{
132-
mRec->DumpData<T>(fp, entries, num, type);
132+
return mRec->DumpData<T>(fp, entries, num, type);
133133
}
134134
template <class T, class S>
135135
inline size_t ReadData(FILE* fp, const T** entries, S* num, std::unique_ptr<T[]>* mem, InOutPointerType type, T** nonConstPtrs = nullptr)

GPU/GPUTracking/Global/GPUChainTrackingIO.cxx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,17 @@ void GPUChainTracking::DumpData(const char* filename)
7777
DumpData(fp, mIOPtrs.rawClusters, mIOPtrs.nRawClusters, InOutPointerType::RAW_CLUSTERS);
7878
#ifdef HAVE_O2HEADERS
7979
if (mIOPtrs.clustersNative) {
80-
DumpData(fp, &mIOPtrs.clustersNative->clustersLinear, &mIOPtrs.clustersNative->nClustersTotal, InOutPointerType::CLUSTERS_NATIVE);
81-
fwrite(&mIOPtrs.clustersNative->nClusters[0][0], sizeof(mIOPtrs.clustersNative->nClusters[0][0]), NSLICES * GPUCA_ROW_COUNT, fp);
82-
if (mIOPtrs.clustersNative->clustersMCTruth) {
83-
const auto& buffer = mIOPtrs.clustersNative->clustersMCTruth->getBuffer();
84-
std::pair<const char*, size_t> tmp = {buffer.data(), buffer.size()};
85-
DumpData(fp, &tmp.first, &tmp.second, InOutPointerType::CLUSTER_NATIVE_MC);
80+
if (DumpData(fp, &mIOPtrs.clustersNative->clustersLinear, &mIOPtrs.clustersNative->nClustersTotal, InOutPointerType::CLUSTERS_NATIVE)) {
81+
fwrite(&mIOPtrs.clustersNative->nClusters[0][0], sizeof(mIOPtrs.clustersNative->nClusters[0][0]), NSLICES * GPUCA_ROW_COUNT, fp);
82+
if (mIOPtrs.clustersNative->clustersMCTruth) {
83+
const auto& buffer = mIOPtrs.clustersNative->clustersMCTruth->getBuffer();
84+
std::pair<const char*, size_t> tmp = {buffer.data(), buffer.size()};
85+
DumpData(fp, &tmp.first, &tmp.second, InOutPointerType::CLUSTER_NATIVE_MC);
86+
}
8687
}
8788
}
8889
if (mIOPtrs.tpcPackedDigits) {
89-
DumpData(fp, mIOPtrs.tpcPackedDigits->tpcDigits, mIOPtrs.tpcPackedDigits->nTPCDigits, InOutPointerType::TPC_DIGIT);
90-
if (mIOPtrs.tpcPackedDigits->tpcDigitsMC) {
90+
if (DumpData(fp, mIOPtrs.tpcPackedDigits->tpcDigits, mIOPtrs.tpcPackedDigits->nTPCDigits, InOutPointerType::TPC_DIGIT) && mIOPtrs.tpcPackedDigits->tpcDigitsMC) {
9191
const char* ptrs[NSLICES];
9292
size_t sizes[NSLICES];
9393
for (unsigned int i = 0; i < NSLICES; i++) {
@@ -121,8 +121,9 @@ void GPUChainTracking::DumpData(const char* filename)
121121
}
122122
}
123123
total *= TPCZSHDR::TPC_ZS_PAGE_SIZE;
124-
DumpData(fp, &ptr, &total, InOutPointerType::TPC_ZS);
125-
fwrite(&counts, sizeof(counts), 1, fp);
124+
if (DumpData(fp, &ptr, &total, InOutPointerType::TPC_ZS)) {
125+
fwrite(&counts, sizeof(counts), 1, fp);
126+
}
126127
}
127128
#endif
128129
DumpData(fp, mIOPtrs.sliceTracks, mIOPtrs.nSliceTracks, InOutPointerType::SLICE_OUT_TRACK);

0 commit comments

Comments
 (0)