Whenever your program uses threading, you should use MPI_Init_thread()
.
It depends on your usage of the threads which value of required
you will pass.
Reference from the OpenMPI manual:
MPI_THREAD_SINGLE Only one thread will execute.
MPI_THREAD_FUNNELED If the process is multithreaded, only the thread that called MPI_Init_thread will make MPI calls.
MPI_THREAD_SERIALIZED If the process is multithreaded, only one thread will make MPI library calls at one time.
MPI_THREAD_MULTIPLE If the process is multithreaded, multiple threads may call MPI at once with no restrictions.
Usually, the only value of required
that is treated differently is MPI_THREAD_MULTIPLE
. You pass this value if more threads can call MPI functions at the same time. Unfortunately, the performance of the MPI library is usually bad in this case.
The others are often treated equally in the MPI libraries. Nevertheless, if the support of threads was disabled when you built OpenMPI, it will still complain, that the only provided
value is MPI_THREAD_SINGLE
, even if MPI_FUNNELED
and MPI_SERIALIZED
will work too.