Project
Loading...
Searching...
No Matches
GPUChainTrackingClusterizer.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#include "GPUChainTracking.h"
18#include "GPULogging.h"
19#include "GPUO2DataTypes.h"
22#include "GPUNewCalibValues.h"
23#include "GPUConstantMem.h"
24#include "CfChargePos.h"
25#include "CfArray2D.h"
26#include "GPUGeneralKernels.h"
27#include "GPUDefParametersRuntime.h"
30#include "GPUTPCCFDecodeZS.h"
32#include "GPUTPCCFPeakFinder.h"
35#include "GPUTPCCFClusterizer.h"
36#include "GPUTPCCFGather.h"
38#include "GPUTriggerOutputs.h"
39#include "GPUHostDataTypes.h"
45#include "TPCBase/RDHUtils.h"
46#include "GPULogging.h"
47
48#ifdef GPUCA_HAS_ONNX
51#endif
52
53#ifdef GPUCA_O2_LIB
55#endif
56
57#include "utils/strtag.h"
58#include <fstream>
59
60#ifndef GPUCA_NO_VC
61#include <Vc/Vc>
62#endif
63
64using namespace o2::gpu;
65using namespace o2::tpc;
66using namespace o2::tpc::constants;
67using namespace o2::dataformats;
68
69#ifdef GPUCA_TPC_GEOMETRY_O2
70std::pair<uint32_t, uint32_t> GPUChainTracking::TPCClusterizerDecodeZSCountUpdate(uint32_t iSector, const CfFragment& fragment)
71{
73 GPUTPCClusterFinder& clusterer = processors()->tpcClusterer[iSector];
75 uint32_t digits = 0;
76 uint32_t pages = 0;
77 for (uint16_t j = 0; j < GPUTrackingInOutZS::NENDPOINTS; j++) {
78 clusterer.mMinMaxCN[j] = mCFContext->fragmentData[fragment.index].minMaxCN[iSector][j];
79 if (doGPU) {
80 uint16_t posInEndpoint = 0;
81 uint16_t pagesEndpoint = 0;
82 for (uint32_t k = clusterer.mMinMaxCN[j].zsPtrFirst; k < clusterer.mMinMaxCN[j].zsPtrLast; k++) {
83 const uint32_t pageFirst = (k == clusterer.mMinMaxCN[j].zsPtrFirst) ? clusterer.mMinMaxCN[j].zsPageFirst : 0;
84 const uint32_t pageLast = (k + 1 == clusterer.mMinMaxCN[j].zsPtrLast) ? clusterer.mMinMaxCN[j].zsPageLast : mIOPtrs.tpcZS->sector[iSector].nZSPtr[j][k];
85 for (uint32_t l = pageFirst; l < pageLast; l++) {
86 uint16_t pageDigits = mCFContext->fragmentData[fragment.index].pageDigits[iSector][j][posInEndpoint++];
87 if (pageDigits) {
88 *(o++) = GPUTPCClusterFinder::ZSOffset{digits, j, pagesEndpoint};
89 digits += pageDigits;
90 }
91 pagesEndpoint++;
92 }
93 }
94 if (pagesEndpoint != mCFContext->fragmentData[fragment.index].pageDigits[iSector][j].size()) {
95 if (GetProcessingSettings().ignoreNonFatalGPUErrors) {
96 GPUError("TPC raw page count mismatch in TPCClusterizerDecodeZSCountUpdate: expected %d / buffered %lu", pagesEndpoint, mCFContext->fragmentData[fragment.index].pageDigits[iSector][j].size());
97 return {0, 0};
98 } else {
99 GPUFatal("TPC raw page count mismatch in TPCClusterizerDecodeZSCountUpdate: expected %d / buffered %lu", pagesEndpoint, mCFContext->fragmentData[fragment.index].pageDigits[iSector][j].size());
100 }
101 }
102 } else {
104 digits += mCFContext->fragmentData[fragment.index].nDigits[iSector][j];
105 pages += mCFContext->fragmentData[fragment.index].nPages[iSector][j];
106 }
107 }
108 if (doGPU) {
109 pages = o - processors()->tpcClusterer[iSector].mPzsOffsets;
110 }
111 if (!doGPU && GetProcessingSettings().debugLevel >= 4 && mCFContext->zsVersion >= ZSVersion::ZSVersionDenseLinkBased) {
112 TPCClusterizerEnsureZSOffsets(iSector, fragment);
113 }
114 return {digits, pages};
115}
116
117void GPUChainTracking::TPCClusterizerEnsureZSOffsets(uint32_t iSector, const CfFragment& fragment)
118{
119 GPUTPCClusterFinder& clusterer = processors()->tpcClusterer[iSector];
120 uint32_t nAdcs = 0;
122 const auto& data = mCFContext->fragmentData[fragment.index];
123 uint32_t pagesEndpoint = 0;
124 const uint32_t nAdcsExpected = data.nDigits[iSector][endpoint];
125 const uint32_t nPagesExpected = data.nPages[iSector][endpoint];
126
127 uint32_t nAdcDecoded = 0;
128 const auto& zs = mIOPtrs.tpcZS->sector[iSector];
129 for (uint32_t i = data.minMaxCN[iSector][endpoint].zsPtrFirst; i < data.minMaxCN[iSector][endpoint].zsPtrLast; i++) {
130 const uint32_t pageFirst = (i == data.minMaxCN[iSector][endpoint].zsPtrFirst) ? data.minMaxCN[iSector][endpoint].zsPageFirst : 0;
131 const uint32_t pageLast = (i + 1 == data.minMaxCN[iSector][endpoint].zsPtrLast) ? data.minMaxCN[iSector][endpoint].zsPageLast : zs.nZSPtr[endpoint][i];
132 for (uint32_t j = pageFirst; j < pageLast; j++) {
133 const uint8_t* page = static_cast<const uint8_t*>(zs.zsPtr[endpoint][i]) + j * TPCZSHDR::TPC_ZS_PAGE_SIZE;
134 const header::RAWDataHeader* rawDataHeader = reinterpret_cast<const header::RAWDataHeader*>(page);
135 const TPCZSHDRV2* decHdr = reinterpret_cast<const TPCZSHDRV2*>(page + raw::RDHUtils::getMemorySize(*rawDataHeader) - sizeof(TPCZSHDRV2));
136 const uint16_t nSamplesInPage = decHdr->nADCsamples;
137
138 nAdcDecoded += nSamplesInPage;
139 pagesEndpoint++;
140 }
141 }
142
143 if (pagesEndpoint != nPagesExpected) {
144 GPUFatal("Sector %d, Endpoint %d, Fragment %d: TPC raw page count mismatch: expected %d / buffered %u", iSector, endpoint, fragment.index, pagesEndpoint, nPagesExpected);
145 }
146
147 if (nAdcDecoded != nAdcsExpected) {
148 GPUFatal("Sector %d, Endpoint %d, Fragment %d: TPC ADC count mismatch: expected %u, buffered %u", iSector, endpoint, fragment.index, nAdcsExpected, nAdcDecoded);
149 }
150
151 if (nAdcs != clusterer.mPzsOffsets[endpoint].offset) {
152 GPUFatal("Sector %d, Endpoint %d, Fragment %d: TPC ADC offset mismatch: expected %u, buffered %u", iSector, endpoint, fragment.index, nAdcs, clusterer.mPzsOffsets[endpoint].offset);
153 }
154
155 nAdcs += nAdcsExpected;
156 }
157}
158
159namespace
160{
161struct TPCCFDecodeScanTmp {
162 int32_t zsPtrFirst, zsPageFirst, zsPtrLast, zsPageLast, hasData, pageCounter;
163};
164} // namespace
165
166std::pair<uint32_t, uint32_t> GPUChainTracking::TPCClusterizerDecodeZSCount(uint32_t iSector, const CfFragment& fragment)
167{
168 mRec->getGeneralStepTimer(GeneralStep::Prepare).Start();
169 uint32_t nDigits = 0;
170 uint32_t nPages = 0;
171 uint32_t endpointAdcSamples[GPUTrackingInOutZS::NENDPOINTS];
172 memset(endpointAdcSamples, 0, sizeof(endpointAdcSamples));
174 int32_t firstHBF = (mIOPtrs.settingsTF && mIOPtrs.settingsTF->hasTfStartOrbit) ? mIOPtrs.settingsTF->tfStartOrbit : ((mIOPtrs.tpcZS->sector[iSector].count[0] && mIOPtrs.tpcZS->sector[iSector].nZSPtr[0][0]) ? o2::raw::RDHUtils::getHeartBeatOrbit(*(const o2::header::RAWDataHeader*)mIOPtrs.tpcZS->sector[iSector].zsPtr[0][0]) : 0);
175
176 for (uint16_t j = 0; j < GPUTrackingInOutZS::NENDPOINTS; j++) {
177#ifndef GPUCA_NO_VC
178 if (GetProcessingSettings().prefetchTPCpageScan >= 3 && j < GPUTrackingInOutZS::NENDPOINTS - 1) {
179 for (uint32_t k = 0; k < mIOPtrs.tpcZS->sector[iSector].count[j + 1]; k++) {
180 for (uint32_t l = 0; l < mIOPtrs.tpcZS->sector[iSector].nZSPtr[j + 1][k]; l++) {
181 Vc::Common::prefetchMid(((const uint8_t*)mIOPtrs.tpcZS->sector[iSector].zsPtr[j + 1][k]) + l * TPCZSHDR::TPC_ZS_PAGE_SIZE);
182 Vc::Common::prefetchMid(((const uint8_t*)mIOPtrs.tpcZS->sector[iSector].zsPtr[j + 1][k]) + l * TPCZSHDR::TPC_ZS_PAGE_SIZE + sizeof(o2::header::RAWDataHeader));
183 }
184 }
185 }
186#endif
187
188 std::vector<std::pair<CfFragment, TPCCFDecodeScanTmp>> fragments;
189 fragments.reserve(mCFContext->nFragments);
190 fragments.emplace_back(std::pair<CfFragment, TPCCFDecodeScanTmp>{fragment, {0, 0, 0, 0, 0, -1}});
191 for (uint32_t i = 1; i < mCFContext->nFragments; i++) {
192 fragments.emplace_back(std::pair<CfFragment, TPCCFDecodeScanTmp>{fragments.back().first.next(), {0, 0, 0, 0, 0, -1}});
193 }
194 std::vector<bool> fragmentExtends(mCFContext->nFragments, false);
195
196 uint32_t firstPossibleFragment = 0;
197 uint32_t pageCounter = 0;
198 uint32_t emptyPages = 0;
199 for (uint32_t k = 0; k < mIOPtrs.tpcZS->sector[iSector].count[j]; k++) {
200 if (GetProcessingSettings().tpcSingleSector != -1 && GetProcessingSettings().tpcSingleSector != (int32_t)iSector) {
201 break;
202 }
203 nPages += mIOPtrs.tpcZS->sector[iSector].nZSPtr[j][k];
204 for (uint32_t l = 0; l < mIOPtrs.tpcZS->sector[iSector].nZSPtr[j][k]; l++) {
205#ifndef GPUCA_NO_VC
206 if (GetProcessingSettings().prefetchTPCpageScan >= 2 && l + 1 < mIOPtrs.tpcZS->sector[iSector].nZSPtr[j][k]) {
207 Vc::Common::prefetchForOneRead(((const uint8_t*)mIOPtrs.tpcZS->sector[iSector].zsPtr[j][k]) + (l + 1) * TPCZSHDR::TPC_ZS_PAGE_SIZE);
208 Vc::Common::prefetchForOneRead(((const uint8_t*)mIOPtrs.tpcZS->sector[iSector].zsPtr[j][k]) + (l + 1) * TPCZSHDR::TPC_ZS_PAGE_SIZE + sizeof(o2::header::RAWDataHeader));
209 }
210#endif
211 const uint8_t* const page = ((const uint8_t*)mIOPtrs.tpcZS->sector[iSector].zsPtr[j][k]) + l * TPCZSHDR::TPC_ZS_PAGE_SIZE;
213 if (o2::raw::RDHUtils::getMemorySize(*rdh) == sizeof(o2::header::RAWDataHeader)) {
214 emptyPages++;
215 continue;
216 }
217 pageCounter++;
218 const TPCZSHDR* const hdr = (const TPCZSHDR*)(rdh_utils::getLink(o2::raw::RDHUtils::getFEEID(*rdh)) == rdh_utils::DLBZSLinkID ? (page + o2::raw::RDHUtils::getMemorySize(*rdh) - sizeof(TPCZSHDRV2)) : (page + sizeof(o2::header::RAWDataHeader)));
219 if (mCFContext->zsVersion == -1) {
220 mCFContext->zsVersion = hdr->version;
221 if (GetProcessingSettings().param.tpcTriggerHandling && mCFContext->zsVersion < ZSVersion::ZSVersionDenseLinkBased) { // TODO: Move tpcTriggerHandling to recoSteps bitmask
222 static bool errorShown = false;
223 if (errorShown == false) {
224 GPUAlarm("Trigger handling only possible with TPC Dense Link Based data, received version %d, disabling", mCFContext->zsVersion);
225 }
226 errorShown = true;
227 }
228 } else if (mCFContext->zsVersion != (int32_t)hdr->version) {
229 GPUError("Received TPC ZS 8kb page of mixed versions, expected %d, received %d (linkid %d, feeCRU %d, feeEndpoint %d, feelinkid %d)", mCFContext->zsVersion, (int32_t)hdr->version, (int32_t)o2::raw::RDHUtils::getLinkID(*rdh), (int32_t)rdh_utils::getCRU(*rdh), (int32_t)rdh_utils::getEndPoint(*rdh), (int32_t)rdh_utils::getLink(*rdh));
230 constexpr size_t bufferSize = 3 * std::max(sizeof(*rdh), sizeof(*hdr)) + 1;
231 char dumpBuffer[bufferSize];
232 for (size_t i = 0; i < sizeof(*rdh); i++) {
233 // "%02X " guaranteed to be 3 chars + ending 0.
234 snprintf(dumpBuffer + 3 * i, 4, "%02X ", (int32_t)((uint8_t*)rdh)[i]);
235 }
236 GPUAlarm("RDH of page: %s", dumpBuffer);
237 for (size_t i = 0; i < sizeof(*hdr); i++) {
238 // "%02X " guaranteed to be 3 chars + ending 0.
239 snprintf(dumpBuffer + 3 * i, 4, "%02X ", (int32_t)((uint8_t*)hdr)[i]);
240 }
241 GPUAlarm("Metainfo of page: %s", dumpBuffer);
242 if (GetProcessingSettings().ignoreNonFatalGPUErrors) {
243 mCFContext->abandonTimeframe = true;
244 return {0, 0};
245 } else {
246 GPUFatal("Cannot process with invalid TPC ZS data, exiting");
247 }
248 }
249 if (GetProcessingSettings().param.tpcTriggerHandling) {
250 const TPCZSHDRV2* const hdr2 = (const TPCZSHDRV2*)hdr;
251 if (hdr2->flags & TPCZSHDRV2::ZSFlags::TriggerWordPresent) {
252 const char* triggerWord = (const char*)hdr - TPCZSHDRV2::TRIGGER_WORD_SIZE;
254 memcpy((void*)&tmp.triggerWord, triggerWord, TPCZSHDRV2::TRIGGER_WORD_SIZE);
255 tmp.orbit = o2::raw::RDHUtils::getHeartBeatOrbit(*rdh);
256 if (tmp.triggerWord.isValid(0)) {
257 mTriggerBuffer->triggers.emplace(tmp);
258 }
259 }
260 }
261 nDigits += hdr->nADCsamples;
262 endpointAdcSamples[j] += hdr->nADCsamples;
263 uint32_t timeBin = (hdr->timeOffset + (o2::raw::RDHUtils::getHeartBeatOrbit(*rdh) - firstHBF) * o2::constants::lhc::LHCMaxBunches) / LHCBCPERTIMEBIN;
264 uint32_t maxTimeBin = timeBin + hdr->nTimeBinSpan;
265 if (mCFContext->zsVersion >= ZSVersion::ZSVersionDenseLinkBased) {
266 const TPCZSHDRV2* const hdr2 = (const TPCZSHDRV2*)hdr;
267 if (hdr2->flags & TPCZSHDRV2::ZSFlags::nTimeBinSpanBit8) {
268 maxTimeBin += 256;
269 }
270 }
271 if (maxTimeBin > mCFContext->tpcMaxTimeBin) {
272 mCFContext->tpcMaxTimeBin = maxTimeBin;
273 }
274 bool extendsInNextPage = false;
275 if (mCFContext->zsVersion >= ZSVersion::ZSVersionDenseLinkBased) {
276 if (l + 1 < mIOPtrs.tpcZS->sector[iSector].nZSPtr[j][k] && o2::raw::RDHUtils::getMemorySize(*rdh) == TPCZSHDR::TPC_ZS_PAGE_SIZE) {
278 extendsInNextPage = o2::raw::RDHUtils::getHeartBeatOrbit(*nextrdh) == o2::raw::RDHUtils::getHeartBeatOrbit(*rdh) && o2::raw::RDHUtils::getMemorySize(*nextrdh) > sizeof(o2::header::RAWDataHeader);
279 }
280 }
281 while (firstPossibleFragment && (uint32_t)fragments[firstPossibleFragment - 1].first.last() > timeBin) {
282 firstPossibleFragment--;
283 }
284 auto handleExtends = [&](uint32_t ff) {
285 if (fragmentExtends[ff]) {
286 if (doGPU) {
287 // Only add extended page on GPU. On CPU the pages are in consecutive memory anyway.
288 // Not adding the page prevents an issue where a page is decoded twice on CPU, when only the extend should be decoded.
289 fragments[ff].second.zsPageLast++;
290 mCFContext->fragmentData[ff].nPages[iSector][j]++;
291 mCFContext->fragmentData[ff].pageDigits[iSector][j].emplace_back(0);
292 }
293 fragmentExtends[ff] = false;
294 }
295 };
296 if (mCFContext->zsVersion >= ZSVersion::ZSVersionDenseLinkBased) {
297 for (uint32_t ff = 0; ff < firstPossibleFragment; ff++) {
298 handleExtends(ff);
299 }
300 }
301 for (uint32_t f = firstPossibleFragment; f < mCFContext->nFragments; f++) {
302 if (timeBin < (uint32_t)fragments[f].first.last() && (uint32_t)fragments[f].first.first() <= maxTimeBin) {
303 if (!fragments[f].second.hasData) {
304 fragments[f].second.hasData = 1;
305 fragments[f].second.zsPtrFirst = k;
306 fragments[f].second.zsPageFirst = l;
307 } else {
308 if (pageCounter > (uint32_t)fragments[f].second.pageCounter + 1) {
309 mCFContext->fragmentData[f].nPages[iSector][j] += emptyPages + pageCounter - fragments[f].second.pageCounter - 1;
310 for (uint32_t k2 = fragments[f].second.zsPtrLast - 1; k2 <= k; k2++) {
311 for (uint32_t l2 = ((int32_t)k2 == fragments[f].second.zsPtrLast - 1) ? fragments[f].second.zsPageLast : 0; l2 < (k2 < k ? mIOPtrs.tpcZS->sector[iSector].nZSPtr[j][k2] : l); l2++) {
312 if (doGPU) {
313 mCFContext->fragmentData[f].pageDigits[iSector][j].emplace_back(0);
314 } else {
315 // CPU cannot skip unneeded pages, so we must keep space to store the invalid dummy clusters
316 const uint8_t* const pageTmp = ((const uint8_t*)mIOPtrs.tpcZS->sector[iSector].zsPtr[j][k2]) + l2 * TPCZSHDR::TPC_ZS_PAGE_SIZE;
317 const o2::header::RAWDataHeader* rdhTmp = (const o2::header::RAWDataHeader*)pageTmp;
318 if (o2::raw::RDHUtils::getMemorySize(*rdhTmp) != sizeof(o2::header::RAWDataHeader)) {
319 const TPCZSHDR* const hdrTmp = (const TPCZSHDR*)(rdh_utils::getLink(o2::raw::RDHUtils::getFEEID(*rdhTmp)) == rdh_utils::DLBZSLinkID ? (pageTmp + o2::raw::RDHUtils::getMemorySize(*rdhTmp) - sizeof(TPCZSHDRV2)) : (pageTmp + sizeof(o2::header::RAWDataHeader)));
320 mCFContext->fragmentData[f].nDigits[iSector][j] += hdrTmp->nADCsamples;
321 }
322 }
323 }
324 }
325 } else if (emptyPages) {
326 mCFContext->fragmentData[f].nPages[iSector][j] += emptyPages;
327 if (doGPU) {
328 for (uint32_t m = 0; m < emptyPages; m++) {
329 mCFContext->fragmentData[f].pageDigits[iSector][j].emplace_back(0);
330 }
331 }
332 }
333 }
334 fragments[f].second.zsPtrLast = k + 1;
335 fragments[f].second.zsPageLast = l + 1;
336 fragments[f].second.pageCounter = pageCounter;
337 mCFContext->fragmentData[f].nPages[iSector][j]++;
338 mCFContext->fragmentData[f].nDigits[iSector][j] += hdr->nADCsamples;
339 if (doGPU) {
340 mCFContext->fragmentData[f].pageDigits[iSector][j].emplace_back(hdr->nADCsamples);
341 }
342 fragmentExtends[f] = extendsInNextPage;
343 } else {
344 handleExtends(f);
345 if (timeBin < (uint32_t)fragments[f].first.last()) {
346 if (mCFContext->zsVersion >= ZSVersion::ZSVersionDenseLinkBased) {
347 for (uint32_t ff = f + 1; ff < mCFContext->nFragments; ff++) {
348 handleExtends(ff);
349 }
350 }
351 break;
352 } else {
353 firstPossibleFragment = f + 1;
354 }
355 }
356 }
357 emptyPages = 0;
358 }
359 }
360 for (uint32_t f = 0; f < mCFContext->nFragments; f++) {
361 mCFContext->fragmentData[f].minMaxCN[iSector][j].zsPtrLast = fragments[f].second.zsPtrLast;
362 mCFContext->fragmentData[f].minMaxCN[iSector][j].zsPtrFirst = fragments[f].second.zsPtrFirst;
363 mCFContext->fragmentData[f].minMaxCN[iSector][j].zsPageLast = fragments[f].second.zsPageLast;
364 mCFContext->fragmentData[f].minMaxCN[iSector][j].zsPageFirst = fragments[f].second.zsPageFirst;
365 }
366 }
367 mCFContext->nPagesTotal += nPages;
368 mCFContext->nPagesSector[iSector] = nPages;
369
370 mCFContext->nDigitsEndpointMax[iSector] = 0;
371 for (uint32_t i = 0; i < GPUTrackingInOutZS::NENDPOINTS; i++) {
372 if (endpointAdcSamples[i] > mCFContext->nDigitsEndpointMax[iSector]) {
373 mCFContext->nDigitsEndpointMax[iSector] = endpointAdcSamples[i];
374 }
375 }
376 uint32_t nDigitsFragmentMax = 0;
377 for (uint32_t i = 0; i < mCFContext->nFragments; i++) {
378 uint32_t pagesInFragment = 0;
379 uint32_t digitsInFragment = 0;
380 for (uint16_t j = 0; j < GPUTrackingInOutZS::NENDPOINTS; j++) {
381 pagesInFragment += mCFContext->fragmentData[i].nPages[iSector][j];
382 digitsInFragment += mCFContext->fragmentData[i].nDigits[iSector][j];
383 }
384 mCFContext->nPagesFragmentMax = std::max(mCFContext->nPagesFragmentMax, pagesInFragment);
385 nDigitsFragmentMax = std::max(nDigitsFragmentMax, digitsInFragment);
386 }
387 mRec->getGeneralStepTimer(GeneralStep::Prepare).Stop();
388 return {nDigits, nDigitsFragmentMax};
389}
390
391void GPUChainTracking::RunTPCClusterizer_compactPeaks(GPUTPCClusterFinder& clusterer, GPUTPCClusterFinder& clustererShadow, int32_t stage, bool doGPU, int32_t lane)
392{
393 auto& in = stage ? clustererShadow.mPpeakPositions : clustererShadow.mPpositions;
394 auto& out = stage ? clustererShadow.mPfilteredPeakPositions : clustererShadow.mPpeakPositions;
395 if (doGPU) {
396 const uint32_t iSector = clusterer.mISector;
397 auto& count = stage ? clusterer.mPmemory->counters.nPeaks : clusterer.mPmemory->counters.nPositions;
398
399 std::vector<size_t> counts;
400
401 uint32_t nSteps = clusterer.getNSteps(count);
402 if (nSteps > clusterer.mNBufs) {
403 GPUError("Clusterer buffers exceeded (%u > %u)", nSteps, (int32_t)clusterer.mNBufs);
404 exit(1);
405 }
406
407 int32_t scanWorkgroupSize = mRec->getGPUParameters(doGPU).par_CF_SCAN_WORKGROUP_SIZE;
408 size_t tmpCount = count;
409 if (nSteps > 1) {
410 for (uint32_t i = 1; i < nSteps; i++) {
411 counts.push_back(tmpCount);
412 if (i == 1) {
413 runKernel<GPUTPCCFStreamCompaction, GPUTPCCFStreamCompaction::scanStart>({GetGrid(tmpCount, scanWorkgroupSize, lane), {iSector}}, i, stage);
414 } else {
415 runKernel<GPUTPCCFStreamCompaction, GPUTPCCFStreamCompaction::scanUp>({GetGrid(tmpCount, scanWorkgroupSize, lane), {iSector}}, i, tmpCount);
416 }
417 tmpCount = (tmpCount + scanWorkgroupSize - 1) / scanWorkgroupSize;
418 }
419
420 runKernel<GPUTPCCFStreamCompaction, GPUTPCCFStreamCompaction::scanTop>({GetGrid(tmpCount, scanWorkgroupSize, lane), {iSector}}, nSteps, tmpCount);
421
422 for (uint32_t i = nSteps - 1; i > 1; i--) {
423 tmpCount = counts[i - 1];
424 runKernel<GPUTPCCFStreamCompaction, GPUTPCCFStreamCompaction::scanDown>({GetGrid(tmpCount - scanWorkgroupSize, scanWorkgroupSize, lane), {iSector}}, i, scanWorkgroupSize, tmpCount);
425 }
426 }
427
428 runKernel<GPUTPCCFStreamCompaction, GPUTPCCFStreamCompaction::compactDigits>({GetGrid(count, scanWorkgroupSize, lane), {iSector}}, 1, stage, in, out);
429 } else {
430 auto& nOut = stage ? clusterer.mPmemory->counters.nClusters : clusterer.mPmemory->counters.nPeaks;
431 auto& nIn = stage ? clusterer.mPmemory->counters.nPeaks : clusterer.mPmemory->counters.nPositions;
432 size_t count = 0;
433 for (size_t i = 0; i < nIn; i++) {
434 if (clusterer.mPisPeak[i]) {
435 out[count++] = in[i];
436 }
437 }
438 nOut = count;
439 }
440}
441
442std::pair<uint32_t, uint32_t> GPUChainTracking::RunTPCClusterizer_transferZS(int32_t iSector, const CfFragment& fragment, int32_t lane)
443{
444 bool doGPU = GetRecoStepsGPU() & RecoStep::TPCClusterFinding;
445 if (mCFContext->abandonTimeframe) {
446 return {0, 0};
447 }
448 const auto& retVal = TPCClusterizerDecodeZSCountUpdate(iSector, fragment);
449 if (doGPU) {
450 GPUTPCClusterFinder& clusterer = processors()->tpcClusterer[iSector];
451 GPUTPCClusterFinder& clustererShadow = doGPU ? processorsShadow()->tpcClusterer[iSector] : clusterer;
452 uint32_t nPagesSector = 0;
453 for (uint32_t j = 0; j < GPUTrackingInOutZS::NENDPOINTS; j++) {
454 uint32_t nPages = 0;
455 mInputsHost->mPzsMeta->sector[iSector].zsPtr[j] = &mInputsShadow->mPzsPtrs[iSector * GPUTrackingInOutZS::NENDPOINTS + j];
456 mInputsHost->mPzsPtrs[iSector * GPUTrackingInOutZS::NENDPOINTS + j] = clustererShadow.mPzs + (nPagesSector + nPages) * TPCZSHDR::TPC_ZS_PAGE_SIZE;
457 for (uint32_t k = clusterer.mMinMaxCN[j].zsPtrFirst; k < clusterer.mMinMaxCN[j].zsPtrLast; k++) {
458 const uint32_t min = (k == clusterer.mMinMaxCN[j].zsPtrFirst) ? clusterer.mMinMaxCN[j].zsPageFirst : 0;
459 const uint32_t max = (k + 1 == clusterer.mMinMaxCN[j].zsPtrLast) ? clusterer.mMinMaxCN[j].zsPageLast : mIOPtrs.tpcZS->sector[iSector].nZSPtr[j][k];
460 if (max > min) {
461 char* src = (char*)mIOPtrs.tpcZS->sector[iSector].zsPtr[j][k] + min * TPCZSHDR::TPC_ZS_PAGE_SIZE;
462 char* ptrLast = (char*)mIOPtrs.tpcZS->sector[iSector].zsPtr[j][k] + (max - 1) * TPCZSHDR::TPC_ZS_PAGE_SIZE;
463 size_t size = (ptrLast - src) + o2::raw::RDHUtils::getMemorySize(*(const o2::header::RAWDataHeader*)ptrLast);
464 GPUMemCpy(RecoStep::TPCClusterFinding, clustererShadow.mPzs + (nPagesSector + nPages) * TPCZSHDR::TPC_ZS_PAGE_SIZE, src, size, lane, true);
465 }
466 nPages += max - min;
467 }
468 mInputsHost->mPzsMeta->sector[iSector].nZSPtr[j] = &mInputsShadow->mPzsSizes[iSector * GPUTrackingInOutZS::NENDPOINTS + j];
469 mInputsHost->mPzsSizes[iSector * GPUTrackingInOutZS::NENDPOINTS + j] = nPages;
470 mInputsHost->mPzsMeta->sector[iSector].count[j] = 1;
471 nPagesSector += nPages;
472 }
473 GPUMemCpy(RecoStep::TPCClusterFinding, clustererShadow.mPzsOffsets, clusterer.mPzsOffsets, clusterer.mNMaxPages * sizeof(*clusterer.mPzsOffsets), lane, true);
474 }
475 return retVal;
476}
477
478int32_t GPUChainTracking::RunTPCClusterizer_prepare(bool restorePointers)
479{
481 if (restorePointers) {
482 for (uint32_t iSector = 0; iSector < NSECTORS; iSector++) {
483 processors()->tpcClusterer[iSector].mPzsOffsets = mCFContext->ptrSave[iSector].zsOffsetHost;
484 processorsShadow()->tpcClusterer[iSector].mPzsOffsets = mCFContext->ptrSave[iSector].zsOffsetDevice;
485 processorsShadow()->tpcClusterer[iSector].mPzs = mCFContext->ptrSave[iSector].zsDevice;
486 }
487 processorsShadow()->ioPtrs.clustersNative = mCFContext->ptrClusterNativeSave;
488 return 0;
489 }
490 const auto& threadContext = GetThreadContext();
492 if (mCFContext == nullptr) {
494 }
495 const int16_t maxFragmentLen = GetProcessingSettings().overrideClusterizerFragmentLen;
496 const uint32_t maxAllowedTimebin = param().par.continuousTracking ? std::max<int32_t>(param().continuousMaxTimeBin, maxFragmentLen) : TPC_MAX_TIME_BIN_TRIGGERED;
497 mCFContext->tpcMaxTimeBin = maxAllowedTimebin;
498 const CfFragment fragmentMax{(tpccf::TPCTime)mCFContext->tpcMaxTimeBin + 1, maxFragmentLen};
499 mCFContext->prepare(mIOPtrs.tpcZS, fragmentMax);
500 if (GetProcessingSettings().param.tpcTriggerHandling) {
501 mTriggerBuffer->triggers.clear();
502 }
503 if (mIOPtrs.tpcZS) {
504 uint32_t nDigitsFragmentMax[NSECTORS];
505 mCFContext->zsVersion = -1;
506 for (uint32_t iSector = 0; iSector < NSECTORS; iSector++) {
507 if (mIOPtrs.tpcZS->sector[iSector].count[0]) {
508 const void* rdh = mIOPtrs.tpcZS->sector[iSector].zsPtr[0][0];
509 if (rdh && o2::raw::RDHUtils::getVersion<o2::header::RAWDataHeaderV6>() > o2::raw::RDHUtils::getVersion(rdh)) {
510 GPUError("Data has invalid RDH version %d, %d required\n", o2::raw::RDHUtils::getVersion(rdh), o2::raw::RDHUtils::getVersion<o2::header::RAWDataHeader>());
511 return 1;
512 }
513 }
514#ifndef GPUCA_NO_VC
515 if (GetProcessingSettings().prefetchTPCpageScan >= 1 && iSector < NSECTORS - 1) {
516 for (uint32_t j = 0; j < GPUTrackingInOutZS::NENDPOINTS; j++) {
517 for (uint32_t k = 0; k < mIOPtrs.tpcZS->sector[iSector].count[j]; k++) {
518 for (uint32_t l = 0; l < mIOPtrs.tpcZS->sector[iSector].nZSPtr[j][k]; l++) {
519 Vc::Common::prefetchFar(((const uint8_t*)mIOPtrs.tpcZS->sector[iSector + 1].zsPtr[j][k]) + l * TPCZSHDR::TPC_ZS_PAGE_SIZE);
520 Vc::Common::prefetchFar(((const uint8_t*)mIOPtrs.tpcZS->sector[iSector + 1].zsPtr[j][k]) + l * TPCZSHDR::TPC_ZS_PAGE_SIZE + sizeof(o2::header::RAWDataHeader));
521 }
522 }
523 }
524 }
525#endif
526 const auto& x = TPCClusterizerDecodeZSCount(iSector, fragmentMax);
527 nDigitsFragmentMax[iSector] = x.first;
528 processors()->tpcClusterer[iSector].mPmemory->counters.nDigits = x.first;
529 mRec->MemoryScalers()->nTPCdigits += x.first;
530 }
531 for (uint32_t iSector = 0; iSector < NSECTORS; iSector++) {
532 uint32_t nDigitsBase = nDigitsFragmentMax[iSector];
533 uint32_t threshold = 40000000;
534 uint32_t nDigitsScaled = nDigitsBase > threshold ? nDigitsBase : std::min((threshold + nDigitsBase) / 2, 2 * nDigitsBase);
535 processors()->tpcClusterer[iSector].SetNMaxDigits(processors()->tpcClusterer[iSector].mPmemory->counters.nDigits, mCFContext->nPagesFragmentMax, nDigitsScaled, mCFContext->nDigitsEndpointMax[iSector]);
536 if (doGPU) {
537 processorsShadow()->tpcClusterer[iSector].SetNMaxDigits(processors()->tpcClusterer[iSector].mPmemory->counters.nDigits, mCFContext->nPagesFragmentMax, nDigitsScaled, mCFContext->nDigitsEndpointMax[iSector]);
538 }
539 if (mPipelineNotifyCtx && GetProcessingSettings().doublePipelineClusterizer) {
540 mPipelineNotifyCtx->rec->AllocateRegisteredForeignMemory(processors()->tpcClusterer[iSector].mZSOffsetId, mRec);
541 mPipelineNotifyCtx->rec->AllocateRegisteredForeignMemory(processors()->tpcClusterer[iSector].mZSId, mRec);
542 } else {
543 AllocateRegisteredMemory(processors()->tpcClusterer[iSector].mZSOffsetId);
544 AllocateRegisteredMemory(processors()->tpcClusterer[iSector].mZSId);
545 }
546 }
547 } else {
548 for (uint32_t iSector = 0; iSector < NSECTORS; iSector++) {
549 uint32_t nDigits = mIOPtrs.tpcPackedDigits->nTPCDigits[iSector];
550 mRec->MemoryScalers()->nTPCdigits += nDigits;
551 processors()->tpcClusterer[iSector].SetNMaxDigits(nDigits, mCFContext->nPagesFragmentMax, nDigits, 0);
552 }
553 }
554
555 if (mIOPtrs.tpcZS) {
556 GPUInfo("Event has %u 8kb TPC ZS pages (version %d), %ld digits", mCFContext->nPagesTotal, mCFContext->zsVersion, (int64_t)mRec->MemoryScalers()->nTPCdigits);
557 } else {
558 GPUInfo("Event has %ld TPC Digits", (int64_t)mRec->MemoryScalers()->nTPCdigits);
559 }
560
561 if (mCFContext->tpcMaxTimeBin > maxAllowedTimebin) {
562 GPUError("Input data has invalid time bin %u > %d", mCFContext->tpcMaxTimeBin, maxAllowedTimebin);
563 if (GetProcessingSettings().ignoreNonFatalGPUErrors) {
564 mCFContext->abandonTimeframe = true;
565 mCFContext->tpcMaxTimeBin = maxAllowedTimebin;
566 } else {
567 return 1;
568 }
569 }
570
571 mCFContext->fragmentFirst = CfFragment{std::max<int32_t>(mCFContext->tpcMaxTimeBin + 1, maxFragmentLen), maxFragmentLen};
572 for (int32_t iSector = 0; iSector < GetProcessingSettings().nTPCClustererLanes && iSector < NSECTORS; iSector++) {
573 if (mIOPtrs.tpcZS && mCFContext->nPagesSector[iSector] && mCFContext->zsVersion != -1) {
574 mCFContext->nextPos[iSector] = RunTPCClusterizer_transferZS(iSector, mCFContext->fragmentFirst, GetProcessingSettings().nTPCClustererLanes + iSector);
575 }
576 }
577
578 if (mPipelineNotifyCtx && GetProcessingSettings().doublePipelineClusterizer) {
579 for (uint32_t iSector = 0; iSector < NSECTORS; iSector++) {
580 mCFContext->ptrSave[iSector].zsOffsetHost = processors()->tpcClusterer[iSector].mPzsOffsets;
581 mCFContext->ptrSave[iSector].zsOffsetDevice = processorsShadow()->tpcClusterer[iSector].mPzsOffsets;
582 mCFContext->ptrSave[iSector].zsDevice = processorsShadow()->tpcClusterer[iSector].mPzs;
583 }
584 }
585 return 0;
586}
587#endif
588
589int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
590{
591 if (param().rec.fwdTPCDigitsAsClusters) {
592 return ForwardTPCDigits();
593 }
594#ifdef GPUCA_TPC_GEOMETRY_O2
595 int32_t tpcTimeBinCut = mUpdateNewCalibObjects && mNewCalibValues->newTPCTimeBinCut ? mNewCalibValues->tpcTimeBinCut : param().tpcCutTimeBin;
597 const auto& threadContext = GetThreadContext();
598 const bool doGPU = GetRecoStepsGPU() & RecoStep::TPCClusterFinding;
599 if (RunTPCClusterizer_prepare(mPipelineNotifyCtx && GetProcessingSettings().doublePipelineClusterizer)) {
600 return 1;
601 }
602 if (GetProcessingSettings().autoAdjustHostThreads && !doGPU) {
604 }
605
607 float tpcHitLowOccupancyScalingFactor = 1.f;
609 uint32_t nHitsBase = mRec->MemoryScalers()->nTPCHits;
610 uint32_t threshold = 30000000 / 256 * mIOPtrs.settingsTF->nHBFPerTF;
611 if (mIOPtrs.settingsTF->nHBFPerTF < 64) {
612 threshold *= 2;
613 }
614 mRec->MemoryScalers()->nTPCHits = std::max<uint32_t>(nHitsBase, std::min<uint32_t>(threshold, nHitsBase * 3.5f)); // Increase the buffer size for low occupancy data to compensate for noisy pads creating exceiive clusters
615 if (nHitsBase < threshold) {
616 float maxFactor = mRec->MemoryScalers()->nTPCHits < threshold * 2 / 3 ? 3 : (mRec->MemoryScalers()->nTPCHits < threshold ? 2.25f : 1.75f);
617 mRec->MemoryScalers()->temporaryFactor *= std::min(maxFactor, (float)threshold / nHitsBase);
618 tpcHitLowOccupancyScalingFactor = std::min(3.5f, (float)threshold / nHitsBase);
619 }
620 }
621 for (uint32_t iSector = 0; iSector < NSECTORS; iSector++) {
622 processors()->tpcClusterer[iSector].SetMaxData(mIOPtrs); // First iteration to set data sizes
623 }
624 mRec->ComputeReuseMax(nullptr); // Resolve maximums for shared buffers
625 for (uint32_t iSector = 0; iSector < NSECTORS; iSector++) {
626 SetupGPUProcessor(&processors()->tpcClusterer[iSector], true); // Now we allocate
627 }
628 if (mPipelineNotifyCtx && GetProcessingSettings().doublePipelineClusterizer) {
629 RunTPCClusterizer_prepare(true); // Restore some pointers, allocated by the other pipeline, and set to 0 by SetupGPUProcessor (since not allocated in this pipeline)
630 }
631
632 if (doGPU && mIOPtrs.tpcZS) {
634 WriteToConstantMemory(RecoStep::TPCClusterFinding, (char*)&processors()->ioPtrs - (char*)processors(), &processorsShadow()->ioPtrs, sizeof(processorsShadow()->ioPtrs), mRec->NStreams() - 1);
635 }
636 if (doGPU) {
637 WriteToConstantMemory(RecoStep::TPCClusterFinding, (char*)processors()->tpcClusterer - (char*)processors(), processorsShadow()->tpcClusterer, sizeof(GPUTPCClusterFinder) * NSECTORS, mRec->NStreams() - 1, &mEvents->init);
638 }
639
640#ifdef GPUCA_HAS_ONNX
641 const GPUSettingsProcessingNNclusterizer& nn_settings = GetProcessingSettings().nn;
642 GPUTPCNNClusterizerHost nnApplications[GetProcessingSettings().nTPCClustererLanes];
643
644 if (GetProcessingSettings().nn.applyNNclusterizer) {
645 int32_t deviceId = -1;
646 int32_t numLanes = GetProcessingSettings().nTPCClustererLanes;
647 int32_t maxThreads = mRec->getNKernelHostThreads(true);
648 // bool recreateMemoryAllocator = false;
649 mRec->runParallelOuterLoop(doGPU, numLanes, [&](uint32_t lane) {
650 nnApplications[lane].init(nn_settings);
651 if (nnApplications[lane].mModelsUsed[0]) {
652 SetONNXGPUStream(*(nnApplications[lane].mModelClass).getSessionOptions(), lane, &deviceId);
653 (nnApplications[lane].mModelClass).setDeviceId(deviceId);
654 if (nnApplications[lane].mModelClass.getIntraOpNumThreads() > maxThreads) {
655 nnApplications[lane].mModelClass.setIntraOpNumThreads(maxThreads);
656 }
657 (nnApplications[lane].mModelClass).initEnvironment();
658 // Registering this once seems to be enough, even with different environmnents / models. ONNX apparently uses this per device and stores the OrtAllocator internally. All models will then use the volatile allocation.
659 // But environment must be valid, so we init the model environment first and use it here afterwards.
660 // Either this is done in one environment with lane == 0 or by recreating the allocator using recreateMemoryAllocator.
661 // TODO: Volatile allocation works for reserving, but not yet for allocations when binding the input tensor
662 // if (lane == 0) {
663 // nnApplications[lane].directOrtAllocator((nnApplications[lane].mModelClass).getEnv(), (nnApplications[lane].mModelClass).getMemoryInfo(), mRec, recreateMemoryAllocator);
664 // }
665 // recreateMemoryAllocator = true;
666 (nnApplications[lane].mModelClass).initSession();
667 }
668 if (nnApplications[lane].mModelsUsed[1]) {
669 SetONNXGPUStream(*(nnApplications[lane].mModelReg1).getSessionOptions(), lane, &deviceId);
670 (nnApplications[lane].mModelReg1).setDeviceId(deviceId);
671 if (nnApplications[lane].mModelReg1.getIntraOpNumThreads() > maxThreads) {
672 nnApplications[lane].mModelReg1.setIntraOpNumThreads(maxThreads);
673 }
674 // (nnApplications[lane].mModelReg1).setEnv((nnApplications[lane].mModelClass).getEnv());
675 (nnApplications[lane].mModelReg1).initEnvironment();
676 // nnApplications[lane].directOrtAllocator((nnApplications[lane].mModelReg1).getEnv(), (nnApplications[lane].mModelReg1).getMemoryInfo(), mRec, recreateMemoryAllocator);
677 (nnApplications[lane].mModelReg1).initSession();
678 }
679 if (nnApplications[lane].mModelsUsed[2]) {
680 SetONNXGPUStream(*(nnApplications[lane].mModelReg2).getSessionOptions(), lane, &deviceId);
681 (nnApplications[lane].mModelReg2).setDeviceId(deviceId);
682 if (nnApplications[lane].mModelReg2.getIntraOpNumThreads() > maxThreads) {
683 nnApplications[lane].mModelReg2.setIntraOpNumThreads(maxThreads);
684 }
685 // (nnApplications[lane].mModelReg2).setEnv((nnApplications[lane].mModelClass).getEnv());
686 (nnApplications[lane].mModelReg2).initEnvironment();
687 // nnApplications[lane].directOrtAllocator((nnApplications[lane].mModelClass).getEnv(), (nnApplications[lane].mModelClass).getMemoryInfo(), mRec, recreateMemoryAllocator);
688 (nnApplications[lane].mModelReg2).initSession();
689 }
690 if (nn_settings.nnClusterizerVerbosity < 3) {
691 LOG(info) << "(ORT) Allocated ONNX stream for lane " << lane << " and device " << deviceId;
692 }
693 });
694 mRec->runParallelOuterLoop(doGPU, NSECTORS, [&](uint32_t sector) {
695 GPUTPCNNClusterizer& clustererNN = processors()->tpcNNClusterer[sector];
696 GPUTPCNNClusterizer& clustererNNShadow = doGPU ? processorsShadow()->tpcNNClusterer[sector] : clustererNN;
697 int32_t lane = sector % numLanes;
698 clustererNN.mDeviceId = deviceId;
699 clustererNN.mISector = sector;
701 nnApplications[lane].initClusterizer(nn_settings, clustererNN);
702 if (doGPU) {
703 clustererNNShadow.mDeviceId = deviceId;
704 clustererNNShadow.mISector = sector;
706 nnApplications[lane].initClusterizer(nn_settings, clustererNNShadow);
707 }
709 });
710 if (doGPU) {
711 WriteToConstantMemory(RecoStep::TPCClusterFinding, (char*)&processors()->tpcNNClusterer - (char*)processors(), &processorsShadow()->tpcNNClusterer, sizeof(GPUTPCNNClusterizer) * NSECTORS, mRec->NStreams() - 1, &mEvents->init);
712 }
713 }
714#endif
715
716 size_t nClsTotal = 0;
717 ClusterNativeAccess* tmpNativeAccess = mClusterNativeAccess.get();
718 ClusterNative* tmpNativeClusters = nullptr;
719 std::unique_ptr<ClusterNative[]> tmpNativeClusterBuffer;
720
721 // setup MC Labels
723
724 auto* digitsMC = propagateMCLabels ? processors()->ioPtrs.tpcPackedDigits->tpcDigitsMC : nullptr;
725
726 bool buildNativeGPU = doGPU && NeedTPCClustersOnGPU();
727 bool buildNativeHost = (mRec->GetRecoStepsOutputs() & GPUDataTypes::InOutType::TPCClusters) || GetProcessingSettings().deterministicGPUReconstruction; // TODO: Should do this also when clusters are needed for later steps on the host but not requested as output
728
729 mInputsHost->mNClusterNative = mInputsShadow->mNClusterNative = mRec->MemoryScalers()->nTPCHits * tpcHitLowOccupancyScalingFactor;
730 if (buildNativeGPU) {
731 AllocateRegisteredMemory(mInputsHost->mResourceClusterNativeBuffer);
732 }
733 if (buildNativeHost && !(buildNativeGPU && GetProcessingSettings().delayedOutput)) {
734 if (mWaitForFinalInputs) {
735 GPUFatal("Cannot use waitForFinalInput callback without delayed output");
736 }
737 if (!GetProcessingSettings().tpcApplyClusterFilterOnCPU) {
739 tmpNativeClusters = mInputsHost->mPclusterNativeOutput;
740 } else {
741 tmpNativeClusterBuffer = std::make_unique<ClusterNative[]>(mInputsHost->mNClusterNative);
742 tmpNativeClusters = tmpNativeClusterBuffer.get();
743 }
744 }
745
746 GPUTPCLinearLabels mcLinearLabels;
747 if (propagateMCLabels) {
748 // No need to overallocate here, nTPCHits is anyway an upper bound used for the GPU cluster buffer, and we can always enlarge the buffer anyway
749 mcLinearLabels.header.reserve(mRec->MemoryScalers()->nTPCHits / 2);
750 mcLinearLabels.data.reserve(mRec->MemoryScalers()->nTPCHits);
751 }
752
753 int8_t transferRunning[NSECTORS] = {0};
754 uint32_t outputQueueStart = mOutputQueue.size();
755
756 auto notifyForeignChainFinished = [this]() {
757 if (mPipelineNotifyCtx) {
758 SynchronizeStream(OutputStream()); // Must finish before updating ioPtrs in (global) constant memory
759 {
760 std::lock_guard<std::mutex> lock(mPipelineNotifyCtx->mutex);
761 mPipelineNotifyCtx->ready = true;
762 }
763 mPipelineNotifyCtx->cond.notify_one();
764 }
765 };
766 bool synchronizeCalibUpdate = false;
767
768 for (uint32_t iSectorBase = 0; iSectorBase < NSECTORS; iSectorBase += GetProcessingSettings().nTPCClustererLanes) {
769 std::vector<bool> laneHasData(GetProcessingSettings().nTPCClustererLanes, false);
770 static_assert(NSECTORS <= GPUCA_MAX_STREAMS, "Stream events must be able to hold all sectors");
771 const int32_t maxLane = std::min<int32_t>(GetProcessingSettings().nTPCClustererLanes, NSECTORS - iSectorBase);
772 for (CfFragment fragment = mCFContext->fragmentFirst; !fragment.isEnd(); fragment = fragment.next()) {
773 if (GetProcessingSettings().debugLevel >= 3) {
774 GPUInfo("Processing time bins [%d, %d) for sectors %d to %d", fragment.start, fragment.last(), iSectorBase, iSectorBase + GetProcessingSettings().nTPCClustererLanes - 1);
775 }
776 mRec->runParallelOuterLoop(doGPU, maxLane, [&](uint32_t lane) {
777 if (doGPU && fragment.index != 0) {
778 SynchronizeStream(lane); // Don't overwrite charge map from previous iteration until cluster computation is finished
779 }
780
781 uint32_t iSector = iSectorBase + lane;
782 GPUTPCClusterFinder& clusterer = processors()->tpcClusterer[iSector];
783 GPUTPCClusterFinder& clustererShadow = doGPU ? processorsShadow()->tpcClusterer[iSector] : clusterer;
784 clusterer.mPmemory->counters.nPeaks = clusterer.mPmemory->counters.nClusters = 0;
785 clusterer.mPmemory->fragment = fragment;
786
788 bool setDigitsOnGPU = doGPU && not mIOPtrs.tpcZS;
789 bool setDigitsOnHost = (not doGPU && not mIOPtrs.tpcZS) || propagateMCLabels;
790 auto* inDigits = mIOPtrs.tpcPackedDigits;
791 size_t numDigits = inDigits->nTPCDigits[iSector];
792 if (setDigitsOnGPU) {
793 GPUMemCpy(RecoStep::TPCClusterFinding, clustererShadow.mPdigits, inDigits->tpcDigits[iSector], sizeof(clustererShadow.mPdigits[0]) * numDigits, lane, true);
794 }
795 if (setDigitsOnHost) {
796 clusterer.mPdigits = const_cast<o2::tpc::Digit*>(inDigits->tpcDigits[iSector]); // TODO: Needs fixing (invalid const cast)
797 }
798 clusterer.mPmemory->counters.nDigits = numDigits;
799 }
800
801 if (mIOPtrs.tpcZS) {
802 if (mCFContext->nPagesSector[iSector] && mCFContext->zsVersion != -1) {
803 clusterer.mPmemory->counters.nPositions = mCFContext->nextPos[iSector].first;
804 clusterer.mPmemory->counters.nPagesSubsector = mCFContext->nextPos[iSector].second;
805 } else {
806 clusterer.mPmemory->counters.nPositions = clusterer.mPmemory->counters.nPagesSubsector = 0;
807 }
808 }
809 TransferMemoryResourceLinkToGPU(RecoStep::TPCClusterFinding, clusterer.mMemoryId, lane);
810
811 using ChargeMapType = decltype(*clustererShadow.mPchargeMap);
812 using PeakMapType = decltype(*clustererShadow.mPpeakMap);
813 runKernel<GPUMemClean16>({GetGridAutoStep(lane, RecoStep::TPCClusterFinding)}, clustererShadow.mPchargeMap, TPCMapMemoryLayout<ChargeMapType>::items(GetProcessingSettings().overrideClusterizerFragmentLen) * sizeof(ChargeMapType));
814 runKernel<GPUMemClean16>({GetGridAutoStep(lane, RecoStep::TPCClusterFinding)}, clustererShadow.mPpeakMap, TPCMapMemoryLayout<PeakMapType>::items(GetProcessingSettings().overrideClusterizerFragmentLen) * sizeof(PeakMapType));
815 if (fragment.index == 0) {
816 runKernel<GPUMemClean16>({GetGridAutoStep(lane, RecoStep::TPCClusterFinding)}, clustererShadow.mPpadIsNoisy, TPC_PADS_IN_SECTOR * sizeof(*clustererShadow.mPpadIsNoisy));
817 }
819
820 if (doGPU) {
821 if (mIOPtrs.tpcZS && mCFContext->nPagesSector[iSector] && mCFContext->zsVersion != -1) {
822 TransferMemoryResourceLinkToGPU(RecoStep::TPCClusterFinding, mInputsHost->mResourceZS, lane);
823 SynchronizeStream(GetProcessingSettings().nTPCClustererLanes + lane);
824 }
825 SynchronizeStream(mRec->NStreams() - 1); // Wait for copying to constant memory
826 }
827
828 if (mIOPtrs.tpcZS && (mCFContext->abandonTimeframe || !mCFContext->nPagesSector[iSector] || mCFContext->zsVersion == -1)) {
829 clusterer.mPmemory->counters.nPositions = 0;
830 return;
831 }
832 if (!mIOPtrs.tpcZS && mIOPtrs.tpcPackedDigits->nTPCDigits[iSector] == 0) {
833 clusterer.mPmemory->counters.nPositions = 0;
834 return;
835 }
836
837 if (propagateMCLabels && fragment.index == 0) {
838 clusterer.PrepareMC();
839 clusterer.mPinputLabels = digitsMC->v[iSector];
840 if (clusterer.mPinputLabels == nullptr) {
841 GPUFatal("MC label container missing, sector %d", iSector);
842 }
843 if (clusterer.mPinputLabels->getIndexedSize() != mIOPtrs.tpcPackedDigits->nTPCDigits[iSector]) {
844 GPUFatal("MC label container has incorrect number of entries: %d expected, has %d\n", (int32_t)mIOPtrs.tpcPackedDigits->nTPCDigits[iSector], (int32_t)clusterer.mPinputLabels->getIndexedSize());
845 }
846 }
847
848 if (GetProcessingSettings().tpcSingleSector == -1 || GetProcessingSettings().tpcSingleSector == (int32_t)iSector) {
849 if (not mIOPtrs.tpcZS) {
850 runKernel<GPUTPCCFChargeMapFiller, GPUTPCCFChargeMapFiller::findFragmentStart>({GetGrid(1, lane), {iSector}}, mIOPtrs.tpcZS == nullptr);
851 TransferMemoryResourceLinkToHost(RecoStep::TPCClusterFinding, clusterer.mMemoryId, lane);
852 } else if (propagateMCLabels) {
853 runKernel<GPUTPCCFChargeMapFiller, GPUTPCCFChargeMapFiller::findFragmentStart>({GetGrid(1, lane, GPUReconstruction::krnlDeviceType::CPU), {iSector}}, mIOPtrs.tpcZS == nullptr);
854 TransferMemoryResourceLinkToGPU(RecoStep::TPCClusterFinding, clusterer.mMemoryId, lane);
855 }
856 }
857
858 if (mIOPtrs.tpcZS) {
859 int32_t firstHBF = (mIOPtrs.settingsTF && mIOPtrs.settingsTF->hasTfStartOrbit) ? mIOPtrs.settingsTF->tfStartOrbit : ((mIOPtrs.tpcZS->sector[iSector].count[0] && mIOPtrs.tpcZS->sector[iSector].nZSPtr[0][0]) ? o2::raw::RDHUtils::getHeartBeatOrbit(*(const o2::header::RAWDataHeader*)mIOPtrs.tpcZS->sector[iSector].zsPtr[0][0]) : 0);
860 uint32_t nBlocks = doGPU ? clusterer.mPmemory->counters.nPagesSubsector : GPUTrackingInOutZS::NENDPOINTS;
861
862 (void)tpcTimeBinCut; // TODO: To be used in decoding kernels
863 switch (mCFContext->zsVersion) {
864 default:
865 GPUFatal("Data with invalid TPC ZS mode (%d) received", mCFContext->zsVersion);
866 break;
869 runKernel<GPUTPCCFDecodeZS>({GetGridBlk(nBlocks, lane), {iSector}}, firstHBF);
870 break;
872 runKernel<GPUTPCCFDecodeZSLink>({GetGridBlk(nBlocks, lane), {iSector}}, firstHBF);
873 break;
875 runKernel<GPUTPCCFDecodeZSDenseLink>({GetGridBlk(nBlocks, lane), {iSector}}, firstHBF);
876 break;
877 }
878 TransferMemoryResourceLinkToHost(RecoStep::TPCClusterFinding, clusterer.mMemoryId, lane);
879 } // clang-format off
880 });
881 mRec->runParallelOuterLoop(doGPU, maxLane, [&](uint32_t lane) {
882 uint32_t iSector = iSectorBase + lane;
883 if (doGPU) {
884 SynchronizeStream(lane);
885 }
886 if (mIOPtrs.tpcZS) {
887 CfFragment f = fragment.next();
888 int32_t nextSector = iSector;
889 if (f.isEnd()) {
890 nextSector += GetProcessingSettings().nTPCClustererLanes;
891 f = mCFContext->fragmentFirst;
892 }
893 if (nextSector < NSECTORS && mIOPtrs.tpcZS && mCFContext->nPagesSector[nextSector] && mCFContext->zsVersion != -1 && !mCFContext->abandonTimeframe) {
894 mCFContext->nextPos[nextSector] = RunTPCClusterizer_transferZS(nextSector, f, GetProcessingSettings().nTPCClustererLanes + lane);
895 }
896 }
897 GPUTPCClusterFinder& clusterer = processors()->tpcClusterer[iSector];
898 GPUTPCClusterFinder& clustererShadow = doGPU ? processorsShadow()->tpcClusterer[iSector] : clusterer;
899 if (clusterer.mPmemory->counters.nPositions == 0) {
900 return;
901 }
902 if (!mIOPtrs.tpcZS) {
903 runKernel<GPUTPCCFChargeMapFiller, GPUTPCCFChargeMapFiller::fillFromDigits>({GetGrid(clusterer.mPmemory->counters.nPositions, lane), {iSector}});
904 }
906 clusterer.DumpChargeMap(*mDebugFile, "Charges");
907 }
908
909 if (propagateMCLabels) {
910 runKernel<GPUTPCCFChargeMapFiller, GPUTPCCFChargeMapFiller::fillIndexMap>({GetGrid(clusterer.mPmemory->counters.nDigitsInFragment, lane, GPUReconstruction::krnlDeviceType::CPU), {iSector}});
911 }
912
913 bool checkForNoisyPads = (rec()->GetParam().rec.tpc.maxTimeBinAboveThresholdIn1000Bin > 0) || (rec()->GetParam().rec.tpc.maxConsecTimeBinAboveThreshold > 0);
914 checkForNoisyPads &= (rec()->GetParam().rec.tpc.noisyPadsQuickCheck ? fragment.index == 0 : true);
915 checkForNoisyPads &= !GetProcessingSettings().disableTPCNoisyPadFilter;
916
917 if (checkForNoisyPads) {
919
920 runKernel<GPUTPCCFCheckPadBaseline>({GetGridBlk(nBlocks, lane), {iSector}});
921 }
922
923 runKernel<GPUTPCCFPeakFinder>({GetGrid(clusterer.mPmemory->counters.nPositions, lane), {iSector}});
925 clusterer.DumpPeakMap(*mDebugFile, "Peaks");
926 }
927
928 RunTPCClusterizer_compactPeaks(clusterer, clustererShadow, 0, doGPU, lane);
929 TransferMemoryResourceLinkToHost(RecoStep::TPCClusterFinding, clusterer.mMemoryId, lane);
930 DoDebugAndDump(RecoStep::TPCClusterFinding, GPUChainTrackingDebugFlags::TPCClustererPeaks, clusterer, &GPUTPCClusterFinder::DumpPeaksCompacted, *mDebugFile); // clang-format off
931 });
932 mRec->runParallelOuterLoop(doGPU, maxLane, [&](uint32_t lane) {
933 uint32_t iSector = iSectorBase + lane;
934 GPUTPCClusterFinder& clusterer = processors()->tpcClusterer[iSector];
935 GPUTPCClusterFinder& clustererShadow = doGPU ? processorsShadow()->tpcClusterer[iSector] : clusterer;
936 if (doGPU) {
937 SynchronizeStream(lane);
938 }
939 if (clusterer.mPmemory->counters.nPeaks == 0) {
940 return;
941 }
942 runKernel<GPUTPCCFNoiseSuppression, GPUTPCCFNoiseSuppression::noiseSuppression>({GetGrid(clusterer.mPmemory->counters.nPeaks, lane), {iSector}});
943 runKernel<GPUTPCCFNoiseSuppression, GPUTPCCFNoiseSuppression::updatePeaks>({GetGrid(clusterer.mPmemory->counters.nPeaks, lane), {iSector}});
945 clusterer.DumpPeakMap(*mDebugFile, "Suppressed Peaks");
946 }
947
948 RunTPCClusterizer_compactPeaks(clusterer, clustererShadow, 1, doGPU, lane);
949 TransferMemoryResourceLinkToHost(RecoStep::TPCClusterFinding, clusterer.mMemoryId, lane);
951 });
952 mRec->runParallelOuterLoop(doGPU, maxLane, [&](uint32_t lane) {
953 uint32_t iSector = iSectorBase + lane;
954 GPUTPCClusterFinder& clusterer = processors()->tpcClusterer[iSector];
955 GPUTPCClusterFinder& clustererShadow = doGPU ? processorsShadow()->tpcClusterer[iSector] : clusterer;
956
957 if (doGPU) {
958 SynchronizeStream(lane);
959 }
960
961 if (fragment.index == 0) {
962 deviceEvent* waitEvent = nullptr;
963 if (transferRunning[lane] == 1) {
964 waitEvent = &mEvents->stream[lane];
965 transferRunning[lane] = 2;
966 }
967 runKernel<GPUMemClean16>({GetGridAutoStep(lane, RecoStep::TPCClusterFinding), krnlRunRangeNone, {nullptr, waitEvent}}, clustererShadow.mPclusterInRow, GPUCA_ROW_COUNT * sizeof(*clustererShadow.mPclusterInRow));
968 }
969
970 if (clusterer.mPmemory->counters.nClusters == 0) {
971 return;
972 }
973
974 if (GetProcessingSettings().nn.applyNNclusterizer) {
975#ifdef GPUCA_HAS_ONNX
976 GPUTPCNNClusterizer& clustererNN = processors()->tpcNNClusterer[lane];
977 GPUTPCNNClusterizer& clustererNNShadow = doGPU ? processorsShadow()->tpcNNClusterer[lane] : clustererNN;
978 GPUTPCNNClusterizerHost& nnApplication = nnApplications[lane];
979
980 // // bool recreateMemoryAllocator = false;
981 // if (lane == 0) {
982 // (nnApplications[lane].mModelClass).initEnvironment();
983 // nnApplications[lane].directOrtAllocator((nnApplications[lane].mModelClass).getEnv(), (nnApplications[lane].mModelClass).getMemoryInfo(), mRec, 0);
984 // }
985 // // recreateMemoryAllocator = true;
986 // (nnApplications[lane].mModelClass).initSession();
987 // (nnApplications[lane].mModelReg1).initSession();
988
989 int withMC = (doGPU && propagateMCLabels);
990
991 if (clustererNNShadow.mNnClusterizerUseCfRegression || (int)(nn_settings.nnClusterizerApplyCfDeconvolution)) {
992 runKernel<GPUTPCCFDeconvolution>({GetGrid(clusterer.mPmemory->counters.nPositions, lane), {iSector}});
994 }
995
996 // float time_clusterizer = 0, time_fill = 0, time_networks = 0;
997 for (int batch = 0; batch < std::ceil((float)clusterer.mPmemory->counters.nClusters / clustererNNShadow.mNnClusterizerBatchedMode); batch++) {
998 uint batchStart = batch * clustererNNShadow.mNnClusterizerBatchedMode;
999 size_t iSize = CAMath::Min((uint)clustererNNShadow.mNnClusterizerBatchedMode, (uint)(clusterer.mPmemory->counters.nClusters - batchStart));
1000
1001 // auto start0 = std::chrono::high_resolution_clock::now();
1002 runKernel<GPUTPCNNClusterizerKernels, GPUTPCNNClusterizerKernels::fillInputNNSingleElement>({GetGrid(iSize * clustererNNShadow.mNnClusterizerElementSize, lane), krnlRunRangeNone}, iSector, clustererNNShadow.mNnInferenceInputDType, withMC, batchStart); // Filling the data
1003
1004 // auto stop0 = std::chrono::high_resolution_clock::now();
1005 // auto start1 = std::chrono::high_resolution_clock::now();
1006
1007 // NN evaluations
1008 if (clustererNNShadow.mNnInferenceInputDType == 0) {
1009 if (clustererNNShadow.mNnInferenceOutputDType == 0) {
1010 (nnApplication.mModelClass).inference(clustererNNShadow.mInputData_16, iSize, clustererNNShadow.mModelProbabilities_16);
1011 } else if (clustererNNShadow.mNnInferenceOutputDType == 1) {
1012 (nnApplication.mModelClass).inference(clustererNNShadow.mInputData_16, iSize, clustererNNShadow.mModelProbabilities_32);
1013 }
1014 } else if (clustererNNShadow.mNnInferenceInputDType == 1) {
1015 if (clustererNNShadow.mNnInferenceOutputDType == 0) {
1016 (nnApplication.mModelClass).inference(clustererNNShadow.mInputData_32, iSize, clustererNNShadow.mModelProbabilities_16);
1017 } else if (clustererNNShadow.mNnInferenceOutputDType == 1) {
1018 (nnApplication.mModelClass).inference(clustererNNShadow.mInputData_32, iSize, clustererNNShadow.mModelProbabilities_32);
1019 }
1020 }
1021 if (!clustererNNShadow.mNnClusterizerUseCfRegression) {
1022 if (clustererNNShadow.mNnInferenceInputDType == 0) {
1023 if (clustererNNShadow.mNnInferenceOutputDType == 0) {
1024 (nnApplication.mModelReg1).inference(clustererNNShadow.mInputData_16, iSize, clustererNNShadow.mOutputDataReg1_16);
1025 } else if (clustererNNShadow.mNnInferenceOutputDType == 1) {
1026 (nnApplication.mModelReg1).inference(clustererNNShadow.mInputData_16, iSize, clustererNNShadow.mOutputDataReg1_32);
1027 }
1028 } else if (clustererNNShadow.mNnInferenceInputDType == 1) {
1029 if (clustererNNShadow.mNnInferenceOutputDType == 0) {
1030 (nnApplication.mModelReg1).inference(clustererNNShadow.mInputData_32, iSize, clustererNNShadow.mOutputDataReg1_16);
1031 } else if (clustererNNShadow.mNnInferenceOutputDType == 1) {
1032 (nnApplication.mModelReg1).inference(clustererNNShadow.mInputData_32, iSize, clustererNNShadow.mOutputDataReg1_32);
1033 }
1034 }
1035 if (nnApplication.mModelClass.getNumOutputNodes()[0][1] > 1 && nnApplication.mModelReg2.isInitialized()) {
1036 if (clustererNNShadow.mNnInferenceInputDType == 0) {
1037 if (clustererNNShadow.mNnInferenceOutputDType == 0) {
1038 (nnApplication.mModelReg2).inference(clustererNNShadow.mInputData_16, iSize, clustererNNShadow.mOutputDataReg2_16);
1039 } else if (clustererNNShadow.mNnInferenceOutputDType == 1) {
1040 (nnApplication.mModelReg2).inference(clustererNNShadow.mInputData_16, iSize, clustererNNShadow.mOutputDataReg2_32);
1041 }
1042 } else if (clustererNNShadow.mNnInferenceInputDType == 1) {
1043 if (clustererNNShadow.mNnInferenceOutputDType == 0) {
1044 (nnApplication.mModelReg2).inference(clustererNNShadow.mInputData_32, iSize, clustererNNShadow.mOutputDataReg2_16);
1045 } else if (clustererNNShadow.mNnInferenceOutputDType == 1) {
1046 (nnApplication.mModelReg2).inference(clustererNNShadow.mInputData_32, iSize, clustererNNShadow.mOutputDataReg2_32);
1047 }
1048 }
1049 }
1050 }
1051
1052 // auto stopNNs = std::chrono::high_resolution_clock::now();
1053
1054 // Publishing kernels
1055 if (nnApplication.mModelClass.getNumOutputNodes()[0][1] == 1) {
1056 runKernel<GPUTPCNNClusterizerKernels, GPUTPCNNClusterizerKernels::determineClass1Labels>({GetGrid(iSize, lane), krnlRunRangeNone}, iSector, clustererNNShadow.mNnInferenceOutputDType, withMC, batchStart); // Assigning class labels
1057 } else {
1058 runKernel<GPUTPCNNClusterizerKernels, GPUTPCNNClusterizerKernels::determineClass2Labels>({GetGrid(iSize, lane), krnlRunRangeNone}, iSector, clustererNNShadow.mNnInferenceOutputDType, withMC, batchStart); // Assigning class labels
1059 }
1060 if (!clustererNNShadow.mNnClusterizerUseCfRegression) {
1061 runKernel<GPUTPCNNClusterizerKernels, GPUTPCNNClusterizerKernels::publishClass1Regression>({GetGrid(iSize, lane), krnlRunRangeNone}, iSector, clustererNNShadow.mNnInferenceOutputDType, withMC, batchStart); // Publishing class 1 regression results
1062 if (nnApplication.mModelClass.getNumOutputNodes()[0][1] > 1 && nnApplication.mModelReg2.isInitialized()) {
1063 runKernel<GPUTPCNNClusterizerKernels, GPUTPCNNClusterizerKernels::publishClass2Regression>({GetGrid(iSize, lane), krnlRunRangeNone}, iSector, clustererNNShadow.mNnInferenceOutputDType, withMC, batchStart); // Publishing class 2 regression results
1064 }
1065 }
1066
1067 // for(int i = 0; i < iSize; ++i) {
1068 // if(clustererNNShadow.mOutputDataClass[i + batchStart] > 1) {
1069 // LOG(info) << "WARNING ORT: Output of " << i + batchStart << " / " << clusterer.mPmemory->counters.nClusters << " is " << clustererNNShadow.mModelProbabilities_16[i].ToFloat() << " and " << clustererNNShadow.mOutputDataClass[i + batchStart] << " thresh " << clustererNNShadow.mNnClassThreshold << " instead of 0 or 1. Please check the model and the input data.";
1070 // // std::string input = "[";
1071 // // for(int j = 0; j < clustererNNShadow.mNnClusterizerElementSize; j++){
1072 // // input += std::to_string(clustererNNShadow.mInputData_16[i * clustererNNShadow.mNnClusterizerElementSize + j].ToFloat()) + ", ";
1073 // // }
1074 // // input += "]";
1075 // // LOG(info) << "Input is: " << input;
1076 // }
1077 // }
1078
1079 // auto stop1 = std::chrono::high_resolution_clock::now();
1080
1081 // time_networks += std::chrono::duration_cast<std::chrono::nanoseconds>(stopNNs - start1).count() / 1e9;
1082 // time_clusterizer += std::chrono::duration_cast<std::chrono::nanoseconds>(stop1 - start1).count() / 1e9;
1083 // time_fill += std::chrono::duration_cast<std::chrono::nanoseconds>(stop0 - start0).count() / 1e9;
1084 }
1085 if (clustererNNShadow.mNnClusterizerUseCfRegression) {
1086 // auto start1 = std::chrono::high_resolution_clock::now();
1087 runKernel<GPUTPCNNClusterizerKernels, GPUTPCNNClusterizerKernels::runCfClusterizer>({GetGrid(clusterer.mPmemory->counters.nClusters, lane), krnlRunRangeNone}, iSector, clustererNNShadow.mNnInferenceInputDType, withMC, 0); // Running the CF regression kernel - no batching needed: batchStart = 0
1088 // auto stop1 = std::chrono::high_resolution_clock::now();
1089 // time_clusterizer += std::chrono::duration_cast<std::chrono::nanoseconds>(stop1 - start1).count() / 1e9;
1090 }
1091 // if (clustererNNShadow.mNnClusterizerVerbosity < 3) {
1092 // int acceptedClusters = 0;
1093 // for (size_t i = 0; i < clusterer.mPmemory->counters.nClusters; ++i) {
1094 // if(clustererNNShadow.mOutputDataClass[i] > 1 || clustererNNShadow.mOutputDataClass[i] < 0) {
1095 // LOG(info) << "WARNING ORT 2: " << clustererNNShadow.mOutputDataClass[i] << " for index " << i << " / " << clusterer.mPmemory->counters.nClusters;
1096 // }
1097 // acceptedClusters += clustererNNShadow.mOutputDataClass[i];
1098 // }
1099 // LOG(info) << "[NN CF] Apply NN (fragment " << fragment.index << ", lane: " << lane << ", sector: " << iSector << "): filling data " << time_fill << "s ; networks: " << time_networks << "s ; clusterizer: " << time_clusterizer << "s ; " << clusterer.mPmemory->counters.nClusters << " clusters, " << acceptedClusters << " accepted. --> " << (int32_t)clusterer.mPmemory->counters.nClusters / (time_fill + time_clusterizer) << " clusters/s";
1100 // }
1101#else
1102 GPUFatal("Project not compiled with neural network clusterization. Aborting.");
1103#endif
1104 } else {
1105 runKernel<GPUTPCCFDeconvolution>({GetGrid(clusterer.mPmemory->counters.nPositions, lane), {iSector}});
1106 DoDebugAndDump(RecoStep::TPCClusterFinding, GPUChainTrackingDebugFlags::TPCClustererChargeMap, clusterer, &GPUTPCClusterFinder::DumpChargeMap, *mDebugFile, "Split Charges");
1107 runKernel<GPUTPCCFClusterizer>({GetGrid(clusterer.mPmemory->counters.nClusters, lane), {iSector}}, 0);
1108 }
1109
1110 if (doGPU && propagateMCLabels) {
1111 TransferMemoryResourceLinkToHost(RecoStep::TPCClusterFinding, clusterer.mScratchId, lane);
1112 if (doGPU) {
1113 SynchronizeStream(lane);
1114 }
1115 runKernel<GPUTPCCFClusterizer>({GetGrid(clusterer.mPmemory->counters.nClusters, lane, GPUReconstruction::krnlDeviceType::CPU), {iSector}}, 1); // Computes MC labels
1116 }
1117
1118 if (GetProcessingSettings().debugLevel >= 3) {
1119 GPUInfo("Sector %02d Fragment %02d Lane %d: Found clusters: digits %u peaks %u clusters %u", iSector, fragment.index, lane, (int32_t)clusterer.mPmemory->counters.nPositions, (int32_t)clusterer.mPmemory->counters.nPeaks, (int32_t)clusterer.mPmemory->counters.nClusters);
1120 }
1121
1122 TransferMemoryResourcesToHost(RecoStep::TPCClusterFinding, &clusterer, lane);
1123 laneHasData[lane] = true;
1124 // Include clusters in default debug mask, exclude other debug output by default
1125 DoDebugAndDump(RecoStep::TPCClusterFinding, GPUChainTrackingDebugFlags::TPCClustererClusters, clusterer, &GPUTPCClusterFinder::DumpClusters, *mDebugFile); // clang-format off
1126 });
1128 }
1129
1130 size_t nClsFirst = nClsTotal;
1131 bool anyLaneHasData = false;
1132 for (int32_t lane = 0; lane < maxLane; lane++) {
1133 uint32_t iSector = iSectorBase + lane;
1134 std::fill(&tmpNativeAccess->nClusters[iSector][0], &tmpNativeAccess->nClusters[iSector][0] + MAXGLOBALPADROW, 0);
1135 if (doGPU) {
1136 SynchronizeStream(lane);
1137 }
1138 GPUTPCClusterFinder& clusterer = processors()->tpcClusterer[iSector];
1139 GPUTPCClusterFinder& clustererShadow = doGPU ? processorsShadow()->tpcClusterer[iSector] : clusterer;
1140
1141 if (laneHasData[lane]) {
1142 anyLaneHasData = true;
1143 if (buildNativeGPU && GetProcessingSettings().tpccfGatherKernel) {
1144 runKernel<GPUTPCCFGather>({GetGridBlk(GPUCA_ROW_COUNT, mRec->NStreams() - 1), {iSector}}, &mInputsShadow->mPclusterNativeBuffer[nClsTotal]);
1145 }
1146 for (uint32_t j = 0; j < GPUCA_ROW_COUNT; j++) {
1147 if (nClsTotal + clusterer.mPclusterInRow[j] > mInputsHost->mNClusterNative) {
1148 clusterer.raiseError(GPUErrors::ERROR_CF_GLOBAL_CLUSTER_OVERFLOW, iSector * 1000 + j, nClsTotal + clusterer.mPclusterInRow[j], mInputsHost->mNClusterNative);
1149 continue;
1150 }
1151 if (buildNativeGPU) {
1152 if (!GetProcessingSettings().tpccfGatherKernel) {
1153 GPUMemCpyAlways(RecoStep::TPCClusterFinding, (void*)&mInputsShadow->mPclusterNativeBuffer[nClsTotal], (const void*)&clustererShadow.mPclusterByRow[j * clusterer.mNMaxClusterPerRow], sizeof(mIOPtrs.clustersNative->clustersLinear[0]) * clusterer.mPclusterInRow[j], mRec->NStreams() - 1, -2);
1154 }
1155 } else if (buildNativeHost) {
1156 GPUMemCpyAlways(RecoStep::TPCClusterFinding, (void*)&tmpNativeClusters[nClsTotal], (const void*)&clustererShadow.mPclusterByRow[j * clusterer.mNMaxClusterPerRow], sizeof(mIOPtrs.clustersNative->clustersLinear[0]) * clusterer.mPclusterInRow[j], mRec->NStreams() - 1, false);
1157 }
1158 tmpNativeAccess->nClusters[iSector][j] += clusterer.mPclusterInRow[j];
1159 nClsTotal += clusterer.mPclusterInRow[j];
1160 }
1161 if (transferRunning[lane]) {
1162 ReleaseEvent(mEvents->stream[lane], doGPU);
1163 }
1164 RecordMarker(&mEvents->stream[lane], mRec->NStreams() - 1);
1165 transferRunning[lane] = 1;
1166 }
1167
1168 if (not propagateMCLabels || not laneHasData[lane]) {
1169 assert(propagateMCLabels ? mcLinearLabels.header.size() == nClsTotal : true);
1170 continue;
1171 }
1172
1173 runKernel<GPUTPCCFMCLabelFlattener, GPUTPCCFMCLabelFlattener::setRowOffsets>({GetGrid(GPUCA_ROW_COUNT, lane, GPUReconstruction::krnlDeviceType::CPU), {iSector}});
1175 runKernel<GPUTPCCFMCLabelFlattener, GPUTPCCFMCLabelFlattener::flatten>({GetGrid(GPUCA_ROW_COUNT, lane, GPUReconstruction::krnlDeviceType::CPU), {iSector}}, &mcLinearLabels);
1176 clusterer.clearMCMemory();
1177 assert(propagateMCLabels ? mcLinearLabels.header.size() == nClsTotal : true);
1178 }
1179 if (propagateMCLabels) {
1180 for (int32_t lane = 0; lane < maxLane; lane++) {
1181 processors()->tpcClusterer[iSectorBase + lane].clearMCMemory();
1182 }
1183 }
1184 if (buildNativeHost && buildNativeGPU && anyLaneHasData) {
1185 if (GetProcessingSettings().delayedOutput) {
1186 mOutputQueue.emplace_back(outputQueueEntry{(void*)((char*)&tmpNativeClusters[nClsFirst] - (char*)&tmpNativeClusters[0]), &mInputsShadow->mPclusterNativeBuffer[nClsFirst], (nClsTotal - nClsFirst) * sizeof(tmpNativeClusters[0]), RecoStep::TPCClusterFinding});
1187 } else {
1188 GPUMemCpy(RecoStep::TPCClusterFinding, (void*)&tmpNativeClusters[nClsFirst], (const void*)&mInputsShadow->mPclusterNativeBuffer[nClsFirst], (nClsTotal - nClsFirst) * sizeof(tmpNativeClusters[0]), mRec->NStreams() - 1, false);
1189 }
1190 }
1191
1192 if (mWaitForFinalInputs && iSectorBase >= 21 && (int32_t)iSectorBase < 21 + GetProcessingSettings().nTPCClustererLanes) {
1193 notifyForeignChainFinished();
1194 }
1195 if (mWaitForFinalInputs && iSectorBase >= 30 && (int32_t)iSectorBase < 30 + GetProcessingSettings().nTPCClustererLanes) {
1196 mWaitForFinalInputs();
1197 synchronizeCalibUpdate = DoQueuedUpdates(0, false);
1198 }
1199 }
1200 for (int32_t i = 0; i < GetProcessingSettings().nTPCClustererLanes; i++) {
1201#ifdef GPUCA_HAS_ONNX
1202 if (GetProcessingSettings().nn.applyNNclusterizer) {
1203 LOG(info) << "(ORT) Environment releasing...";
1204 GPUTPCNNClusterizerHost& nnApplication = nnApplications[i];
1205 nnApplication.mModelClass.release(true);
1206 nnApplication.mModelReg1.release(true);
1207 nnApplication.mModelReg2.release(true);
1208 }
1209#endif
1210 if (transferRunning[i]) {
1211 ReleaseEvent(mEvents->stream[i], doGPU);
1212 }
1213 }
1214
1215 if (GetProcessingSettings().param.tpcTriggerHandling) {
1217 if (triggerOutput && triggerOutput->allocator) {
1218 // GPUInfo("Storing %lu trigger words", mTriggerBuffer->triggers.size());
1219 auto* outputBuffer = (decltype(mTriggerBuffer->triggers)::value_type*)triggerOutput->allocator(mTriggerBuffer->triggers.size() * sizeof(decltype(mTriggerBuffer->triggers)::value_type));
1220 std::copy(mTriggerBuffer->triggers.begin(), mTriggerBuffer->triggers.end(), outputBuffer);
1221 }
1222 mTriggerBuffer->triggers.clear();
1223 }
1224
1225 ClusterNativeAccess::ConstMCLabelContainerView* mcLabelsConstView = nullptr;
1226 if (propagateMCLabels) {
1227 // TODO: write to buffer directly
1229 std::pair<ConstMCLabelContainer*, ConstMCLabelContainerView*> buffer;
1232 throw std::runtime_error("Cluster MC Label buffer missing");
1233 }
1235 buffer = {&container->first, &container->second};
1236 } else {
1237 mIOMem.clusterNativeMCView = std::make_unique<ConstMCLabelContainerView>();
1238 mIOMem.clusterNativeMCBuffer = std::make_unique<ConstMCLabelContainer>();
1239 buffer.first = mIOMem.clusterNativeMCBuffer.get();
1240 buffer.second = mIOMem.clusterNativeMCView.get();
1241 }
1242
1243 assert(propagateMCLabels ? mcLinearLabels.header.size() == nClsTotal : true);
1244 assert(propagateMCLabels ? mcLinearLabels.data.size() >= nClsTotal : true);
1245
1246 mcLabels.setFrom(mcLinearLabels.header, mcLinearLabels.data);
1247 mcLabels.flatten_to(*buffer.first);
1248 *buffer.second = *buffer.first;
1249 mcLabelsConstView = buffer.second;
1250 }
1251
1252 if (buildNativeHost && buildNativeGPU && GetProcessingSettings().delayedOutput) {
1253 mInputsHost->mNClusterNative = mInputsShadow->mNClusterNative = nClsTotal;
1255 tmpNativeClusters = mInputsHost->mPclusterNativeOutput;
1256 for (uint32_t i = outputQueueStart; i < mOutputQueue.size(); i++) {
1257 mOutputQueue[i].dst = (char*)tmpNativeClusters + (size_t)mOutputQueue[i].dst;
1258 }
1259 }
1260
1261 if (buildNativeHost) {
1262 tmpNativeAccess->clustersLinear = tmpNativeClusters;
1263 tmpNativeAccess->clustersMCTruth = mcLabelsConstView;
1264 tmpNativeAccess->setOffsetPtrs();
1265 mIOPtrs.clustersNative = tmpNativeAccess;
1266 if (GetProcessingSettings().tpcApplyClusterFilterOnCPU) {
1267 auto allocator = [this, &tmpNativeClusters](size_t size) {
1268 this->mInputsHost->mNClusterNative = size;
1269 this->AllocateRegisteredMemory(this->mInputsHost->mResourceClusterNativeOutput, this->mSubOutputControls[GPUTrackingOutputs::getIndex(&GPUTrackingOutputs::clustersNative)]);
1270 return (tmpNativeClusters = this->mInputsHost->mPclusterNativeOutput);
1271 };
1272 RunTPCClusterFilter(tmpNativeAccess, allocator, false);
1273 nClsTotal = tmpNativeAccess->nClustersTotal;
1274 }
1275 }
1276
1277 if (!mWaitForFinalInputs) {
1278 notifyForeignChainFinished();
1279 }
1280
1281 if (buildNativeGPU) {
1282 processorsShadow()->ioPtrs.clustersNative = mInputsShadow->mPclusterNativeAccess;
1283 WriteToConstantMemory(RecoStep::TPCClusterFinding, (char*)&processors()->ioPtrs - (char*)processors(), &processorsShadow()->ioPtrs, sizeof(processorsShadow()->ioPtrs), 0);
1284 *mInputsHost->mPclusterNativeAccess = *mIOPtrs.clustersNative;
1285 mInputsHost->mPclusterNativeAccess->clustersLinear = mInputsShadow->mPclusterNativeBuffer;
1286 mInputsHost->mPclusterNativeAccess->setOffsetPtrs();
1287 TransferMemoryResourceLinkToGPU(RecoStep::TPCClusterFinding, mInputsHost->mResourceClusterNativeAccess, 0);
1288 }
1289 if (doGPU && synchronizeOutput) {
1291 }
1292 if (doGPU && synchronizeCalibUpdate) {
1294 }
1295 if (buildNativeHost && (GetProcessingSettings().deterministicGPUReconstruction || GetProcessingSettings().debugLevel >= 4)) {
1296 for (uint32_t i = 0; i < NSECTORS; i++) {
1297 for (uint32_t j = 0; j < GPUCA_ROW_COUNT; j++) {
1298 std::sort(&tmpNativeClusters[tmpNativeAccess->clusterOffset[i][j]], &tmpNativeClusters[tmpNativeAccess->clusterOffset[i][j] + tmpNativeAccess->nClusters[i][j]]);
1299 }
1300 }
1301 if (buildNativeGPU) {
1302 GPUMemCpy(RecoStep::TPCClusterFinding, (void*)mInputsShadow->mPclusterNativeBuffer, (const void*)tmpNativeClusters, nClsTotal * sizeof(tmpNativeClusters[0]), -1, true);
1303 }
1304 }
1305 mRec->MemoryScalers()->nTPCHits = nClsTotal;
1306 mRec->PopNonPersistentMemory(RecoStep::TPCClusterFinding, qStr2Tag("TPCCLUST"));
1307 if (mPipelineNotifyCtx) {
1309 mPipelineNotifyCtx = nullptr;
1310 }
1311
1312 if (GetProcessingSettings().autoAdjustHostThreads && !doGPU) {
1314 }
1315
1316#endif
1317 return 0;
1318}
Definition of the TPC Digit.
int32_t i
#define TPC_MAX_TIME_BIN_TRIGGERED
#define GPUCA_MAX_STREAMS
int32_t retVal
bool o
#define GPUCA_ROW_COUNT
std::enable_if_t< std::is_signed< T >::value, bool > hasData(const CalArray< T > &cal)
Definition Painter.cxx:515
uint32_t j
Definition RawData.h:0
uint8_t endpoint
Definition RawData.h:0
Definitions of TPC Zero Suppression Data Headers.
void Start()
Definition timer.cxx:57
void Stop()
Definition timer.cxx:69
A container to hold and manage MC truth information/labels.
void setFrom(std::vector< MCTruthHeaderElement > &header, std::vector< TruthElement > &truthArray)
size_t flatten_to(ContainerType &container) const
std::unique_ptr< o2::tpc::ClusterNativeAccess > mClusterNativeAccess
int32_t RunTPCClusterizer(bool synchronizeOutput=true)
std::unique_ptr< GPUTrackingInputProvider > mInputsHost
std::array< GPUOutputControl *, GPUTrackingOutputs::count()> mSubOutputControls
std::unique_ptr< std::ofstream > mDebugFile
std::unique_ptr< GPUTriggerOutputs > mTriggerBuffer
std::vector< outputQueueEntry > mOutputQueue
std::unique_ptr< GPUTPCCFChainContext > mCFContext
int32_t DoQueuedUpdates(int32_t stream, bool updateSlave=true)
std::unique_ptr< GPUNewCalibValues > mNewCalibValues
GPUTrackingInOutPointers & mIOPtrs
struct o2::gpu::GPUChainTracking::InOutMemory mIOMem
std::unique_ptr< GPUTrackingInputProvider > mInputsShadow
void RecordMarker(deviceEvent *ev, int32_t stream)
Definition GPUChain.h:108
void TransferMemoryResourceLinkToGPU(RecoStep step, int16_t res, int32_t stream=-1, deviceEvent *ev=nullptr, deviceEvent *evList=nullptr, int32_t nEvents=1)
Definition GPUChain.h:124
void GPUMemCpyAlways(RecoStep step, void *dst, const void *src, size_t size, int32_t stream, int32_t toGPU, deviceEvent *ev=nullptr, deviceEvent *evList=nullptr, int32_t nEvents=1)
Definition GPUChain.h:129
void GPUMemCpy(RecoStep step, void *dst, const void *src, size_t size, int32_t stream, int32_t toGPU, deviceEvent *ev=nullptr, deviceEvent *evList=nullptr, int32_t nEvents=1)
Definition GPUChain.h:128
bool DoDebugAndDump(RecoStep step, uint32_t mask, T &processor, S T::*func, Args &&... args)
Definition GPUChain.h:230
GPUReconstruction::RecoStepField GetRecoStepsGPU() const
Definition GPUChain.h:72
void WriteToConstantMemory(RecoStep step, size_t offset, const void *src, size_t size, int32_t stream=-1, deviceEvent *ev=nullptr)
Definition GPUChain.h:127
void ReleaseEvent(deviceEvent ev, bool doGPU=true)
Definition GPUChain.h:111
size_t AllocateRegisteredMemory(GPUProcessor *proc)
Definition GPUChain.h:217
virtual std::unique_ptr< GPUReconstructionProcessing::threadContext > GetThreadContext()
Definition GPUChain.h:109
GPUConstantMem * processors()
Definition GPUChain.h:84
static constexpr krnlRunRange krnlRunRangeNone
Definition GPUChain.h:41
void SetONNXGPUStream(Ort::SessionOptions &opt, int32_t stream, int32_t *deviceId)
Definition GPUChain.h:90
GPUParam & param()
Definition GPUChain.h:87
void SetupGPUProcessor(T *proc, bool allocate)
Definition GPUChain.h:220
const GPUSettingsProcessing & GetProcessingSettings() const
Definition GPUChain.h:76
void SynchronizeStream(int32_t stream)
Definition GPUChain.h:89
GPUReconstructionCPU * mRec
Definition GPUChain.h:79
GPUConstantMem * processorsShadow()
Definition GPUChain.h:85
krnlExec GetGridAutoStep(int32_t stream, GPUDataTypes::RecoStep st=GPUDataTypes::RecoStep::NoRecoStep)
Definition GPUChain.cxx:47
static constexpr int32_t NSECTORS
Definition GPUChain.h:58
void TransferMemoryResourceLinkToHost(RecoStep step, int16_t res, int32_t stream=-1, deviceEvent *ev=nullptr, deviceEvent *evList=nullptr, int32_t nEvents=1)
Definition GPUChain.h:125
void TransferMemoryResourcesToHost(RecoStep step, GPUProcessor *proc, int32_t stream=-1, bool all=false)
Definition GPUChain.h:123
krnlExec GetGrid(uint32_t totalItems, uint32_t nThreads, int32_t stream, GPUReconstruction::krnlDeviceType d=GPUReconstruction::krnlDeviceType::Auto, GPUDataTypes::RecoStep st=GPUDataTypes::RecoStep::NoRecoStep)
Definition GPUChain.cxx:21
krnlExec GetGridBlk(uint32_t nBlocks, int32_t stream, GPUReconstruction::krnlDeviceType d=GPUReconstruction::krnlDeviceType::Auto, GPUDataTypes::RecoStep st=GPUDataTypes::RecoStep::NoRecoStep)
Definition GPUChain.cxx:32
GPUReconstruction * rec()
Definition GPUChain.h:66
HighResTimer & getGeneralStepTimer(GeneralStep step)
void runParallelOuterLoop(bool doGPU, uint32_t nThreads, std::function< void(uint32_t)> lambda)
const GPUDefParameters & getGPUParameters(bool doGPU) const override
void AllocateRegisteredForeignMemory(int16_t res, GPUReconstruction *rec, GPUOutputControl *control=nullptr)
void PopNonPersistentMemory(RecoStep step, uint64_t tag)
void ComputeReuseMax(GPUProcessor *proc)
RecoStepField GetRecoStepsGPU() const
const GPUParam & GetParam() const
void PushNonPersistentMemory(uint64_t tag)
InOutTypeField GetRecoStepsOutputs() const
GPUMemorySizeScalers * MemoryScalers()
static void setGlobalOffsetsAndAllocate(GPUTPCClusterFinder &, GPUTPCLinearLabels &)
void SetMaxData(const GPUTrackingInOutPointers &io)
void SetNMaxDigits(size_t nDigits, size_t nPages, size_t nDigitsFragment, size_t nDigitsEndpointMax)
void DumpSuppressedPeaks(std::ostream &out)
void DumpPeakMap(std::ostream &out, std::string_view)
o2::dataformats::ConstMCTruthContainerView< o2::MCCompLabel > const * mPinputLabels
void DumpChargeMap(std::ostream &out, std::string_view)
uint32_t getNSteps(size_t items) const
void DumpSuppressedPeaksCompacted(std::ostream &out)
void DumpPeaksCompacted(std::ostream &out)
tpc::ClusterNative * mPclusterByRow
void initClusterizer(const GPUSettingsProcessingNNclusterizer &, GPUTPCNNClusterizer &)
void init(const GPUSettingsProcessingNNclusterizer &)
OrtDataType::Float16_t * mInputData_16
OrtDataType::Float16_t * mOutputDataReg2_16
OrtDataType::Float16_t * mModelProbabilities_16
OrtDataType::Float16_t * mOutputDataReg1_16
void release(bool=false)
void setIntraOpNumThreads(int threads)
std::vector< std::vector< int64_t > > getNumOutputNodes() const
#define TPC_PADS_IN_SECTOR
GLint GLenum GLint x
Definition glcorearb.h:403
const GLfloat * m
Definition glcorearb.h:4066
GLenum src
Definition glcorearb.h:1767
GLint GLsizei count
Definition glcorearb.h:399
GLuint buffer
Definition glcorearb.h:655
GLsizeiptr size
Definition glcorearb.h:659
GLdouble f
Definition glcorearb.h:310
GLboolean * data
Definition glcorearb.h:298
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLenum GLfloat param
Definition glcorearb.h:271
uint8_t itsSharedClusterMap uint8_t
constexpr int LHCMaxBunches
Definition of a container to keep/associate and arbitrary number of labels associated to an index wit...
RAWDataHeaderV7 RAWDataHeader
void dumpBuffer(gsl::span< const std::byte > buffer, std::ostream &out=std::cout, size_t maxbytes=std::numeric_limits< size_t >::max())
Definition DumpBuffer.h:139
constexpr int LHCBCPERTIMEBIN
Definition Constants.h:38
constexpr int MAXGLOBALPADROW
Definition Constants.h:34
Global TPC definitions and constants.
Definition SimTraits.h:167
@ ZSVersionDenseLinkBased
@ ZSVersionLinkBasedWithMeta
@ ZSVersionRowBased10BitADC
@ ZSVersionRowBased12BitADC
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
constexpr T qStr2Tag(const char *str)
Definition strtag.h:22
tpccf::TPCTime start
Definition CfFragment.h:31
std::unique_ptr< o2::dataformats::ConstMCTruthContainerView< o2::MCCompLabel > > clusterNativeMCView
std::unique_ptr< o2::dataformats::ConstMCTruthContainer< o2::MCCompLabel > > clusterNativeMCBuffer
deviceEvent stream[GPUCA_MAX_STREAMS]
GPUTPCClusterFinder tpcClusterer[GPUCA_NSECTORS]
GPUTrackingInOutPointers ioPtrs
size_t NTPCClusters(size_t tpcDigits, bool perSector=false)
std::function< void *(size_t)> allocator
struct o2::gpu::GPUTPCClusterFinder::Memory::counters_t counters
std::vector< o2::MCCompLabel > data
std::vector< o2::dataformats::MCTruthHeaderElement > header
const GPUTPCDigitsMCInput * tpcDigitsMC
const o2::tpc::ClusterNativeAccess * clustersNative
const GPUSettingsTF * settingsTF
const GPUTrackingInOutZS * tpcZS
const GPUTrackingInOutDigits * tpcPackedDigits
GPUTrackingInOutZSSector sector[NSECTORS]
static constexpr uint32_t NENDPOINTS
size_t getIndex(const GPUOutputControl &v)
static constexpr int getVersion()
get numeric version of the RDH
Definition RDHUtils.h:60
unsigned int nClusters[constants::MAXSECTOR][constants::MAXGLOBALPADROW]
const o2::dataformats::ConstMCTruthContainerView< o2::MCCompLabel > * clustersMCTruth
std::pair< ConstMCLabelContainer, ConstMCLabelContainerView > ConstMCLabelContainerViewWithBuffer
unsigned int clusterOffset[constants::MAXSECTOR][constants::MAXGLOBALPADROW]
const ClusterNative * clustersLinear
static constexpr unsigned int TRIGGER_WORD_SIZE
unsigned char version
static constexpr size_t TPC_ZS_PAGE_SIZE
unsigned short nADCsamples
Trigger info including the orbit.
uint32_t orbit
orbit of the trigger word
TriggerWordDLBZS triggerWord
trigger Word information
bool isValid(int entry=0) const
constexpr size_t min
constexpr size_t max
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits