From 714d003954ca992ee290995c0a375a8b218e7262 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Wed, 25 Nov 2026 12:57:32 +0100 Subject: [PATCH] ITS GPU: move the tracklet kernel body into a header shared by the GPU backends ITS shared, needs agreement with the ITS GPU developers. The CUDA/HIP kernel becomes a wrapper around a GPUd() function in TrackingKernelsDevice.h, which another backend (Metal) can call from its own kernel. The device span helpers move from Utils.h, which needs the CUDA/HIP runtime, to DeviceSpan.h. Placement new becomes an assignment and atomicAdd CAMath::AtomicAdd, both the same on CUDA/HIP. Not compiled with nvcc/hipcc here (no CUDA/ROCm on this Mac). --- .../tracking/GPU/ITStrackingGPU/DeviceSpan.h | 87 ++++++++ .../ITStrackingGPU/TrackingKernelsDevice.h | 197 ++++++++++++++++++ .../ITS/tracking/GPU/ITStrackingGPU/Utils.h | 59 +----- .../ITS/tracking/GPU/cuda/TrackingKernels.cu | 157 +++----------- 4 files changed, 312 insertions(+), 188 deletions(-) create mode 100644 Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/DeviceSpan.h create mode 100644 Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/TrackingKernelsDevice.h diff --git a/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/DeviceSpan.h b/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/DeviceSpan.h new file mode 100644 index 0000000000000..421a94081352e --- /dev/null +++ b/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/DeviceSpan.h @@ -0,0 +1,87 @@ +// Copyright 2019-2026 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +/// +/// \file DeviceSpan.h +/// \brief Device-side span and cluster lookup, without host runtime dependencies. +/// + +#ifndef ITSTRACKINGGPU_DEVICESPAN_H_ +#define ITSTRACKINGGPU_DEVICESPAN_H_ + +#include "GPUCommonDef.h" +#include "ITStracking/Cluster.h" + +namespace o2::its::gpu +{ + +template +struct gpuSpan { + using value_type = T; + using ptr = T*; + using ref = T&; + + GPUd() gpuSpan() : _data(nullptr), _size(0) {} + GPUd() gpuSpan(ptr data, unsigned int dim) : _data(data), _size(dim) {} + GPUd() ref operator[](unsigned int idx) const { return _data[idx]; } + GPUd() unsigned int size() const { return _size; } + GPUd() bool empty() const { return _size == 0; } + GPUd() ref front() const { return _data[0]; } + GPUd() ref back() const { return _data[_size - 1]; } + GPUd() ptr begin() const { return _data; } + GPUd() ptr end() const { return _data + _size; } + + protected: + ptr _data; + unsigned int _size; +}; + +template +struct gpuSpan { + using value_type = T; + using ptr = const T*; + using ref = const T&; + + GPUd() gpuSpan() : _data(nullptr), _size(0) {} + GPUd() gpuSpan(ptr data, unsigned int dim) : _data(data), _size(dim) {} + GPUd() gpuSpan(const gpuSpan& other) : _data(other._data), _size(other._size) {} + GPUd() ref operator[](unsigned int idx) const { return _data[idx]; } + GPUd() unsigned int size() const { return _size; } + GPUd() bool empty() const { return _size == 0; } + GPUd() ref front() const { return _data[0]; } + GPUd() ref back() const { return _data[_size - 1]; } + GPUd() ptr begin() const { return _data; } + GPUd() ptr end() const { return _data + _size; } + + protected: + ptr _data; + unsigned int _size; +}; + +#ifdef GPUCA_GPUCODE +GPUdii() gpuSpan getClustersOnLayer(const int rof, + const int totROFs, + const int layer, + const int** roframesClus, + const Cluster** clusters) +{ + if (rof < 0 || rof >= totROFs) { + return gpuSpan(); + } + const int start_clus_id{roframesClus[layer][rof]}; + const int stop_rof = rof >= totROFs - 1 ? totROFs : rof + 1; + const unsigned int delta = roframesClus[layer][stop_rof] - start_clus_id; + return gpuSpan(&(clusters[layer][start_clus_id]), delta); +} +#endif + +} // namespace o2::its::gpu + +#endif // ITSTRACKINGGPU_DEVICESPAN_H_ diff --git a/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/TrackingKernelsDevice.h b/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/TrackingKernelsDevice.h new file mode 100644 index 0000000000000..08a9e8e85e347 --- /dev/null +++ b/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/TrackingKernelsDevice.h @@ -0,0 +1,197 @@ +// Copyright 2019-2026 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +/// +/// \file TrackingKernelsDevice.h +/// \brief Bodies of the ITS tracking kernels, shared by the CUDA/HIP kernels and other GPU backends. +/// + +#ifndef ITSTRACKINGGPU_TRACKINGKERNELSDEVICE_H_ +#define ITSTRACKINGGPU_TRACKINGKERNELSDEVICE_H_ + +#include "GPUCommonDef.h" +#include "GPUCommonMath.h" +#include "ITSMFTTracking/Constants.h" +#include "ITSMFTTracking/MathUtils.h" +#include "ITSMFTTracking/ROFLookupTables.h" +#include "ITStracking/Cluster.h" +#include "ITStracking/IndexTableUtils.h" +#include "ITStracking/Tracklet.h" +#include "ITStracking/TrackingTopology.h" +#include "ITStrackingGPU/DeviceSpan.h" + +namespace o2::its::gpu +{ + +template +GPUdi() void computeLayerTrackletsMultiROF( + const int iThread, + const int nThreads, + const IndexTableUtils* utils, + const typename ROFMaskTable::View rofMask, + const int linkId, + const typename TrackingTopology::View topology, + const typename ROFOverlapTable::View rofOverlaps, + const typename ROFVertexLookupTable::View vertexLUT, + const Vertex* vertices, + const bool useDiamond, + const int vertexId, + const Cluster** clusters, + const int** ROFClusters, + const unsigned char** usedClusters, + const int** indexTables, + Tracklet** tracklets, + int* outputCounter, + const int outputCapacity, + const bool selectUPCVertices, + const float NSigmaCut, + const float phiCut, + const float resolutionPV, + const float* minRs, + const float* maxRs, + const float positionResolution, + const float meanDeltaR, + const float MSAngle) +{ + const auto link = topology.getLink(linkId); + const int fromLayer = link.fromLayer; + const int toLayer = link.toLayer; + const float minR = minRs[toLayer]; + const float maxR = maxRs[toLayer]; + const int phiBins{utils->getNphiBins()}; + const int zBins{utils->getNzBins()}; + const int tableSize{phiBins * zBins + 1}; + const int totalROFs0 = rofOverlaps.getLayer(fromLayer).mNROFsTF; + const int totalROFs1 = rofOverlaps.getLayer(toLayer).mNROFsTF; + if (totalROFs0 <= 0) { + return; + } + + const int* const rofOffsets = ROFClusters[fromLayer]; + const int totalClusters = rofOffsets[totalROFs0]; + for (int currentSortedIndex = iThread; + currentSortedIndex < totalClusters; + currentSortedIndex += nThreads) { + // last ROF whose first cluster is at or before this one + int lo{0}, hi{totalROFs0 - 1}; + while (lo < hi) { + const int mid{(lo + hi + 1) >> 1}; + if (rofOffsets[mid] <= currentSortedIndex) { + lo = mid; + } else { + hi = mid - 1; + } + } + const unsigned int pivotROF = static_cast(lo); + if (!rofMask.isROFEnabled(fromLayer, pivotROF)) { + continue; + } + + gpuSpan primaryVertices; + if (useDiamond) { + primaryVertices = gpuSpan(vertices, 1); + } else { + const auto& pvs = vertexLUT.getVertices(fromLayer, pivotROF); + primaryVertices = gpuSpan(&vertices[pvs.getFirstEntry()], pvs.getEntries()); + } + if (primaryVertices.empty()) { + continue; + } + const auto startVtx{vertexId >= 0 ? vertexId : 0}; + const auto endVtx{vertexId >= 0 ? o2::gpu::CAMath::Min(vertexId + 1, static_cast(primaryVertices.size())) : static_cast(primaryVertices.size())}; + if (endVtx <= startVtx || (vertexId + 1) > primaryVertices.size()) { + continue; + } + + const auto& rofOverlap = rofOverlaps.getOverlap(fromLayer, toLayer, pivotROF); + if (!rofOverlap.getEntries()) { + continue; + } + + { + const auto& currentCluster{clusters[fromLayer][currentSortedIndex]}; + if (usedClusters[fromLayer][currentCluster.clusterId]) { + continue; + } + + const float inverseR0{1.f / currentCluster.radius}; + for (int iV{startVtx}; iV < endVtx; ++iV) { + auto& primaryVertex{primaryVertices[iV]}; + if (!vertexLUT.isVertexCompatible(fromLayer, pivotROF, primaryVertex)) { + continue; + } + if (primaryVertex.isFlagSet(Vertex::Flags::UPCMode) != selectUPCVertices) { + continue; + } + + const float resolution = o2::gpu::CAMath::Sqrt(math_utils::Sq(resolutionPV) / primaryVertex.getNContributors() + math_utils::Sq(positionResolution)); + const float tanLambda{(currentCluster.zCoordinate - primaryVertex.getZ()) * inverseR0}; + const float zAtRmin{tanLambda * (minR - currentCluster.radius) + currentCluster.zCoordinate}; + const float zAtRmax{tanLambda * (maxR - currentCluster.radius) + currentCluster.zCoordinate}; + const float sqInverseDeltaZ0{1.f / (math_utils::Sq(currentCluster.zCoordinate - primaryVertex.getZ()) + constants::Tolerance)}; /// protecting from overflows adding the detector resolution + const float sigmaZ{o2::gpu::CAMath::Sqrt(math_utils::Sq(resolution) * math_utils::Sq(tanLambda) * ((math_utils::Sq(inverseR0) + sqInverseDeltaZ0) * math_utils::Sq(meanDeltaR) + 1.f) + math_utils::Sq(meanDeltaR * MSAngle))}; + const int4 selectedBinsRect{o2::its::getBinsRect(currentCluster, toLayer, zAtRmin, zAtRmax, sigmaZ * NSigmaCut, phiCut, *utils)}; + if (selectedBinsRect.x < 0) { + continue; + } + int phiBinsNum{selectedBinsRect.w - selectedBinsRect.y + 1}; + + if (phiBinsNum < 0) { + phiBinsNum += phiBins; + } + + for (short targetROF = rofOverlap.getFirstEntry(); targetROF < rofOverlap.getEntriesBound(); ++targetROF) { + if (!rofMask.isROFEnabled(toLayer, targetROF)) { + continue; + } + auto clustersNextLayer = getClustersOnLayer(targetROF, totalROFs1, toLayer, ROFClusters, clusters); + if (clustersNextLayer.empty()) { + continue; + } + const auto ts = rofOverlaps.getTimeStamp(fromLayer, pivotROF, toLayer, targetROF); + if (!ts.isCompatible(primaryVertex.getTimeStamp())) { + continue; + } + for (int iPhiCount{0}; iPhiCount < phiBinsNum; iPhiCount++) { + int iPhiBin = (selectedBinsRect.y + iPhiCount) % phiBins; + const int firstBinIndex{utils->getBinIndex(selectedBinsRect.x, iPhiBin)}; + const int maxBinIndex{firstBinIndex + selectedBinsRect.z - selectedBinsRect.x + 1}; + const int firstRowClusterIndex = indexTables[toLayer][(targetROF)*tableSize + firstBinIndex]; + const int maxRowClusterIndex = indexTables[toLayer][(targetROF)*tableSize + maxBinIndex]; + for (int nextClusterIndex{firstRowClusterIndex}; nextClusterIndex < maxRowClusterIndex; ++nextClusterIndex) { + if (nextClusterIndex >= clustersNextLayer.size()) { + break; + } + const Cluster& nextCluster{clustersNextLayer[nextClusterIndex]}; + if (usedClusters[toLayer][nextCluster.clusterId]) { + continue; + } + const float deltaPhi{o2::gpu::CAMath::Abs(currentCluster.phi - nextCluster.phi)}; + const float deltaZ{o2::gpu::CAMath::Abs(tanLambda * (nextCluster.radius - currentCluster.radius) + currentCluster.zCoordinate - nextCluster.zCoordinate)}; + if (deltaZ / sigmaZ < NSigmaCut && (deltaPhi < phiCut || o2::gpu::CAMath::Abs(deltaPhi - o2::constants::math::TwoPI) < phiCut)) { + const float phi{o2::math_utils::fastATan2(currentCluster.yCoordinate - nextCluster.yCoordinate, currentCluster.xCoordinate - nextCluster.xCoordinate)}; + const float tanL{(currentCluster.zCoordinate - nextCluster.zCoordinate) / (currentCluster.radius - nextCluster.radius)}; + const int nextSortedIndex{ROFClusters[toLayer][targetROF] + nextClusterIndex}; + const int outputIndex = o2::gpu::CAMath::AtomicAdd(outputCounter, 1); // the optimizer turns this into a wave ballot vote + if (outputIndex < outputCapacity) { + tracklets[linkId][outputIndex] = Tracklet{currentSortedIndex, nextSortedIndex, tanL, phi, ts}; + } + } + } + } + } + } + } + } +} + +} // namespace o2::its::gpu + +#endif // ITSTRACKINGGPU_TRACKINGKERNELSDEVICE_H_ diff --git a/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/Utils.h b/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/Utils.h index 41ce4d4deaaa1..c506dce5dd74a 100644 --- a/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/Utils.h +++ b/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/Utils.h @@ -27,6 +27,7 @@ #include "GPUCommonHelpers.h" #include "GPUCommonLogger.h" #include "GPUCommonDefAPI.h" +#include "ITStrackingGPU/DeviceSpan.h" #ifdef GPUCA_GPUCODE #include @@ -67,49 +68,6 @@ using gpuPair = std::pair; namespace gpu { -template -struct gpuSpan { - using value_type = T; - using ptr = T*; - using ref = T&; - - GPUd() gpuSpan() : _data(nullptr), _size(0) {} - GPUd() gpuSpan(ptr data, unsigned int dim) : _data(data), _size(dim) {} - GPUd() ref operator[](unsigned int idx) const { return _data[idx]; } - GPUd() unsigned int size() const { return _size; } - GPUd() bool empty() const { return _size == 0; } - GPUd() ref front() const { return _data[0]; } - GPUd() ref back() const { return _data[_size - 1]; } - GPUd() ptr begin() const { return _data; } - GPUd() ptr end() const { return _data + _size; } - - protected: - ptr _data; - unsigned int _size; -}; - -template -struct gpuSpan { - using value_type = T; - using ptr = const T*; - using ref = const T&; - - GPUd() gpuSpan() : _data(nullptr), _size(0) {} - GPUd() gpuSpan(ptr data, unsigned int dim) : _data(data), _size(dim) {} - GPUd() gpuSpan(const gpuSpan& other) : _data(other._data), _size(other._size) {} - GPUd() ref operator[](unsigned int idx) const { return _data[idx]; } - GPUd() unsigned int size() const { return _size; } - GPUd() bool empty() const { return _size == 0; } - GPUd() ref front() const { return _data[0]; } - GPUd() ref back() const { return _data[_size - 1]; } - GPUd() ptr begin() const { return _data; } - GPUd() ptr end() const { return _data + _size; } - - protected: - ptr _data; - unsigned int _size; -}; - // Abstract stream class class Stream { @@ -380,21 +338,6 @@ GPUdii() int deviceUpperBound(const T* a, int beg, int end, const T key) return beg; } -GPUdii() gpuSpan getClustersOnLayer(const int rof, - const int totROFs, - const int layer, - const int** roframesClus, - const Cluster** clusters) -{ - if (rof < 0 || rof >= totROFs) { - return gpuSpan(); - } - const int start_clus_id{roframesClus[layer][rof]}; - const int stop_rof = rof >= totROFs - 1 ? totROFs : rof + 1; - const unsigned int delta = roframesClus[layer][stop_rof] - start_clus_id; - return gpuSpan(&(clusters[layer][start_clus_id]), delta); -} - #endif } // namespace gpu } // namespace o2::its diff --git a/Detectors/ITSMFT/ITS/tracking/GPU/cuda/TrackingKernels.cu b/Detectors/ITSMFT/ITS/tracking/GPU/cuda/TrackingKernels.cu index bdb702d3b4427..9f602e90c6210 100644 --- a/Detectors/ITSMFT/ITS/tracking/GPU/cuda/TrackingKernels.cu +++ b/Detectors/ITSMFT/ITS/tracking/GPU/cuda/TrackingKernels.cu @@ -50,6 +50,7 @@ #include "ITStracking/TrackHelpers.h" #include "ITStracking/TrackFollower.h" #include "ITStrackingGPU/TrackingKernels.h" +#include "ITStrackingGPU/TrackingKernelsDevice.h" #include "ITStrackingGPU/Utils.h" #include "MathUtils/Utils.h" #include "GPUCommonAlgorithm.h" @@ -438,136 +439,32 @@ GPUg() void __launch_bounds__(GPUThreads, MinBlocks.computeLayerTracklets) compu const float meanDeltaR, const float MSAngle) { - const auto link = topology.getLink(linkId); - const int fromLayer = link.fromLayer; - const int toLayer = link.toLayer; - const float minR = minRs[toLayer]; - const float maxR = maxRs[toLayer]; - const int phiBins{utils->getNphiBins()}; - const int zBins{utils->getNzBins()}; - const int tableSize{phiBins * zBins + 1}; - const int totalROFs0 = rofOverlaps.getLayer(fromLayer).mNROFsTF; - const int totalROFs1 = rofOverlaps.getLayer(toLayer).mNROFsTF; - if (totalROFs0 <= 0) { - return; - } - - const int* const rofOffsets = ROFClusters[fromLayer]; - const int totalClusters = rofOffsets[totalROFs0]; - for (int currentSortedIndex = blockIdx.x * blockDim.x + threadIdx.x; - currentSortedIndex < totalClusters; - currentSortedIndex += blockDim.x * gridDim.x) { - // last ROF whose first cluster is at or before this one - int lo{0}, hi{totalROFs0 - 1}; - while (lo < hi) { - const int mid{(lo + hi + 1) >> 1}; - if (rofOffsets[mid] <= currentSortedIndex) { - lo = mid; - } else { - hi = mid - 1; - } - } - const unsigned int pivotROF = static_cast(lo); - if (!rofMask.isROFEnabled(fromLayer, pivotROF)) { - continue; - } - - gpuSpan primaryVertices; - if (useDiamond) { - primaryVertices = gpuSpan(vertices, 1); - } else { - const auto& pvs = vertexLUT.getVertices(fromLayer, pivotROF); - primaryVertices = gpuSpan(&vertices[pvs.getFirstEntry()], pvs.getEntries()); - } - if (primaryVertices.empty()) { - continue; - } - const auto startVtx{vertexId >= 0 ? vertexId : 0}; - const auto endVtx{vertexId >= 0 ? o2::gpu::CAMath::Min(vertexId + 1, static_cast(primaryVertices.size())) : static_cast(primaryVertices.size())}; - if (endVtx <= startVtx || (vertexId + 1) > primaryVertices.size()) { - continue; - } - - const auto& rofOverlap = rofOverlaps.getOverlap(fromLayer, toLayer, pivotROF); - if (!rofOverlap.getEntries()) { - continue; - } - - { - const auto& currentCluster{clusters[fromLayer][currentSortedIndex]}; - if (usedClusters[fromLayer][currentCluster.clusterId]) { - continue; - } - - const float inverseR0{1.f / currentCluster.radius}; - for (int iV{startVtx}; iV < endVtx; ++iV) { - auto& primaryVertex{primaryVertices[iV]}; - if (!vertexLUT.isVertexCompatible(fromLayer, pivotROF, primaryVertex)) { - continue; - } - if (primaryVertex.isFlagSet(Vertex::Flags::UPCMode) != selectUPCVertices) { - continue; - } - - const float resolution = o2::gpu::CAMath::Sqrt(math_utils::Sq(resolutionPV) / primaryVertex.getNContributors() + math_utils::Sq(positionResolution)); - const float tanLambda{(currentCluster.zCoordinate - primaryVertex.getZ()) * inverseR0}; - const float zAtRmin{tanLambda * (minR - currentCluster.radius) + currentCluster.zCoordinate}; - const float zAtRmax{tanLambda * (maxR - currentCluster.radius) + currentCluster.zCoordinate}; - const float sqInverseDeltaZ0{1.f / (math_utils::Sq(currentCluster.zCoordinate - primaryVertex.getZ()) + constants::Tolerance)}; /// protecting from overflows adding the detector resolution - const float sigmaZ{o2::gpu::CAMath::Sqrt(math_utils::Sq(resolution) * math_utils::Sq(tanLambda) * ((math_utils::Sq(inverseR0) + sqInverseDeltaZ0) * math_utils::Sq(meanDeltaR) + 1.f) + math_utils::Sq(meanDeltaR * MSAngle))}; - const int4 selectedBinsRect{o2::its::getBinsRect(currentCluster, toLayer, zAtRmin, zAtRmax, sigmaZ * NSigmaCut, phiCut, *utils)}; - if (selectedBinsRect.x < 0) { - continue; - } - int phiBinsNum{selectedBinsRect.w - selectedBinsRect.y + 1}; - - if (phiBinsNum < 0) { - phiBinsNum += phiBins; - } - - for (short targetROF = rofOverlap.getFirstEntry(); targetROF < rofOverlap.getEntriesBound(); ++targetROF) { - if (!rofMask.isROFEnabled(toLayer, targetROF)) { - continue; - } - auto clustersNextLayer = getClustersOnLayer(targetROF, totalROFs1, toLayer, ROFClusters, clusters); - if (clustersNextLayer.empty()) { - continue; - } - const auto ts = rofOverlaps.getTimeStamp(fromLayer, pivotROF, toLayer, targetROF); - if (!ts.isCompatible(primaryVertex.getTimeStamp())) { - continue; - } - for (int iPhiCount{0}; iPhiCount < phiBinsNum; iPhiCount++) { - int iPhiBin = (selectedBinsRect.y + iPhiCount) % phiBins; - const int firstBinIndex{utils->getBinIndex(selectedBinsRect.x, iPhiBin)}; - const int maxBinIndex{firstBinIndex + selectedBinsRect.z - selectedBinsRect.x + 1}; - const int firstRowClusterIndex = indexTables[toLayer][(targetROF)*tableSize + firstBinIndex]; - const int maxRowClusterIndex = indexTables[toLayer][(targetROF)*tableSize + maxBinIndex]; - for (int nextClusterIndex{firstRowClusterIndex}; nextClusterIndex < maxRowClusterIndex; ++nextClusterIndex) { - if (nextClusterIndex >= clustersNextLayer.size()) { - break; - } - const Cluster& nextCluster{clustersNextLayer[nextClusterIndex]}; - if (usedClusters[toLayer][nextCluster.clusterId]) { - continue; - } - const float deltaPhi{o2::gpu::CAMath::Abs(currentCluster.phi - nextCluster.phi)}; - const float deltaZ{o2::gpu::CAMath::Abs(tanLambda * (nextCluster.radius - currentCluster.radius) + currentCluster.zCoordinate - nextCluster.zCoordinate)}; - if (deltaZ / sigmaZ < NSigmaCut && (deltaPhi < phiCut || o2::gpu::CAMath::Abs(deltaPhi - o2::constants::math::TwoPI) < phiCut)) { - const float phi{o2::math_utils::fastATan2(currentCluster.yCoordinate - nextCluster.yCoordinate, currentCluster.xCoordinate - nextCluster.xCoordinate)}; - const float tanL{(currentCluster.zCoordinate - nextCluster.zCoordinate) / (currentCluster.radius - nextCluster.radius)}; - const int nextSortedIndex{ROFClusters[toLayer][targetROF] + nextClusterIndex}; - const int outputIndex = atomicAdd(outputCounter, 1); // the optimizer turns this into a wave ballot vote - if (outputIndex < outputCapacity) { - new (tracklets[linkId] + outputIndex) Tracklet{currentSortedIndex, nextSortedIndex, tanL, phi, ts}; - } - } - } - } - } - } - } - } + computeLayerTrackletsMultiROF(blockIdx.x * blockDim.x + threadIdx.x, blockDim.x * gridDim.x, + utils, + rofMask, + linkId, + topology, + rofOverlaps, + vertexLUT, + vertices, + useDiamond, + vertexId, + clusters, + ROFClusters, + usedClusters, + indexTables, + tracklets, + outputCounter, + outputCapacity, + selectUPCVertices, + NSigmaCut, + phiCut, + resolutionPV, + minRs, + maxRs, + positionResolution, + meanDeltaR, + MSAngle); } GPUg() void __launch_bounds__(GPUThreads, MinBlocks.compileLookupTable) compileTrackletsLookupTableKernel(