Function utils::detail::cachedMPIRank

Function Documentation

inline auto utils::detail::cachedMPIRank() -> int&

Storage for this process’s own MPI rank, filled in by initMPI()

Cached, rather than queried from MPI on each call to mpiRank(), because a process’s rank never changes once MPI is up, and because MPI_THREAD_FUNNELED (see initMPI()) only allows MPI calls from the one thread that initialized MPI: mpiRank() and isIORank() are called from code that can run inside an OpenMP parallel region, or after MPI_Finalize(), where a fresh MPI_Comm_rank() call would not be valid.

Returns:

A reference to a function-local static, 0 until initMPI() has run (and always 0 when this build was not compiled with SLUG_MPI)