You are here

How to express parallelism on many cores?

ROOT offers a production quality framework to express parallelism on distributed systems, PROOF, and on many cores machines, PROOFLite. On the other hand, often, solutions involving a simple multi-threading and multi-processing are often desirable.


ROOT can be used as a library from multiple threads, provided that two simple conditions are respected, namely:

  • The function ROOT::EnableThreadSafety() is called before carrying out operations in multiple threads
  • One file per thread is read/written.

Simple examples about the usage one can make of ROOT in a multi-threaded application can be found here.


The tool provided by ROOT for carrying out simple operations involving multiprocessing is TProcPool. This class allows to easily implement solutions relying on the map and map/reduce pattern and to analyse trees exploiting all the cores at disposal.

TProcPool myPool(5);
myPool.Map(MyFunction, MyCollection);

Examples about the usage of TProcPool can be found here.