@@ -524,7 +524,7 @@ void TrackerTraits<NLayers>::findCellsNeighbours(const int iteration)
524524
525525template <int NLayers>
526526template <typename InputSeed>
527- void TrackerTraits<NLayers>::processNeighbours(int iLayer, int iLevel, const bounded_vector< InputSeed>& currentCellSeed, const bounded_vector< int >& currentCellId, bounded_vector<TrackSeedN>& updatedCellSeeds, bounded_vector<int >& updatedCellsIds)
527+ void TrackerTraits<NLayers>::processNeighbours(int iLayer, int iLevel, std::span< const InputSeed> currentCellSeed, std::span< const int > currentCellId, int cellOffset , bounded_vector<TrackSeedN>& updatedCellSeeds, bounded_vector<int >& updatedCellsIds)
528528{
529529 auto propagator = o2::base::Propagator::Instance ();
530530
@@ -543,7 +543,7 @@ void TrackerTraits<NLayers>::processNeighbours(int iLayer, int iLevel, const bou
543543 }
544544 }
545545
546- const int cellId = currentCellId.empty () ? iCell : currentCellId[iCell];
546+ const int cellId = currentCellId.empty () ? ( iCell + cellOffset) : currentCellId[iCell];
547547 const int startNeighbourId{cellId ? mTimeFrame ->getCellsNeighboursLUT ()[iLayer - 1 ][cellId - 1 ] : 0 };
548548 const int endNeighbourId{mTimeFrame ->getCellsNeighboursLUT ()[iLayer - 1 ][cellId]};
549549 int foundSeeds{0 };
@@ -658,30 +658,42 @@ void TrackerTraits<NLayers>::findRoads(const int iteration)
658658 };
659659
660660 bounded_vector<TrackSeedN> trackSeeds (mMemoryPool .get ());
661+ constexpr int kStartCellChunk = 32000 ; // TODO: expose as tunable parameter
661662 for (int startLayer{mTrkParams [iteration].NeighboursPerRoad ()}; startLayer >= startLevel - 1 ; --startLayer) {
662663 if ((mTrkParams [iteration].StartLayerMask & (1 << (startLayer + 2 ))) == 0 ) {
663664 continue ;
664665 }
665666
666- bounded_vector< int > lastCellId ( mMemoryPool . get ()), updatedCellId ( mMemoryPool . get ()) ;
667- bounded_vector<TrackSeedN> lastCellSeed ( mMemoryPool . get ()), updatedCellSeed ( mMemoryPool . get ());
667+ const auto & startCells = mTimeFrame -> getCells ()[startLayer] ;
668+ const int nStartCells = static_cast < int >(startCells. size ());
668669
669- processNeighbours (startLayer, startLevel, mTimeFrame ->getCells ()[startLayer], lastCellId, updatedCellSeed, updatedCellId);
670+ for (int chunkStart{0 }; chunkStart < nStartCells; chunkStart += kStartCellChunk ) {
671+ const int chunkSize = std::min (kStartCellChunk , nStartCells - chunkStart);
672+ std::span<const CellSeed> chunkSeeds{startCells.data () + chunkStart, static_cast <size_t >(chunkSize)};
670673
671- int level = startLevel;
672- for (int iLayer{startLayer - 1 }; iLayer > 0 && level > 2 ; --iLayer) {
673- lastCellSeed.swap (updatedCellSeed);
674- lastCellId.swap (updatedCellId);
675- deepVectorClear (updatedCellSeed); // / tame the memory peaks
676- deepVectorClear (updatedCellId); // / tame the memory peaks
677- processNeighbours (iLayer, --level, lastCellSeed, lastCellId, updatedCellSeed, updatedCellId);
678- }
679- deepVectorClear (lastCellId); // / tame the memory peaks
680- deepVectorClear (lastCellSeed); // / tame the memory peaks
674+ bounded_vector<int > lastCellId (mMemoryPool .get ()), updatedCellId (mMemoryPool .get ());
675+ bounded_vector<TrackSeedN> lastCellSeed (mMemoryPool .get ()), updatedCellSeed (mMemoryPool .get ());
676+
677+ processNeighbours (startLayer, startLevel, chunkSeeds, std::span<const int >{}, chunkStart, updatedCellSeed, updatedCellId);
681678
682- if (!updatedCellSeed.empty ()) {
683- trackSeeds.reserve (trackSeeds.size () + std::count_if (updatedCellSeed.begin (), updatedCellSeed.end (), seedFilter));
684- std::copy_if (updatedCellSeed.begin (), updatedCellSeed.end (), std::back_inserter (trackSeeds), seedFilter);
679+ int level = startLevel;
680+ for (int iLayer{startLayer - 1 }; iLayer > 0 && level > 2 ; --iLayer) {
681+ lastCellSeed.swap (updatedCellSeed);
682+ lastCellId.swap (updatedCellId);
683+ deepVectorClear (updatedCellSeed); // / tame the memory peaks
684+ deepVectorClear (updatedCellId); // / tame the memory peaks
685+ processNeighbours (iLayer, --level,
686+ std::span<const TrackSeedN>{lastCellSeed.data (), lastCellSeed.size ()},
687+ std::span<const int >{lastCellId.data (), lastCellId.size ()},
688+ 0 , updatedCellSeed, updatedCellId);
689+ }
690+ deepVectorClear (lastCellId); // / tame the memory peaks
691+ deepVectorClear (lastCellSeed); // / tame the memory peaks
692+
693+ if (!updatedCellSeed.empty ()) {
694+ trackSeeds.reserve (trackSeeds.size () + std::count_if (updatedCellSeed.begin (), updatedCellSeed.end (), seedFilter));
695+ std::copy_if (updatedCellSeed.begin (), updatedCellSeed.end (), std::back_inserter (trackSeeds), seedFilter);
696+ }
685697 }
686698 }
687699
@@ -1001,13 +1013,13 @@ void TrackerTraits<NLayers>::setNThreads(int n, std::shared_ptr<tbb::task_arena>
10011013}
10021014
10031015template class TrackerTraits <7 >;
1004- template void TrackerTraits<7 >::processNeighbours<CellSeed>(int , int , const bounded_vector< CellSeed>&, const bounded_vector< int >& , bounded_vector<TrackSeed<7 >>&, bounded_vector<int >&);
1005- template void TrackerTraits<7 >::processNeighbours<TrackSeed<7 >>(int , int , const bounded_vector< TrackSeed<7 >>&, const bounded_vector< int >& , bounded_vector<TrackSeed<7 >>&, bounded_vector<int >&);
1016+ template void TrackerTraits<7 >::processNeighbours<CellSeed>(int , int , std::span< const CellSeed>, std::span< const int >, int , bounded_vector<TrackSeed<7 >>&, bounded_vector<int >&);
1017+ template void TrackerTraits<7 >::processNeighbours<TrackSeed<7 >>(int , int , std::span< const TrackSeed<7 >>, std::span< const int >, int , bounded_vector<TrackSeed<7 >>&, bounded_vector<int >&);
10061018// ALICE3 upgrade
10071019#ifdef ENABLE_UPGRADES
10081020template class TrackerTraits <11 >;
1009- template void TrackerTraits<11 >::processNeighbours<CellSeed>(int , int , const bounded_vector< CellSeed>&, const bounded_vector< int >& , bounded_vector<TrackSeed<11 >>&, bounded_vector<int >&);
1010- template void TrackerTraits<11 >::processNeighbours<TrackSeed<11 >>(int , int , const bounded_vector< TrackSeed<11 >>&, const bounded_vector< int >& , bounded_vector<TrackSeed<11 >>&, bounded_vector<int >&);
1021+ template void TrackerTraits<11 >::processNeighbours<CellSeed>(int , int , std::span< const CellSeed>, std::span< const int >, int , bounded_vector<TrackSeed<11 >>&, bounded_vector<int >&);
1022+ template void TrackerTraits<11 >::processNeighbours<TrackSeed<11 >>(int , int , std::span< const TrackSeed<11 >>, std::span< const int >, int , bounded_vector<TrackSeed<11 >>&, bounded_vector<int >&);
10111023#endif
10121024
10131025} // namespace o2::its
0 commit comments