I’m trying to make my analysis code run on a multicore machine (specifically a new 2xquad at my Uni), and I’m trying to understand what the easiest way of doing this is. The time consuming part of my code mostly involves reading large trees (not chained) into histograms from tens of files (one tree per file). I’ve read the tutorials and example code and am still a bit confused.
Is there a big advantage of using PROOF over opening multiple TThreads? which is easiest to modify existing code to?
Is there any way for functions passed to TThread to return values (aside from using globals)? Is there a way to pass multiple arguments (without using dedicated structs)?
Can I use PROOF for a single TTree? that is, do gain any speed if each chain only contains one tree?
Any help would be greatly appreciated, I’m a bit of a newbie at parallel.
Easiest way w/o learning anything about parallel coding is to process each tree-file by a separate program-process w/o any threads and write resulting histograms into separate files. And then, at the end, have these histograms summed up by available in ROOT “hadd”. Of course histograms have to be identically produced by instances of the same program.
The advantage of PROOF is that you do not have to bother about tread-safety and load-balancing of the entry loop.
The TThread technique may be more efficient, if you get it right.
This depends on the starting point.
PROOF is designed to work in the TSelector framework, so you need the adaptation if your current code does not yet make use of TSelector.
Depending on your experience with threads, writing a TSelector may be anyhow easier than thread programming.
Well, passing a ‘void *’ give you all the flexibility you need. In particular you can reserve regions dedicated to each thread.
PROOF always runs on a single TTree. But I guess you meant a TTree residing on one file only. Yes, just create a TChain with one file and you are done. For what relates to the gain, if you are CPU bounded you’ll gain . If you are I/O bounded it will depend on your I/O hardware.
Looking at your example, it shouldn’t be very difficult to write a TSelector for doing what you need. You should load your TTree once and then obtain the TSelector template for your tree with TTree::MakeSelector; then you have just to fill in the hist definition in SlaveBegin and the filling in Process. Have a look at, for example, tutorials/tree/h1analysis.h,.C
Once you have your TSelector, you can try PROOF straightaway and get quickly an idea of what you can gain from parallelization.