38 RecoStep myStep = RecoStep::TPCCompression;
48 if (gatherMode == 3) {
56 runKernel<GPUTPCCompressionKernels, GPUTPCCompressionKernels::step0attached>(
GetGridAuto(0));
58 WriteReducedClusters();
60 runKernel<GPUTPCCompressionKernels, GPUTPCCompressionKernels::step1unattached>(
GetGridAuto(0));
62#ifdef GPUCA_TPC_GEOMETRY_O2
71 memset((
void*)O, 0,
sizeof(*O));
84 if (gatherMode == 3) {
90 int32_t outputStream = 0;
93 outputStream = OutputStream();
95 if (gatherMode >= 2) {
96 if (gatherMode == 2) {
100 for (uint32_t
i = 0;
i <
sizeof(ptrs) /
sizeof(
void*);
i++) {
101 reinterpret_cast<char**
>(&ptrs)[
i] =
reinterpret_cast<char**
>(&ptrs)[
i] + (
reinterpret_cast<char*
>(devicePtr) -
reinterpret_cast<char*
>(Compressor.
mOutputFlat));
106 constexpr uint32_t nBlocksDefault = 2;
107 constexpr uint32_t nBlocksMulti = 1 + 2 * 200;
109 switch (gatherModeKernel) {
111 runKernel<GPUTPCCompressionGatherKernels, GPUTPCCompressionGatherKernels::unbuffered>(
GetGridBlkStep(nBlocksDefault, outputStream, RecoStep::TPCCompression));
112 getKernelTimer<GPUTPCCompressionGatherKernels, GPUTPCCompressionGatherKernels::unbuffered>(RecoStep::TPCCompression, 0, outputSize,
false);
115 runKernel<GPUTPCCompressionGatherKernels, GPUTPCCompressionGatherKernels::buffered32>(
GetGridBlkStep(nBlocksDefault, outputStream, RecoStep::TPCCompression));
116 getKernelTimer<GPUTPCCompressionGatherKernels, GPUTPCCompressionGatherKernels::buffered32>(RecoStep::TPCCompression, 0, outputSize,
false);
119 runKernel<GPUTPCCompressionGatherKernels, GPUTPCCompressionGatherKernels::buffered64>(
GetGridBlkStep(nBlocksDefault, outputStream, RecoStep::TPCCompression));
120 getKernelTimer<GPUTPCCompressionGatherKernels, GPUTPCCompressionGatherKernels::buffered64>(RecoStep::TPCCompression, 0, outputSize,
false);
123 runKernel<GPUTPCCompressionGatherKernels, GPUTPCCompressionGatherKernels::buffered128>(
GetGridBlkStep(nBlocksDefault, outputStream, RecoStep::TPCCompression));
124 getKernelTimer<GPUTPCCompressionGatherKernels, GPUTPCCompressionGatherKernels::buffered128>(RecoStep::TPCCompression, 0, outputSize,
false);
127 static_assert((nBlocksMulti & 1) && nBlocksMulti >= 3);
128 runKernel<GPUTPCCompressionGatherKernels, GPUTPCCompressionGatherKernels::multiBlock>(
GetGridBlkStep(nBlocksMulti, outputStream, RecoStep::TPCCompression));
129 getKernelTimer<GPUTPCCompressionGatherKernels, GPUTPCCompressionGatherKernels::multiBlock>(RecoStep::TPCCompression, 0, outputSize,
false);
132 GPUError(
"Invalid compression kernel %d selected.", (int32_t)gatherModeKernel);
135 if (gatherMode == 3) {
139 const size_t blockSize = CAMath::nextMultipleOf<1024>(copySize / 30);
140 const uint32_t
n = (copySize + blockSize - 1) / blockSize;
141 for (uint32_t
i = 0;
i <
n;
i++) {
142 GPUMemCpy(myStep, hostFlatPtr +
i * blockSize, deviceFlatPts +
i * blockSize, CAMath::Min(blockSize, copySize -
i * blockSize), outputStream,
false);
145 GPUMemCpy(myStep, hostFlatPtr, deviceFlatPts, copySize, outputStream,
false);
149 int8_t direction = 0;
150 if (gatherMode == 0) {
151 P = &CompressorShadow.
mPtrs;
152 }
else if (gatherMode == 1) {
155 gatherTimer = &getTimer<GPUTPCCompressionKernels>(
"GPUTPCCompression_GatherOnCPU", 0);
156 gatherTimer->
Start();
196 if (gatherMode == 1) {
200 if (gatherMode == 3) {
205 if (mPipelineFinalizationCtx ==
nullptr) {
224 GPUFatal(
"tpcApplyCFCutsAtDecoding, tpcApplyClusterFilterOnCPU and tpcCutTimeBin currently require tpcUseOldCPUDecoding");
228 const bool runFiltering = needFullFiltering || runTimeBinCutFiltering;
231 auto allocatorFinal = [
this](
size_t size) {
236 std::unique_ptr<ClusterNative[]> tmpBuffer;
237 auto allocatorTmp = [&tmpBuffer](
size_t size) {
240 auto& decompressTimer = getTimer<TPCClusterDecompressor>(
"TPCDecompression", 0);
241 auto allocatorUse = runFiltering ? std::function<
ClusterNative*(size_t)>{allocatorTmp} : std::function<
ClusterNative*(size_t)>{allocatorFinal};
242 decompressTimer.Start();
244 GPUError(
"Error decompressing clusters");
250 decompressTimer.Stop();
258 mInputsHost->mPclusterNativeAccess->setOffsetPtrs();
265 RecoStep myStep = RecoStep::TPCDecompression;
275 throw std::runtime_error(
"Configured solenoid Bz does not match value used for track model encoding");
278 throw std::runtime_error(
"Configured max time bin does not match value used for track model encoding");
281 int32_t inputStream = 0;
283 inputGPU = cmprClsHost;
286 inputGPU = cmprClsHost;
293 for (int32_t iStream = 0; iStream < nStreams; iStream++) {
294 uint32_t startTrack = cmprClsHost.
nTracks / nStreams * iStream;
295 uint32_t endTrack = cmprClsHost.
nTracks / nStreams * (iStream + 1) + (iStream < nStreams - 1 ? 0 : cmprClsHost.
nTracks % nStreams);
296 uint32_t numTracks = endTrack - startTrack;
299 uint32_t numClustersRed = numClusters - numTracks;
311 GPUMemCpy(myStep, inputGPUShadow.
qPtA + startTrack, cmprClsHost.
qPtA + startTrack, numTracks *
sizeof(cmprClsHost.
qPtA[0]), iStream, toGPU);
312 GPUMemCpy(myStep, inputGPUShadow.
rowA + startTrack, cmprClsHost.
rowA + startTrack, numTracks *
sizeof(cmprClsHost.
rowA[0]), iStream, toGPU);
313 GPUMemCpy(myStep, inputGPUShadow.
sliceA + startTrack, cmprClsHost.
sliceA + startTrack, numTracks *
sizeof(cmprClsHost.
sliceA[0]), iStream, toGPU);
314 GPUMemCpy(myStep, inputGPUShadow.
timeA + startTrack, cmprClsHost.
timeA + startTrack, numTracks *
sizeof(cmprClsHost.
timeA[0]), iStream, toGPU);
315 GPUMemCpy(myStep, inputGPUShadow.
padA + startTrack, cmprClsHost.
padA + startTrack, numTracks *
sizeof(cmprClsHost.
padA[0]), iStream, toGPU);
331 uint32_t decodedAttachedClusters = 0;
338 offset += unattachedOffset;
346 if (runTimeBinCutFiltering) {
378 uint32_t batchSize = doGPU ? 6 :
NSECTORS;
379 for (uint32_t iSector = 0; iSector <
NSECTORS; iSector = iSector + batchSize) {
380 int32_t iStream = (iSector / batchSize) %
mRec->
NStreams();
383 if (!runTimeBinCutFiltering) {
389 if (runTimeBinCutFiltering) {
393 runKernel<GPUTPCDecompressionUtilKernels, GPUTPCDecompressionUtilKernels::countFilteredClusters>(
GetGridAutoStep(unattachedStream, RecoStep::TPCDecompression));
419 runKernel<GPUTPCDecompressionUtilKernels, GPUTPCDecompressionUtilKernels::storeFilteredClusters>(
GetGridAutoStep(unattachedStream, RecoStep::TPCDecompression));
424 runKernel<GPUTPCDecompressionUtilKernels, GPUTPCDecompressionUtilKernels::sortPerSectorRow>(
GetGridAutoStep(unattachedStream, RecoStep::TPCDecompression));