@@ -71,7 +71,7 @@ void TrackerTraits<nLayers>::computeLayerTracklets(const int iteration, int iROF
7171 int minRof = o2::gpu::CAMath::Max (startROF, rof0 - mTrkParams [iteration].DeltaROF );
7272 int maxRof = o2::gpu::CAMath::Min (endROF - 1 , rof0 + mTrkParams [iteration].DeltaROF );
7373
74- mTaskArena . execute ([&] {
74+ mTaskArena -> execute ([&] {
7575 tbb::parallel_for (
7676 tbb::blocked_range<int >(0 , mTrkParams [iteration].TrackletsPerRoad ()),
7777 [&](const tbb::blocked_range<int >& Layers) {
@@ -200,7 +200,7 @@ void TrackerTraits<nLayers>::computeLayerTracklets(const int iteration, int iROF
200200 return a.firstClusterIndex == b.firstClusterIndex && a.secondClusterIndex == b.secondClusterIndex ;
201201 };
202202
203- mTaskArena . execute ([&] {
203+ mTaskArena -> execute ([&] {
204204 tbb::parallel_for (
205205 tbb::blocked_range<int >(0 , mTrkParams [iteration].CellsPerRoad ()),
206206 [&](const tbb::blocked_range<int >& Layers) {
@@ -229,7 +229,7 @@ void TrackerTraits<nLayers>::computeLayerTracklets(const int iteration, int iROF
229229 // / Layer 0 is done outside the loop
230230 // in-place deduplication
231231 auto & trklt0 = mTimeFrame ->getTracklets ()[0 ];
232- mTaskArena . execute ([&] { tbb::parallel_sort (trklt0.begin (), trklt0.end (), sortTracklets); });
232+ mTaskArena -> execute ([&] { tbb::parallel_sort (trklt0.begin (), trklt0.end (), sortTracklets); });
233233 trklt0.erase (std::unique (trklt0.begin (), trklt0.end (), equalTracklets), trklt0.end ());
234234 trklt0.shrink_to_fit ();
235235
@@ -275,7 +275,7 @@ void TrackerTraits<nLayers>::computeLayerCells(const int iteration)
275275 }
276276 }
277277
278- mTaskArena . execute ([&] {
278+ mTaskArena -> execute ([&] {
279279 tbb::parallel_for (
280280 tbb::blocked_range<int >(0 , mTrkParams [iteration].CellsPerRoad ()),
281281 [&](const tbb::blocked_range<int >& Layers) {
@@ -496,7 +496,7 @@ void TrackerTraits<nLayers>::findCellsNeighbours(const int iteration)
496496 continue ;
497497 }
498498
499- mTaskArena . execute ([&] {
499+ mTaskArena -> execute ([&] {
500500 int layerCellsNum{static_cast <int >(mTimeFrame ->getCells ()[iLayer].size ())};
501501
502502 bounded_vector<int > perCellCount (layerCellsNum + 1 , 0 , mMemoryPool .get ());
@@ -621,7 +621,7 @@ void TrackerTraits<nLayers>::processNeighbours(int iLayer, int iLevel, const bou
621621 int failed[5 ]{0 , 0 , 0 , 0 , 0 }, attempts{0 }, failedByMismatch{0 };
622622#endif
623623
624- mTaskArena . execute ([&] {
624+ mTaskArena -> execute ([&] {
625625 bounded_vector<int > perCellCount (currentCellSeed.size () + 1 , 0 , mMemoryPool .get ());
626626 tbb::parallel_for (
627627 tbb::blocked_range<int >(0 , (int )currentCellSeed.size ()),
@@ -812,7 +812,7 @@ void TrackerTraits<nLayers>::findRoads(const int iteration)
812812 }
813813
814814 bounded_vector<TrackITSExt> tracks (mMemoryPool .get ());
815- mTaskArena . execute ([&] {
815+ mTaskArena -> execute ([&] {
816816 bounded_vector<int > perSeedCount (trackSeeds.size () + 1 , 0 , mMemoryPool .get ());
817817 tbb::parallel_for (
818818 tbb::blocked_range<int >(0 , (int )trackSeeds.size ()),
@@ -1258,17 +1258,19 @@ bool TrackerTraits<nLayers>::isMatLUT() const
12581258}
12591259
12601260template <int nLayers>
1261- void TrackerTraits<nLayers>::setNThreads(int n)
1261+ void TrackerTraits<nLayers>::setNThreads(int n, std::shared_ptr<tbb::task_arena>& arena )
12621262{
1263- if (mNThreads == n && mTaskArena .is_active ()) {
1264- return ;
1265- }
1266- mNThreads = n > 0 ? n : 1 ;
12671263#if defined(OPTIMISATION_OUTPUT) || defined(CA_DEBUG)
1268- mNThreads = 1 ; // only works while serial
1264+ mTaskArena = std::make_shared<tbb::task_arena>(1 );
1265+ #else
1266+ if (arena == nullptr ) {
1267+ mTaskArena = std::make_shared<tbb::task_arena>(std::abs (n));
1268+ LOGP (info, " Setting tracker with {} threads." , n);
1269+ } else {
1270+ mTaskArena = arena;
1271+ LOGP (info, " Attaching tracker to calling thread's arena" );
1272+ }
12691273#endif
1270- mTaskArena .initialize (mNThreads );
1271- LOGP (info, " Setting tracker with {} threads." , mNThreads );
12721274}
12731275
12741276template class TrackerTraits <7 >;
0 commit comments