Demonstrate how to activate and use the implicit parallelisation of TTree::GetEntry.
Such parallelisation creates one task per top-level branch of the tree being read. In this example, most of the branches are floating point numbers, which are very fast to read. This parallelisation can be used, though, on bigger trees with many (complex) branches, which are more likely to benefit from speedup gains.
int imt001_parBranchProcessing()
{
int nthreads = 4;
auto file =
TFile::Open(
"http://root.cern/files/h1/dstarmb.root");
auto tree = file->Get<
TTree>(
"h42");
const auto nEntries = tree->GetEntries();
for (
auto i :
ROOT::TSeqUL(nEntries)) {
tree->GetEntry(i);
}
tree->SetImplicitMT(false);
for (
auto i :
ROOT::TSeqUL(nEntries)) {
tree->GetEntry(i);
}
tree->SetImplicitMT(
true);
}
return 0;
}
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
A TTree represents a columnar dataset.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
void EnableImplicitMT(UInt_t numthreads=0)
Enable ROOT's implicit multi-threading for all objects and methods that provide an internal paralleli...
TSeq< unsigned long > TSeqUL
void DisableImplicitMT()
Disables the implicit multi-threading in ROOT (see EnableImplicitMT).
- Date
- 26/09/2016
- Author
- Enric Tejedor
Definition in file imt001_parBranchProcessing.C.