Skip to content
Snippets Groups Projects
Commit 99af46c1 authored by Axel Naumann's avatar Axel Naumann
Browse files

[treeplayer] Construct TThreadedObject after enabling IMT:

Before, the TThreadedObject had to guess 64 slots were enough for the use case of TTreeProcessorMT - and with 256 cores that was not the case.
Be explicit about the use of IMT for TThreadedObject by providing the new argument.
IMT is enabled before the construction of the TThreadedObject (and thus TThreadedObject now knows how many slots to expect), because the pool is constructed before.
If the order ever gets changes, the TThreadedObject will complain as it is now told to expect IMT usage.

A future TTreeProcessorMT ctor overload might provide a specific thread count, and can pass it down to TThreadedObject.
parent b4615147
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@
#include "TFriendElement.h"
#include "ROOT/RMakeUnique.hxx"
#include "ROOT/TThreadedObject.hxx"
#include "ROOT/TThreadExecutor.hxx"
#include <string.h>
#include <functional>
......@@ -88,8 +89,10 @@ private:
/// User-defined selection of entry numbers to be processed, empty if none was provided
const TEntryList fEntryList; // const to be sure to avoid race conditions among TTreeViews
const Internal::FriendInfo fFriendInfo;
ROOT::TThreadExecutor fPool; ///<! Thread pool for processing.
ROOT::TThreadedObject<ROOT::Internal::TTreeView> fTreeView; ///<! Thread-local TreeViews
// Must be declared after fPool, for IMT to be initialized first!
ROOT::TThreadedObject<ROOT::Internal::TTreeView> fTreeView{ROOT::kIMTPoolSize}; ///<! Thread-local TreeViews
Internal::FriendInfo GetFriendInfo(TTree &tree);
std::string FindTreeName();
......
......@@ -26,7 +26,6 @@ objects.
#include "TROOT.h"
#include "ROOT/TTreeProcessorMT.hxx"
#include "ROOT/TThreadExecutor.hxx"
using namespace ROOT;
......@@ -491,7 +490,6 @@ void TTreeProcessorMT::Process(std::function<void(TTreeReader &)> func)
const std::vector<Internal::NameAlias> &friendNames = fFriendInfo.fFriendNames;
const std::vector<std::vector<std::string>> &friendFileNames = fFriendInfo.fFriendFileNames;
TThreadExecutor pool;
// If an entry list or friend trees are present, we need to generate clusters with global entry numbers,
// so we do it here for all files.
const bool hasFriends = !friendNames.empty();
......@@ -530,7 +528,7 @@ void TTreeProcessorMT::Process(std::function<void(TTreeReader &)> func)
func(*reader);
};
pool.Foreach(processCluster, thisFileClusters);
fPool.Foreach(processCluster, thisFileClusters);
};
std::vector<std::size_t> fileIdxs(fFileNames.size());
......@@ -539,7 +537,7 @@ void TTreeProcessorMT::Process(std::function<void(TTreeReader &)> func)
// Enable this IMT use case (activate its locks)
Internal::TParTreeProcessingRAII ptpRAII;
pool.Foreach(processFile, fileIdxs);
fPool.Foreach(processFile, fileIdxs);
}
////////////////////////////////////////////////////////////////////////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment