Home | News | Documentation | Download

How to make sure that reading a tree is really parallel?

Dear experts!
I use the ROOT::EnableImplicitMT() and GetEntry() function when reading a tree. But the time of the macro is the same as in the non-parallel case.

How can I make sure that reading a tree is distributed over several threads and that these threads run in parallel? Is there a method that shows the actual number of threads in the ROOT environment when the macro is executed.

ROOT Version: 6.13
Platform: LINUX
Compiler: Not Provided

you can ask ROOT how big the thread-pool that it is using is with ROOT::GetImplicitMTPoolSize().
To verify that it is actually used when you call TTree::GetEntry you can monitor the core usage of your machine during execution, e.g. with htop, or the %CPU field when you run your application through /usr/bin/time, or you can run the application through gdb, add a breakpoint in TTree.cxx:5483 (the inside of the mapFunction which is distributed between workers) and check if you hit it from multiple threads, or again from gdb you can just break the application with ctrl+C at random times during the event loop and check how many threads are working and what they are doing with thread apply all backtrace 20.

Hope this helps!

1 Like

Thank you!
I tried to call ROOT::GetImplicitMTPoolSize(). The result is the same as the number of determinated threads in ROOT::EnableImplicit(nthreads) . But it is unclear whether these threads are running in parallel or they are executed sequentially one after the other?
The execution time of parallel and non-parallel macros coincide. Therefore, probably, though the task is divided into several threads, but they are executed sequentially.

Hi Tanysha,
it’s improbable that threads execute tasks one after the other.
It’s more likely that

  1. most of your runtime is spent outside of TTree::GetEntry, so parallelizing that is not helping you
  2. each call to TTree::GetEntry does too little work for parallelization to be effective: for example, you have only one or two branches in the TTree
  3. a bug in ROOT prevents parallelization: to exclude this is the case you can try running on lxplus with the latest ROOT: source /cvmfs/sft.cern.ch/lcg/views/dev3/latest/x86_64-centos7-gcc7-opt/setup.sh

You can use one of the methods I described in my previous post to check what’s going on.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.