cosmicrays / hermes

HERMES is a publicly available computational framework for the line of sight integration over galactic radiative processes which creates sky maps in the HEALPix-compatibile format.
GNU General Public License v3.0
23 stars 9 forks source link

parallelization #21

Closed danielegaggero closed 2 years ago

danielegaggero commented 2 years ago

Hi, very quick dummy questions:

1) how do I disable multi-threading, or set a different number of threads? I noticed this line *env_num_threads = getenv("HERMES_NUM_THREADS”) but I have no such environment variable set in my system... still, the code is parallelized!

2) In alternative, for debugging purpose: how do I set a line of code (e.g. a std::cout) so that it is executed on one thread at a time? I mean, the equivalent of "#pragma omp critical" in openMP

Thanks! Daniele

carmeloevoli commented 2 years ago
  1. if HERMES_NUM_THREADS is not set than the code uses the max number of threads allowed, see the line after https://github.com/cosmicrays/hermes/blob/cf6345893695e2cea5e128134da7fd44a04f1374/src/Common.cpp#L125 you can use export HERMES_NUM_THREADS=1 before cmake to run HERMES on a single thread.
adundovi commented 2 years ago

Yes, as @carmeloevoli wrote, export HERMES_NUM_THREADS=1 will run HERMES on a single thread.

carmeloevoli commented 2 years ago

I think this issue has been settled, I close it.