Wiki

Clone wiki

KROME / Thread Safety

6.4 Thread Safety

KROME has been instrumented with OpenMP pragmas to make it thread safe.

The general guidelines are :

  • KROME in itself is not parallelised with openmp.
  • KROME is mostly thread safe, by making all key shared variables thread private. KROME can therefore be called from inside a parallel region in the main program to speedup execution.
  • The underlying ODE solver DLSODES has been modified to be completely thread safe
  • The call to krome_init should happen outside a parallel region.
  • All other calls to krome functions should happen inside parallel regions

The following tests can be used as examples of how to use OpenMP to speed up KROME execution:

  • atmosphere
  • chianti
  • collapseCO
  • collapseUV
  • collapseZ
  • shock1D
  • shock1Dcool

Currently not all parts of KROME have been checked in detail, and OpenMP parallelization should be considered an experimental feature. We are incrementally upgrading all the tests to include OpenMP pragmas as tests for thread safety.

We recommend anybody taking advantage of OpenMP with KROME to first check for identical results between repeated runs with many threads, and to use the intel inspector or a similar thread checking tool from another vendor (e.g. TotalView) for indepth analysis. This should be done before production runs. Please report any threading bugs by opening an issue at the bitbucket repository.

How to take advantage of threading

  • Instrument your main code with OpenMP pragmas. See the tests for examples
  • After running the krome python script, go in to the build directory and add the appropriate compiler flag in the Makefile to enable OpenMP compilation. E.g. -openmp for ifort and -fopenmp for gfortran.

Updated