29 this->mTaskArena->execute([&] {
30 mTimeFrameGPU->initialise(this->mTrkParams[iteration], this->mTrkParams[iteration].NLayers, iteration);
33 mTimeFrameGPU->loadIterationParameters(this->mTrkParams[iteration]);
37 mTimeFrameGPU->loadVertices();
39 mTimeFrameGPU->loadROFOverlapTable();
40 mTimeFrameGPU->loadROFVertexLookupTable();
41 mTimeFrameGPU->loadTrackingTopologies();
44 mTimeFrameGPU->loadIndexTableUtils();
46 mTimeFrameGPU->createUsedClustersDeviceArray();
47 mTimeFrameGPU->createClustersDeviceArray();
48 mTimeFrameGPU->createUnsortedClustersDeviceArray();
49 mTimeFrameGPU->createClustersIndexTablesArray();
50 mTimeFrameGPU->createTrackingFrameInfoDeviceArray();
51 mTimeFrameGPU->createROFrameClustersDeviceArray();
53 mTimeFrameGPU->createTrackletsLUTDeviceArray();
54 mTimeFrameGPU->createTrackletsBuffersArray();
55 mTimeFrameGPU->createCellsBuffersArray();
56 mTimeFrameGPU->createCellsLUTDeviceArray();
59 mTimeFrameGPU->loadROFCutMask(iteration);
73 const auto topology = mTimeFrameGPU->getDeviceTrackingTopologyView();
76 for (
int iLayer{0}; iLayer < this->mTrkParams[iteration].NLayers; ++iLayer) {
77 if (loadFirstPassData) {
78 mTimeFrameGPU->createUsedClustersDevice(iLayer);
79 mTimeFrameGPU->loadClustersDevice(iLayer);
80 mTimeFrameGPU->loadClustersIndexTables(iLayer);
81 mTimeFrameGPU->loadROFrameClustersDevice(iLayer);
83 mTimeFrameGPU->recordEvent(iLayer);
86 for (
int linkId{0}; linkId < hostTopology.nLinks; ++linkId) {
87 mTimeFrameGPU->createTrackletsLUTDevice(loadFirstPassData, linkId);
92 mTimeFrameGPU->pushMemoryStack(iteration);
94 const auto nClusters = mTimeFrameGPU->getClusterSizes();
95 for (
int linkId{0}; linkId < hostTopology.nLinks; ++linkId) {
96 const auto link = hostTopology.getLink(linkId);
97 mTimeFrameGPU->waitEvent(linkId,
link.fromLayer);
98 mTimeFrameGPU->waitEvent(linkId,
link.toLayer);
100 const auto scale =
static_cast<double>(
nClusters[
link.fromLayer]);
101 runOnSlab(mTimeFrameGPU->getCapacityEstimator(),
key, scale, [&](
const int capacity) {
102 mTimeFrameGPU->createTrackletsBuffers(linkId, capacity);
103 return TrackingKernels<NLayers>::computeTrackletsInROFsHandler(mTimeFrameGPU->getDeviceIndexTableUtils(),
104 mTimeFrameGPU->getDeviceROFMaskTableView(),
108 mTimeFrameGPU->getDeviceROFOverlapTableView(),
109 mTimeFrameGPU->getDeviceROFVertexLookupTableView(),
111 mTimeFrameGPU->getDeviceVertices(),
112 mTimeFrameGPU->getDeviceArrayClusters(),
114 mTimeFrameGPU->getDeviceROFrameClusters(),
115 (const uint8_t**)mTimeFrameGPU->getDeviceArrayUsedClusters(),
116 mTimeFrameGPU->getDeviceArrayClustersIndexTables(),
117 mTimeFrameGPU->getDeviceArrayTracklets(),
118 mTimeFrameGPU->getDeviceTracklets(),
119 mTimeFrameGPU->getNTracklets(),
121 mTimeFrameGPU->getDeviceTrackletsLUTs(),
122 this->mTrkParams[iteration].PassFlags[IterationStep::SelectUPCVertices],
123 this->mTrkParams[iteration].NSigmaCut,
125 mTimeFrameGPU->getLinkPhiCuts(),
126 this->mTrkParams[iteration].PVres,
127 mTimeFrameGPU->getMinRs(),
128 mTimeFrameGPU->getMaxRs(),
129 mTimeFrameGPU->getPositionResolutions(),
130 this->mTrkParams[iteration].LayerRadii,
131 mTimeFrameGPU->getLinkMSAngles(),
132 mTimeFrameGPU->getFrameworkAllocator(),
133 mTimeFrameGPU->getStreams());
135 mTimeFrameGPU->recordEvent(linkId);
142 const auto topology = mTimeFrameGPU->getDeviceTrackingTopologyView();
143 const auto hostTopology = mTimeFrameGPU->getTrackingTopologyView();
144 for (
int iLayer{0}; iLayer < this->mTrkParams[iteration].NLayers; ++iLayer) {
146 mTimeFrameGPU->loadUnsortedClustersDevice(iLayer);
147 mTimeFrameGPU->loadTrackingFrameInfoDevice(iLayer);
149 mTimeFrameGPU->recordEvent(iLayer);
152 for (
int cellTopologyId{hostTopology.nCells}; cellTopologyId--;) {
153 const auto cellTopology = hostTopology.getCell(cellTopologyId);
154 const auto first = hostTopology.getLink(cellTopology.firstLink);
155 const auto second = hostTopology.getLink(cellTopology.secondLink);
156 const int currentLayerTrackletsNum{
static_cast<int>(mTimeFrameGPU->getNTracklets()[cellTopology.firstLink])};
157 if (!currentLayerTrackletsNum || !mTimeFrameGPU->getNTracklets()[cellTopology.secondLink]) {
158 mTimeFrameGPU->getNCells()[cellTopologyId] = 0;
162 mTimeFrameGPU->createCellsLUTDevice(cellTopologyId);
163 mTimeFrameGPU->waitEvent(cellTopologyId, cellTopology.firstLink);
164 mTimeFrameGPU->waitEvent(cellTopologyId, cellTopology.secondLink);
165 mTimeFrameGPU->waitEvent(cellTopologyId,
first.fromLayer);
166 mTimeFrameGPU->waitEvent(cellTopologyId,
first.toLayer);
167 mTimeFrameGPU->waitEvent(cellTopologyId, second.toLayer);
169 const auto scale =
static_cast<double>(currentLayerTrackletsNum);
170 const int emitted = runOnSlab(mTimeFrameGPU->getCapacityEstimator(),
key, scale, [&](
const int capacity) {
171 mTimeFrameGPU->createCellsBuffers(cellTopologyId, capacity);
172 return TrackingKernels<NLayers>::computeCellsHandler(mTimeFrameGPU->getDeviceArrayClusters(),
173 mTimeFrameGPU->getDeviceArrayUnsortedClusters(),
174 mTimeFrameGPU->getDeviceArrayTrackingFrameInfo(),
175 mTimeFrameGPU->getDeviceArrayTracklets(),
176 mTimeFrameGPU->getDeviceArrayTrackletsLUT(),
177 currentLayerTrackletsNum,
180 mTimeFrameGPU->getDeviceCells()[cellTopologyId],
182 mTimeFrameGPU->getDeviceCellLUTs()[cellTopologyId],
184 this->mTrkParams[iteration].MaxChi2ClusterAttachment,
185 this->mTrkParams[iteration].CellDeltaTanLambdaSigma,
186 this->mTrkParams[iteration].NSigmaCut,
187 mTimeFrameGPU->getDeviceLayerxX0(),
188 mTimeFrameGPU->getFrameworkAllocator(),
189 mTimeFrameGPU->getStreams());
191 mTimeFrameGPU->getNCells()[cellTopologyId] = emitted;
192 mTimeFrameGPU->recordEvent(cellTopologyId);
194 mTimeFrameGPU->syncStreams(
false);
200 const auto hostTopology = mTimeFrameGPU->getTrackingTopologyView();
201 bounded_vector<int> sourceTopologies(this->getMemoryPool().
get());
202 sourceTopologies.reserve(hostTopology.nCells);
203 for (
int outerLayer{0}; outerLayer < NLayers; ++outerLayer) {
204 for (
int targetCellTopologyId{0}; targetCellTopologyId < hostTopology.nCells; ++targetCellTopologyId) {
205 const auto targetCellTopology = hostTopology.getCell(targetCellTopologyId);
206 if (targetCellTopology.hitLayerMask.last() != outerLayer) {
209 const int targetCellsNum{
static_cast<int>(mTimeFrameGPU->getNCells()[targetCellTopologyId])};
210 sourceTopologies.clear();
211 size_t sourceCellCount{0};
212 for (
int sourceCellTopologyId{0}; sourceCellTopologyId < hostTopology.nCells; ++sourceCellTopologyId) {
213 const auto sourceCellTopology = hostTopology.getCell(sourceCellTopologyId);
214 const int sourceCellsNum{
static_cast<int>(mTimeFrameGPU->getNCells()[sourceCellTopologyId])};
215 if (!sourceCellsNum || sourceCellTopology.secondLink != targetCellTopology.firstLink) {
218 sourceTopologies.push_back(sourceCellTopologyId);
219 sourceCellCount += sourceCellsNum;
221 if (!targetCellsNum || sourceTopologies.empty()) {
222 mTimeFrameGPU->getNNeighbours()[targetCellTopologyId] = 0;
223 mTimeFrameGPU->createNeighboursDevice(targetCellTopologyId, 0);
224 mTimeFrameGPU->recordEvent(targetCellTopologyId);
227 mTimeFrameGPU->createNeighboursLUTDevice(targetCellTopologyId, targetCellsNum);
228 auto&
stream = mTimeFrameGPU->getStream(targetCellTopologyId);
229 int* outputCounter = mTimeFrameGPU->getDeviceNeighboursLUT(targetCellTopologyId) + targetCellsNum;
232 const auto scale =
static_cast<double>(sourceCellCount);
233 const int emitted = runOnSlab(mTimeFrameGPU->getCapacityEstimator(),
key, scale, [&](
const int capacity) {
234 mTimeFrameGPU->createNeighboursDevice(targetCellTopologyId, capacity);
235 resetOutputCounterHandler(outputCounter, stream);
236 for (const int sourceCellTopologyId : sourceTopologies) {
237 mTimeFrameGPU->waitEvent(targetCellTopologyId, sourceCellTopologyId);
238 TrackingKernels<NLayers>::computeCellNeighboursHandler(mTimeFrameGPU->getDeviceArrayCells(),
239 mTimeFrameGPU->getDeviceArrayCellsLUT(),
240 mTimeFrameGPU->getDeviceNeighbours(targetCellTopologyId),
243 sourceCellTopologyId,
244 targetCellTopologyId,
245 this->mTrkParams[iteration].MaxChi2ClusterAttachment,
247 mTimeFrameGPU->getNCells()[sourceCellTopologyId],
248 mTimeFrameGPU->getFrameworkAllocator(),
252 mTimeFrameGPU->getDeviceNeighboursLUT(targetCellTopologyId),
255 mTimeFrameGPU->getFrameworkAllocator(),
258 mTimeFrameGPU->getNNeighbours()[targetCellTopologyId] = emitted;
259 mTimeFrameGPU->recordEvent(targetCellTopologyId);
262 mTimeFrameGPU->syncStreams(
false);
268 bounded_vector<bounded_vector<int>> firstClusters(this->mTrkParams[iteration].NLayers, bounded_vector<int>(this->getMemoryPool().
get()), this->getMemoryPool().
get());
269 firstClusters.resize(this->mTrkParams[iteration].NLayers);
270 const auto hostTopology = mTimeFrameGPU->getTrackingTopologyView();
271 const bool extendTop = this->mTrkParams[iteration].PassFlags[IterationStep::TrackFollowerTop];
272 const bool extendBot = this->mTrkParams[iteration].PassFlags[IterationStep::TrackFollowerBot];
274 for (
int startLevel{this->mTrkParams[iteration].CellsPerRoad()}; startLevel >= this->mTrkParams[iteration].CellMinimumLevel(); --startLevel) {
276 size_t startCells{0};
277 for (
int startCellTopologyId{0}; startCellTopologyId < hostTopology.nCells; ++startCellTopologyId) {
278 const int startLayer = hostTopology.getCell(startCellTopologyId).hitLayerMask.last();
279 if (this->mTrkParams[iteration].StartLayerMask.has(startLayer)) {
280 startCells += mTimeFrameGPU->getNCells()[startCellTopologyId];
286 const auto key = CapacityEstimator::makeKey(SlabSite::TrackSeeds, iteration, startLevel, 0);
287 auto& estimator = mTimeFrameGPU->getCapacityEstimator();
288 const int nSeeds = runOnSlab(estimator,
key,
static_cast<double>(startCells), [&](
const int capacity) {
289 mTimeFrameGPU->createTrackSeedsDevice(capacity);
291 for (
int startCellTopologyId{0}; startCellTopologyId < hostTopology.nCells; ++startCellTopologyId) {
292 const int startLayer = hostTopology.getCell(startCellTopologyId).hitLayerMask.last();
293 if (!(this->mTrkParams[iteration].StartLayerMask.has(startLayer)) || mTimeFrameGPU->getNCells()[startCellTopologyId] == 0) {
298 mTimeFrameGPU->getDeviceArrayCells(),
299 mTimeFrameGPU->getDeviceCells()[startCellTopologyId],
302 mTimeFrameGPU->getArrayNCells().data(),
303 (
const uint8_t**)mTimeFrameGPU->getDeviceArrayUsedClusters(),
304 mTimeFrameGPU->getDeviceArrayNeighbours(),
305 mTimeFrameGPU->getDeviceArrayNeighboursCellLUT(),
306 mTimeFrameGPU->getDeviceArrayTrackingFrameInfo(),
307 mTimeFrameGPU->getDeviceTrackSeeds(),
310 mTimeFrameGPU->getCapacityEstimator(),
313 this->mTrkParams[iteration].MaxChi2ClusterAttachment,
314 this->mTrkParams[iteration].MaxChi2NDF,
315 this->mTrkParams[iteration].MaxHoles,
316 this->mTrkParams[iteration].getMinSeedingClusters(),
317 this->mTrkParams[iteration].HoleLayerMask,
318 this->mTrkParams[iteration].getNonSeedingLayerMask(),
319 mTimeFrameGPU->getDeviceLayerxX0(),
320 mTimeFrameGPU->getDevicePropagator(),
321 this->mTrkParams[iteration].CorrType,
322 mTimeFrameGPU->getFrameworkAllocator());
324 return cursor; }, estimator.peakCapacity(
key));
326 LOGP(
debug,
"No track seeds found, skipping track finding");
330 mTimeFrameGPU->createTrackExtensionScratchDevice(gpu::gridThreads(gpu::ResidentBlocks.fitTrackSeedsExtended),
331 this->mTrkParams[iteration].TrackFollowerMaxHypotheses);
333 const auto trackKey = CapacityEstimator::makeKey(extendTracks ? SlabSite::TracksExtended : SlabSite::Tracks,
334 iteration, startLevel, 0);
335 const int nTracks = runOnSlab(estimator, trackKey,
static_cast<double>(nSeeds), [&](
const int capacity) {
336 mTimeFrameGPU->createTrackITSExtDevice(capacity);
338 mTimeFrameGPU->getDeviceArrayTrackingFrameInfo(),
339 mTimeFrameGPU->getDeviceArrayUnsortedClusters(),
340 mTimeFrameGPU->getDeviceIndexTableUtils(),
341 mTimeFrameGPU->getDeviceROFMaskTableView(),
342 mTimeFrameGPU->getDeviceROFOverlapTableView(),
343 mTimeFrameGPU->getDeviceArrayClusters(),
344 (
const unsigned char**)mTimeFrameGPU->getDeviceArrayUsedClusters(),
345 mTimeFrameGPU->getDeviceArrayClustersIndexTables(),
346 mTimeFrameGPU->getDeviceROFrameClusters(),
347 mTimeFrameGPU->getDeviceTrackITSExt(),
348 mTimeFrameGPU->getDeviceTrackIndices(),
349 mTimeFrameGPU->getDeviceTrackSeedIndices(),
350 mTimeFrameGPU->getDeviceTrackCounter(),
352 extendTracks ? mTimeFrameGPU->getDeviceActiveTrackExtensionHypotheses() :
nullptr,
353 extendTracks ? mTimeFrameGPU->getDeviceNextTrackExtensionHypotheses() :
nullptr,
354 mTimeFrameGPU->getDeviceLayerRadii(),
355 mTimeFrameGPU->getDeviceMinPts(),
356 mTimeFrameGPU->getDeviceLayerxX0(),
357 static_cast<unsigned int>(nSeeds),
359 this->mTrkParams[iteration].MaxChi2ClusterAttachment,
360 this->mTrkParams[iteration].MaxChi2NDF,
361 this->mTrkParams[iteration].ReseedIfShorter,
362 this->mTrkParams[iteration].RepeatRefitOut,
363 this->mTrkParams[iteration].ShiftRefToCluster,
364 this->mTrkParams[iteration].NLayers,
365 this->mTrkParams[iteration].PhiBins,
366 this->mTrkParams[iteration].TrackFollowerMaxHypotheses,
369 this->mTrkParams[iteration].TrackFollowerNSigmaCutPhi,
370 this->mTrkParams[iteration].TrackFollowerNSigmaCutZ,
371 mTimeFrameGPU->getDevicePropagator(),
372 this->mTrkParams[iteration].CorrType,
373 mTimeFrameGPU->getFrameworkAllocator()); }, estimator.peakCapacity(trackKey));
374 mTimeFrameGPU->createTrackITSExtHost(nTracks);
375 mTimeFrameGPU->downloadTrackITSExtDevice();
377 auto& tracks = mTimeFrameGPU->getTrackITSExt();
378 const auto& trackIndices = mTimeFrameGPU->getTrackIndices();
379 this->acceptTracks(iteration, tracks, trackIndices, firstClusters);
380 mTimeFrameGPU->loadUsedClustersDevice();
382 this->markTracks(iteration);
384 mTimeFrameGPU->popMemoryStack(iteration);