Skip to content

Commit c5ed8cf

Browse files
committed
GPU: Add cluster dump to CSV option in runCompressionStatistics
1 parent 177f569 commit c5ed8cf

4 files changed

Lines changed: 48 additions & 4 deletions

File tree

GPU/GPUTracking/DataCompression/GPUTPCClusterStatistics.cxx

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <cstring>
2020
#include <map>
2121
#include <queue>
22+
#include <fstream>
2223

2324
using namespace o2::gpu;
2425

@@ -106,7 +107,7 @@ void GenerateCodes(const INode* node, const HuffCode& prefix, HuffCodeMap& outCo
106107
} // anonymous namespace
107108
} // namespace o2::gpu
108109

109-
void GPUTPCClusterStatistics::RunStatistics(const o2::tpc::ClusterNativeAccess* clustersNative, const o2::tpc::CompressedClusters* clustersCompressed, const GPUParam& param)
110+
void GPUTPCClusterStatistics::RunStatistics(const o2::tpc::ClusterNativeAccess* clustersNative, const o2::tpc::CompressedClusters* clustersCompressed, const GPUParam& param, bool dumpCSV)
110111
{
111112
uint32_t decodingErrors = 0;
112113
o2::tpc::ClusterNativeAccess clustersNativeDecoded;
@@ -185,6 +186,49 @@ void GPUTPCClusterStatistics::RunStatistics(const o2::tpc::ClusterNativeAccess*
185186
FillStatisticCombined(mPQU, clustersCompressed->qMaxU, clustersCompressed->qTotU, clustersCompressed->nUnattachedClusters, P_MAX_QMAX);
186187
FillStatisticCombined(mProwSectorA, clustersCompressed->rowDiffA, clustersCompressed->sliceLegDiffA, clustersCompressed->nAttachedClustersReduced, GPUTPCGeometry::NROWS);
187188
mNTotalClusters += clustersCompressed->nAttachedClusters + clustersCompressed->nUnattachedClusters;
189+
190+
if (dumpCSV) {
191+
std::ofstream csv("clusters_raw.csv");
192+
csv << "sector,row,time,pad,flags,qtot,qmax,sigmatime,sigmapad\n";
193+
for (uint32_t i = 0; i < NSECTORS; i++) {
194+
for (uint32_t j = 0; j < GPUTPCGeometry::NROWS; j++) {
195+
for (uint32_t k = 0; k < clustersNativeDecoded.nClusters[i][j]; k++) {
196+
const auto& cl = clustersNativeDecoded.clusters[i][j][k];
197+
csv << i << ',' << j << ',' << cl.getTimePacked() << ',' << cl.padPacked << ',' << (uint32_t)cl.getFlags() << ',' << cl.qTot << ',' << cl.qMax << ',' << (uint32_t)cl.sigmaTimePacked << ',' << (uint32_t)cl.sigmaPadPacked << '\n';
198+
}
199+
}
200+
}
201+
202+
csv = std::ofstream("attachedCl.csv");
203+
csv << "qTotA,qMaxA,flagsA,sigmaPadA,sigmaTimeA\n";
204+
for (uint32_t i = 0; i < clustersCompressed->nAttachedClusters; i++) {
205+
csv << clustersCompressed->qTotA[i] << ',' << clustersCompressed->qMaxA[i] << ',' << (uint32_t)clustersCompressed->flagsA[i] << ',' << (uint32_t)clustersCompressed->sigmaPadA[i] << ',' << (uint32_t)clustersCompressed->sigmaTimeA[i] << "\n";
206+
}
207+
208+
csv = std::ofstream("attachedClred.csv");
209+
csv << "rodDiffA,legDiffA,padResA,timeResA\n";
210+
for (uint32_t i = 0; i < clustersCompressed->nAttachedClustersReduced; i++) {
211+
csv << (uint32_t)clustersCompressed->rowDiffA[i] << ',' << (uint32_t)clustersCompressed->sliceLegDiffA[i] << ',' << clustersCompressed->padResA[i] << ',' << clustersCompressed->timeResA[i] << "\n";
212+
}
213+
214+
csv = std::ofstream("nClU.csv");
215+
csv << "sliceRowCl\n";
216+
for (uint32_t i = 0; i < clustersCompressed->nSliceRows; i++) {
217+
csv << clustersCompressed->nSliceRowClusters[i] << "\n";
218+
}
219+
220+
csv = std::ofstream("trk.csv");
221+
csv << "qPtA,rowA,sliceA,timeA,padA,nCl\n";
222+
for (uint32_t i = 0; i < clustersCompressed->nTracks; i++) {
223+
csv << (uint32_t)clustersCompressed->qPtA[i] << ',' << (uint32_t)clustersCompressed->rowA[i] << ',' << (uint32_t)clustersCompressed->sliceA[i] << ',' << clustersCompressed->timeA[i] << ',' << clustersCompressed->padA[i] << ',' << clustersCompressed->nTrackClusters[i] << "\n";
224+
}
225+
226+
csv = std::ofstream("unattachedCl.csv");
227+
csv << "qTotU,qMaxU,flagsU,padDiffU,timeDiffU,sigmaPadU,sigmaTimeU\n";
228+
for (uint32_t i = 0; i < clustersCompressed->nUnattachedClusters; i++) {
229+
csv << clustersCompressed->qTotU[i] << ',' << clustersCompressed->qMaxU[i] << ',' << (uint32_t)clustersCompressed->flagsU[i] << ',' << clustersCompressed->padDiffU[i] << ',' << clustersCompressed->timeDiffU[i] << ',' << (uint32_t)clustersCompressed->sigmaPadU[i] << ',' << (uint32_t)clustersCompressed->sigmaTimeU[i] << "\n";
230+
}
231+
}
188232
}
189233

190234
void GPUTPCClusterStatistics::Finish()

GPU/GPUTracking/DataCompression/GPUTPCClusterStatistics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class GPUTPCClusterStatistics
3030
{
3131
public:
3232
static constexpr uint32_t NSECTORS = GPUTPCGeometry::NSECTORS;
33-
void RunStatistics(const o2::tpc::ClusterNativeAccess* clustersNative, const o2::tpc::CompressedClusters* clustersCompressed, const GPUParam& param);
33+
void RunStatistics(const o2::tpc::ClusterNativeAccess* clustersNative, const o2::tpc::CompressedClusters* clustersCompressed, const GPUParam& param, bool dumpCSV);
3434
void Finish();
3535

3636
protected:

GPU/GPUTracking/Definitions/GPUSettingsList.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ AddOption(serializeGPU, int8_t, 0, "", 0, "Synchronize after each kernel call (b
342342
AddOption(recoTaskTiming, bool, 0, "", 0, "Perform summary timing after whole reconstruction tasks")
343343
AddOption(deterministicGPUReconstruction, int32_t, -1, "", 0, "Make CPU and GPU debug output comparable (sort / skip concurrent parts), -1 = automatic if debugLevel >= 6 or deterministic compile flag set", def(1))
344344
AddOption(showOutputStat, bool, false, "", 0, "Print some track output statistics")
345-
AddOption(runCompressionStatistics, bool, false, "compressionStat", 0, "Run statistics and verification for cluster compression")
345+
AddOption(runCompressionStatistics, int8_t, 0, "compressionStat", 0, "Run statistics and verification for cluster compression, 2 to dump clusters and entropy-reduced clusters to CSV", def(1))
346346
AddOption(resetTimers, int8_t, 1, "", 0, "Reset timers every event")
347347
AddOption(deviceTimers, bool, true, "", 0, "Use device timers instead of host-based time measurement")
348348
AddOption(keepAllMemory, bool, false, "", 0, "Allocate all memory on both device and host, and do not reuse")

GPU/GPUTracking/Global/GPUChainTracking.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ int32_t GPUChainTracking::RunChainFinalize()
789789
{
790790
if (mIOPtrs.clustersNative && (GetRecoSteps() & RecoStep::TPCCompression) && GetProcessingSettings().runCompressionStatistics) {
791791
CompressedClusters c = *mIOPtrs.tpcCompressedClusters;
792-
mCompressionStatistics->RunStatistics(mIOPtrs.clustersNative, &c, param());
792+
mCompressionStatistics->RunStatistics(mIOPtrs.clustersNative, &c, param(), GetProcessingSettings().runCompressionStatistics >= 2);
793793
}
794794

795795
if (GetProcessingSettings().outputSanityCheck) {

0 commit comments

Comments
 (0)