26 this->mTaskArena->execute([&] {
27 mTimeFrameGPU->initialise(this->mTrkParams[iteration], this->mTrkParams[iteration].NLayers, iteration);
30 mTimeFrameGPU->loadIterationParameters(this->mTrkParams[iteration]);
34 mTimeFrameGPU->loadVertices();
36 mTimeFrameGPU->loadROFOverlapTable();
37 mTimeFrameGPU->loadROFVertexLookupTable();
38 mTimeFrameGPU->loadTrackingTopologies();
41 mTimeFrameGPU->loadIndexTableUtils();
43 mTimeFrameGPU->createUsedClustersDeviceArray();
44 mTimeFrameGPU->createClustersDeviceArray();
45 mTimeFrameGPU->createUnsortedClustersDeviceArray();
46 mTimeFrameGPU->createClustersIndexTablesArray();
47 mTimeFrameGPU->createTrackingFrameInfoDeviceArray();
48 mTimeFrameGPU->createROFrameClustersDeviceArray();
50 mTimeFrameGPU->createTrackletsLUTDeviceArray();
51 mTimeFrameGPU->createTrackletsBuffersArray();
52 mTimeFrameGPU->createCellsBuffersArray();
53 mTimeFrameGPU->createCellsLUTDeviceArray();
56 mTimeFrameGPU->loadROFCutMask(iteration);
70 const auto topology = mTimeFrameGPU->getDeviceTrackingTopologyView();
73 for (
int iLayer{0}; iLayer < this->mTrkParams[iteration].NLayers; ++iLayer) {
74 if (loadFirstPassData) {
75 mTimeFrameGPU->createUsedClustersDevice(iLayer);
76 mTimeFrameGPU->loadClustersDevice(iLayer);
77 mTimeFrameGPU->loadClustersIndexTables(iLayer);
78 mTimeFrameGPU->loadROFrameClustersDevice(iLayer);
80 mTimeFrameGPU->recordEvent(iLayer);
83 for (
int linkId{0}; linkId < hostTopology.nLinks; ++linkId) {
84 mTimeFrameGPU->createTrackletsLUTDevice(loadFirstPassData, linkId);
89 mTimeFrameGPU->pushMemoryStack(iteration);
91 const auto nClusters = mTimeFrameGPU->getClusterSizes();
92 for (
int linkId{0}; linkId < hostTopology.nLinks; ++linkId) {
93 const auto link = hostTopology.getLink(linkId);
94 mTimeFrameGPU->waitEvent(linkId,
link.fromLayer);
95 mTimeFrameGPU->waitEvent(linkId,
link.toLayer);
97 const auto scale =
static_cast<double>(
nClusters[
link.fromLayer]);
98 runOnSlab(mTimeFrameGPU->getCapacityEstimator(),
key, scale, [&](
const int capacity) {
99 mTimeFrameGPU->createTrackletsBuffers(linkId, capacity);
100 return TrackingKernels<NLayers>::computeTrackletsInROFsHandler(mTimeFrameGPU->getDeviceIndexTableUtils(),
101 mTimeFrameGPU->getDeviceROFMaskTableView(),
105 mTimeFrameGPU->getDeviceROFOverlapTableView(),
106 mTimeFrameGPU->getDeviceROFVertexLookupTableView(),
108 mTimeFrameGPU->getDeviceVertices(),
109 mTimeFrameGPU->getDeviceArrayClusters(),
111 mTimeFrameGPU->getDeviceROFrameClusters(),
112 (const uint8_t**)mTimeFrameGPU->getDeviceArrayUsedClusters(),
113 mTimeFrameGPU->getDeviceArrayClustersIndexTables(),
114 mTimeFrameGPU->getDeviceArrayTracklets(),
115 mTimeFrameGPU->getDeviceTracklets(),
116 mTimeFrameGPU->getNTracklets(),
118 mTimeFrameGPU->getDeviceTrackletsLUTs(),
119 this->mTrkParams[iteration].PassFlags[IterationStep::SelectUPCVertices],
120 this->mTrkParams[iteration].NSigmaCut,
122 mTimeFrameGPU->getLinkPhiCuts(),
123 this->mTrkParams[iteration].PVres,
124 mTimeFrameGPU->getMinRs(),
125 mTimeFrameGPU->getMaxRs(),
126 mTimeFrameGPU->getPositionResolutions(),
127 this->mTrkParams[iteration].LayerRadii,
128 mTimeFrameGPU->getLinkMSAngles(),
129 mTimeFrameGPU->getFrameworkAllocator(),
130 mTimeFrameGPU->getStreams());
132 mTimeFrameGPU->recordEvent(linkId);
139 const auto topology = mTimeFrameGPU->getDeviceTrackingTopologyView();
140 const auto hostTopology = mTimeFrameGPU->getTrackingTopologyView();
141 for (
int iLayer{0}; iLayer < this->mTrkParams[iteration].NLayers; ++iLayer) {
143 mTimeFrameGPU->loadUnsortedClustersDevice(iLayer);
144 mTimeFrameGPU->loadTrackingFrameInfoDevice(iLayer);
146 mTimeFrameGPU->recordEvent(iLayer);
149 for (
int cellTopologyId{hostTopology.nCells}; cellTopologyId--;) {
150 const auto cellTopology = hostTopology.getCell(cellTopologyId);
151 const auto first = hostTopology.getLink(cellTopology.firstLink);
152 const auto second = hostTopology.getLink(cellTopology.secondLink);
153 const int currentLayerTrackletsNum{
static_cast<int>(mTimeFrameGPU->getNTracklets()[cellTopology.firstLink])};
154 if (!currentLayerTrackletsNum || !mTimeFrameGPU->getNTracklets()[cellTopology.secondLink]) {
155 mTimeFrameGPU->getNCells()[cellTopologyId] = 0;
159 mTimeFrameGPU->createCellsLUTDevice(cellTopologyId);
160 mTimeFrameGPU->waitEvent(cellTopologyId, cellTopology.firstLink);
161 mTimeFrameGPU->waitEvent(cellTopologyId, cellTopology.secondLink);
162 mTimeFrameGPU->waitEvent(cellTopologyId,
first.fromLayer);
163 mTimeFrameGPU->waitEvent(cellTopologyId,
first.toLayer);
164 mTimeFrameGPU->waitEvent(cellTopologyId, second.toLayer);
166 const auto scale =
static_cast<double>(currentLayerTrackletsNum);
167 const int emitted =
runOnSlab(mTimeFrameGPU->getCapacityEstimator(),
key, scale, [&](
const int capacity) {
168 mTimeFrameGPU->createCellsBuffers(cellTopologyId, capacity);
169 return TrackingKernels<NLayers>::computeCellsHandler(mTimeFrameGPU->getDeviceArrayClusters(),
170 mTimeFrameGPU->getDeviceArrayUnsortedClusters(),
171 mTimeFrameGPU->getDeviceArrayTrackingFrameInfo(),
172 mTimeFrameGPU->getDeviceArrayTracklets(),
173 mTimeFrameGPU->getDeviceArrayTrackletsLUT(),
174 currentLayerTrackletsNum,
177 mTimeFrameGPU->getDeviceCells()[cellTopologyId],
179 mTimeFrameGPU->getDeviceCellLUTs()[cellTopologyId],
181 this->mTrkParams[iteration].MaxChi2ClusterAttachment,
182 this->mTrkParams[iteration].CellDeltaTanLambdaSigma,
183 this->mTrkParams[iteration].NSigmaCut,
184 mTimeFrameGPU->getDeviceLayerxX0(),
185 mTimeFrameGPU->getFrameworkAllocator(),
186 mTimeFrameGPU->getStreams());
188 mTimeFrameGPU->getNCells()[cellTopologyId] = emitted;
189 mTimeFrameGPU->recordEvent(cellTopologyId);
191 mTimeFrameGPU->syncStreams(
false);
197 const auto hostTopology = mTimeFrameGPU->getTrackingTopologyView();
199 sourceTopologies.reserve(hostTopology.nCells);
200 for (
int outerLayer{0}; outerLayer < NLayers; ++outerLayer) {
201 for (
int targetCellTopologyId{0}; targetCellTopologyId < hostTopology.nCells; ++targetCellTopologyId) {
202 const auto targetCellTopology = hostTopology.getCell(targetCellTopologyId);
203 if (targetCellTopology.hitLayerMask.last() != outerLayer) {
206 const int targetCellsNum{
static_cast<int>(mTimeFrameGPU->getNCells()[targetCellTopologyId])};
207 sourceTopologies.clear();
208 size_t sourceCellCount{0};
209 for (
int sourceCellTopologyId{0}; sourceCellTopologyId < hostTopology.nCells; ++sourceCellTopologyId) {
210 const auto sourceCellTopology = hostTopology.getCell(sourceCellTopologyId);
211 const int sourceCellsNum{
static_cast<int>(mTimeFrameGPU->getNCells()[sourceCellTopologyId])};
212 if (!sourceCellsNum || sourceCellTopology.secondLink != targetCellTopology.firstLink) {
215 sourceTopologies.push_back(sourceCellTopologyId);
216 sourceCellCount += sourceCellsNum;
218 if (!targetCellsNum || sourceTopologies.empty()) {
219 mTimeFrameGPU->getNNeighbours()[targetCellTopologyId] = 0;
220 mTimeFrameGPU->createNeighboursDevice(targetCellTopologyId, 0);
221 mTimeFrameGPU->recordEvent(targetCellTopologyId);
224 mTimeFrameGPU->createNeighboursLUTDevice(targetCellTopologyId, targetCellsNum);
225 auto&
stream = mTimeFrameGPU->getStream(targetCellTopologyId);
226 int* outputCounter = mTimeFrameGPU->getDeviceNeighboursLUT(targetCellTopologyId) + targetCellsNum;
229 const auto scale =
static_cast<double>(sourceCellCount);
230 const int emitted =
runOnSlab(mTimeFrameGPU->getCapacityEstimator(),
key, scale, [&](
const int capacity) {
231 mTimeFrameGPU->createNeighboursDevice(targetCellTopologyId, capacity);
232 resetOutputCounterHandler(outputCounter, stream);
233 for (const int sourceCellTopologyId : sourceTopologies) {
234 mTimeFrameGPU->waitEvent(targetCellTopologyId, sourceCellTopologyId);
235 TrackingKernels<NLayers>::computeCellNeighboursHandler(mTimeFrameGPU->getDeviceArrayCells(),
236 mTimeFrameGPU->getDeviceArrayCellsLUT(),
237 mTimeFrameGPU->getDeviceNeighbours(targetCellTopologyId),
240 sourceCellTopologyId,
241 targetCellTopologyId,
242 this->mTrkParams[iteration].MaxChi2ClusterAttachment,
244 mTimeFrameGPU->getNCells()[sourceCellTopologyId],
245 mTimeFrameGPU->getFrameworkAllocator(),
249 mTimeFrameGPU->getDeviceNeighboursLUT(targetCellTopologyId),
252 mTimeFrameGPU->getFrameworkAllocator(),
255 mTimeFrameGPU->getNNeighbours()[targetCellTopologyId] = emitted;
256 mTimeFrameGPU->recordEvent(targetCellTopologyId);
259 mTimeFrameGPU->syncStreams(
false);
266 firstClusters.resize(this->mTrkParams[iteration].NLayers);
267 const auto hostTopology = mTimeFrameGPU->getTrackingTopologyView();
268 const bool extendTop = this->mTrkParams[iteration].PassFlags[IterationStep::TrackFollowerTop];
269 const bool extendBot = this->mTrkParams[iteration].PassFlags[IterationStep::TrackFollowerBot];
271 for (
int startLevel{this->mTrkParams[iteration].CellsPerRoad()}; startLevel >= this->mTrkParams[iteration].CellMinimumLevel(); --startLevel) {
273 size_t startCells{0};
274 for (
int startCellTopologyId{0}; startCellTopologyId < hostTopology.nCells; ++startCellTopologyId) {
275 const int startLayer = hostTopology.getCell(startCellTopologyId).hitLayerMask.last();
276 if (this->mTrkParams[iteration].StartLayerMask.has(startLayer)) {
277 startCells += mTimeFrameGPU->getNCells()[startCellTopologyId];
283 const auto key = CapacityEstimator::makeKey(SlabSite::TrackSeeds, iteration, startLevel, 0);
284 auto& estimator = mTimeFrameGPU->getCapacityEstimator();
285 const int nSeeds =
runOnSlab(estimator,
key,
static_cast<double>(startCells), [&](
const int capacity) {
286 mTimeFrameGPU->createTrackSeedsDevice(capacity);
288 for (
int startCellTopologyId{0}; startCellTopologyId < hostTopology.nCells; ++startCellTopologyId) {
289 const int startLayer = hostTopology.getCell(startCellTopologyId).hitLayerMask.last();
290 if (!(this->mTrkParams[iteration].StartLayerMask.has(startLayer)) || mTimeFrameGPU->getNCells()[startCellTopologyId] == 0) {
295 mTimeFrameGPU->getDeviceArrayCells(),
296 mTimeFrameGPU->getDeviceCells()[startCellTopologyId],
299 mTimeFrameGPU->getArrayNCells().data(),
300 (
const uint8_t**)mTimeFrameGPU->getDeviceArrayUsedClusters(),
301 mTimeFrameGPU->getDeviceArrayNeighbours(),
302 mTimeFrameGPU->getDeviceArrayNeighboursCellLUT(),
303 mTimeFrameGPU->getDeviceArrayTrackingFrameInfo(),
304 mTimeFrameGPU->getDeviceTrackSeeds(),
307 mTimeFrameGPU->getCapacityEstimator(),
310 this->mTrkParams[iteration].MaxChi2ClusterAttachment,
311 this->mTrkParams[iteration].MaxChi2NDF,
312 this->mTrkParams[iteration].MaxHoles,
313 this->mTrkParams[iteration].getMinSeedingClusters(),
314 this->mTrkParams[iteration].HoleLayerMask,
315 this->mTrkParams[iteration].getNonSeedingLayerMask(),
316 mTimeFrameGPU->getDeviceLayerxX0(),
317 mTimeFrameGPU->getDevicePropagator(),
318 this->mTrkParams[iteration].CorrType,
319 mTimeFrameGPU->getFrameworkAllocator());
321 return cursor; }, estimator.peakCapacity(
key));
323 LOGP(
debug,
"No track seeds found, skipping track finding");
327 mTimeFrameGPU->createTrackExtensionScratchDevice(gpu::gridThreads(gpu::ResidentBlocks.fitTrackSeedsExtended),
328 this->mTrkParams[iteration].TrackFollowerMaxHypotheses);
330 const auto trackKey = CapacityEstimator::makeKey(extendTracks ? SlabSite::TracksExtended : SlabSite::Tracks,
331 iteration, startLevel, 0);
332 const int nTracks =
runOnSlab(estimator, trackKey,
static_cast<double>(nSeeds), [&](
const int capacity) {
333 mTimeFrameGPU->createTrackITSExtDevice(capacity);
335 mTimeFrameGPU->getDeviceArrayTrackingFrameInfo(),
336 mTimeFrameGPU->getDeviceArrayUnsortedClusters(),
337 mTimeFrameGPU->getDeviceIndexTableUtils(),
338 mTimeFrameGPU->getDeviceROFMaskTableView(),
339 mTimeFrameGPU->getDeviceROFOverlapTableView(),
340 mTimeFrameGPU->getDeviceArrayClusters(),
341 (
const unsigned char**)mTimeFrameGPU->getDeviceArrayUsedClusters(),
342 mTimeFrameGPU->getDeviceArrayClustersIndexTables(),
343 mTimeFrameGPU->getDeviceROFrameClusters(),
344 mTimeFrameGPU->getDeviceTrackITSExt(),
345 mTimeFrameGPU->getDeviceTrackIndices(),
346 mTimeFrameGPU->getDeviceTrackSeedIndices(),
347 mTimeFrameGPU->getDeviceTrackCounter(),
349 extendTracks ? mTimeFrameGPU->getDeviceActiveTrackExtensionHypotheses() :
nullptr,
350 extendTracks ? mTimeFrameGPU->getDeviceNextTrackExtensionHypotheses() :
nullptr,
351 mTimeFrameGPU->getDeviceLayerRadii(),
352 mTimeFrameGPU->getDeviceMinPts(),
353 mTimeFrameGPU->getDeviceLayerxX0(),
354 static_cast<unsigned int>(nSeeds),
356 this->mTrkParams[iteration].MaxChi2ClusterAttachment,
357 this->mTrkParams[iteration].MaxChi2NDF,
358 this->mTrkParams[iteration].ReseedIfShorter,
359 this->mTrkParams[iteration].RepeatRefitOut,
360 this->mTrkParams[iteration].ShiftRefToCluster,
361 this->mTrkParams[iteration].NLayers,
362 this->mTrkParams[iteration].PhiBins,
363 this->mTrkParams[iteration].TrackFollowerMaxHypotheses,
366 this->mTrkParams[iteration].TrackFollowerNSigmaCutPhi,
367 this->mTrkParams[iteration].TrackFollowerNSigmaCutZ,
368 mTimeFrameGPU->getDevicePropagator(),
369 this->mTrkParams[iteration].CorrType,
370 mTimeFrameGPU->getFrameworkAllocator()); }, estimator.peakCapacity(trackKey));
371 mTimeFrameGPU->createTrackITSExtHost(nTracks);
372 mTimeFrameGPU->downloadTrackITSExtDevice();
374 auto& tracks = mTimeFrameGPU->getTrackITSExt();
375 const auto& trackIndices = mTimeFrameGPU->getTrackIndices();
376 this->acceptTracks(iteration, tracks, trackIndices, firstClusters);
377 mTimeFrameGPU->loadUsedClustersDevice();
379 this->markTracks(iteration);
381 mTimeFrameGPU->popMemoryStack(iteration);