HOWTO run a JANA program with multiple threads
JANA was designed to allow multi-thread event processing. By default, however, only 1 processing thread is used unless the user specifies something different. There are three ways to specify the number of processing threads to be used:
- Configuration parameter NTHREADS
- Explicit command line argument: --nthreads=X where X is an integer of 1 or greater
- Programatically by passing a second argument to the Run method of JApplication
Examples
Command Line:
Run with 4 processing threads
hd_root -PNTHREADS=4 hdgeant_smeared.hddm
Have JANA detect the number of cores available and start 1 thread for each
hd_root -PNTHREADS=Ncores hdgeant_smeared.hddm
Run with 4 processing threads using the explicit command line parameter --nthreads. This will take precedence over the NTHREADS configuration parameter. It is useful in case you specify a configuration file that sets NTHREADS, but would like to override it without editing the file.
hd_root --nthreads=4 hdgeant_smeared.hddm
Use a configuration file. The file should have a line like the following:
NTHREADS Ncores
Then run the program using the configuration file. ("jana.conf" is the name of the configuration file containing the above line.)
hd_root --config=jana.conf hdgeant_smeared.hddm