@@ -71,14 +71,15 @@ void TrackerTraits<nLayers>::computeLayerTracklets(const int iteration, int iROF
7171 gsl::span<const Vertex> diamondSpan (&diamondVert, 1 );
7272 int startROF{mTrkParams [iteration].nROFsPerIterations > 0 ? iROFslice * mTrkParams [iteration].nROFsPerIterations : 0 };
7373 int endROF{o2::gpu::GPUCommonMath::Min (mTrkParams [iteration].nROFsPerIterations > 0 ? (iROFslice + 1 ) * mTrkParams [iteration].nROFsPerIterations + mTrkParams [iteration].DeltaROF : mTimeFrame ->getNrof (), mTimeFrame ->getNrof ())};
74- for (int rof0{startROF}; rof0 < endROF; ++rof0) {
75- gsl::span<const Vertex> primaryVertices = mTrkParams [iteration].UseDiamond ? diamondSpan : mTimeFrame ->getPrimaryVertices (rof0);
76- const int startVtx{iVertex >= 0 ? iVertex : 0 };
77- const int endVtx{iVertex >= 0 ? o2::gpu::CAMath::Min (iVertex + 1 , static_cast <int >(primaryVertices.size ())) : static_cast <int >(primaryVertices.size ())};
78- int minRof = o2::gpu::CAMath::Max (startROF, rof0 - mTrkParams [iteration].DeltaROF );
79- int maxRof = o2::gpu::CAMath::Min (endROF - 1 , rof0 + mTrkParams [iteration].DeltaROF );
8074
81- mTaskArena ->execute ([&] {
75+ mTaskArena ->execute ([&] {
76+ for (int rof0{startROF}; rof0 < endROF; ++rof0) {
77+ gsl::span<const Vertex> primaryVertices = mTrkParams [iteration].UseDiamond ? diamondSpan : mTimeFrame ->getPrimaryVertices (rof0);
78+ const int startVtx{iVertex >= 0 ? iVertex : 0 };
79+ const int endVtx{iVertex >= 0 ? o2::gpu::CAMath::Min (iVertex + 1 , static_cast <int >(primaryVertices.size ())) : static_cast <int >(primaryVertices.size ())};
80+ int minRof = o2::gpu::CAMath::Max (startROF, rof0 - mTrkParams [iteration].DeltaROF );
81+ int maxRof = o2::gpu::CAMath::Min (endROF - 1 , rof0 + mTrkParams [iteration].DeltaROF );
82+
8283 tbb::parallel_for (
8384 tbb::blocked_range<int >(0 , mTrkParams [iteration].TrackletsPerRoad ()),
8485 [&](const tbb::blocked_range<int >& Layers) {
@@ -197,49 +198,39 @@ void TrackerTraits<nLayers>::computeLayerTracklets(const int iteration, int iROF
197198 }
198199 }
199200 });
200- });
201- }
202-
203- auto sortTracklets = [](const Tracklet& a, const Tracklet& b) -> bool {
204- return a.firstClusterIndex < b.firstClusterIndex || (a.firstClusterIndex == b.firstClusterIndex && a.secondClusterIndex < b.secondClusterIndex );
205- };
206- auto equalTracklets = [](const Tracklet& a, const Tracklet& b) -> bool {
207- return a.firstClusterIndex == b.firstClusterIndex && a.secondClusterIndex == b.secondClusterIndex ;
208- };
201+ }
209202
210- mTaskArena ->execute ([&] {
211203 tbb::parallel_for (
212- tbb::blocked_range<int >(0 , mTrkParams [iteration].CellsPerRoad ()),
204+ tbb::blocked_range<int >(0 , mTrkParams [iteration].TrackletsPerRoad ()),
213205 [&](const tbb::blocked_range<int >& Layers) {
214206 for (int iLayer = Layers.begin (); iLayer < Layers.end (); ++iLayer) {
215207 // / Sort tracklets
216- auto & trkl{mTimeFrame ->getTracklets ()[iLayer + 1 ]};
217- tbb::parallel_sort (trkl.begin (), trkl.end (), sortTracklets);
208+ auto & trkl{mTimeFrame ->getTracklets ()[iLayer]};
209+ tbb::parallel_sort (trkl.begin (), trkl.end (), [](const Tracklet& a, const Tracklet& b) -> bool {
210+ return a.firstClusterIndex < b.firstClusterIndex || (a.firstClusterIndex == b.firstClusterIndex && a.secondClusterIndex < b.secondClusterIndex );
211+ });
218212 // / Remove duplicates
219- trkl.erase (std::unique (trkl.begin (), trkl.end (), equalTracklets), trkl.end ());
213+ trkl.erase (std::unique (trkl.begin (), trkl.end (), [](const Tracklet& a, const Tracklet& b) -> bool {
214+ return a.firstClusterIndex == b.firstClusterIndex && a.secondClusterIndex == b.secondClusterIndex ;
215+ }),
216+ trkl.end ());
220217 trkl.shrink_to_fit ();
221- // / recalculate lut
222- auto & lut{mTimeFrame ->getTrackletsLookupTable ()[iLayer]};
223- std::fill (lut.begin (), lut.end (), 0 );
224- if (trkl.empty ()) {
225- return ;
226- }
227- for (const auto & tkl : trkl) {
228- lut[tkl.firstClusterIndex ]++;
218+ if (iLayer > 0 ) { // / recalculate lut
219+ auto & lut{mTimeFrame ->getTrackletsLookupTable ()[iLayer - 1 ]};
220+ std::fill (lut.begin (), lut.end (), 0 );
221+ if (trkl.empty ()) {
222+ return ;
223+ }
224+ for (const auto & tkl : trkl) {
225+ lut[tkl.firstClusterIndex ]++;
226+ }
227+ std::exclusive_scan (lut.begin (), lut.end (), lut.begin (), 0 );
228+ lut.push_back (trkl.size ());
229229 }
230- std::exclusive_scan (lut.begin (), lut.end (), lut.begin (), 0 );
231- lut.push_back (trkl.size ());
232230 }
233231 });
234232 });
235233
236- // / Layer 0 is done outside the loop
237- // in-place deduplication
238- auto & trklt0 = mTimeFrame ->getTracklets ()[0 ];
239- mTaskArena ->execute ([&] { tbb::parallel_sort (trklt0.begin (), trklt0.end (), sortTracklets); });
240- trklt0.erase (std::unique (trklt0.begin (), trklt0.end (), equalTracklets), trklt0.end ());
241- trklt0.shrink_to_fit ();
242-
243234 // / Create tracklets labels
244235 if (mTimeFrame ->hasMCinformation ()) {
245236 for (int iLayer{0 }; iLayer < mTrkParams [iteration].TrackletsPerRoad (); ++iLayer) {
0 commit comments