[mpich-discuss] Right level of thread safety
Thakur, Rajeev
thakur at anl.gov
Tue Jun 26 09:31:22 CDT 2018
You need to follow the MPI specification and use MPI_THREAD_MULTIPLE. It is not a good idea to make assumptions about what an MPI implementation may do within an MPI function. Otherwise your code may not work with some MPI implementation on some platform.
MPI_Test is not read only. Internally it may cause progress to occur on other pending communication operations.
Rajeev
> On Jun 26, 2018, at 4:26 AM, Florian Lindner <mailinglists at xgm.de> wrote:
>
> Hello,
>
> I have a multi-threaded MPI application. Actually, only two threads. The main thread does all kinds of MPI operations,
> the secondary thread, launched by std::thread does only MPI_Test, no other MPI operations.
>
> What is the required level of thread safety?
>
> According to https://www.mpich.org/static/docs/v3.1/www3/MPI_Init_thread.html
>
> MPI_THREAD_SINGLE
> Only one thread will execute.
>
> MPI_THREAD_FUNNELED
> The process may be multi-threaded, but only the main thread will make MPI calls (all MPI calls are funneled to the
> main thread).
>
> MPI_THREAD_SERIALIZED
> The process may be multi-threaded, and multiple threads may make MPI calls, but only one at a time: MPI calls are
> not made concurrently from two distinct threads (all MPI calls are serialized).
>
> MPI_THREAD_MULTIPLE
> Multiple threads may call MPI, with no restrictions.
>
>
> its THREAD_MULTIPLE, since I can not synchronize the main threads MPI calls and MPI_Test from the other thread.
>
> Is that perception correct? I am asking, because I think Test is a relatively small operations and probably read only
> and therefore maybe a lower thread safety level suffices.
>
> Thanks,
> Florian
> _______________________________________________
> discuss mailing list discuss at mpich.org
> To manage subscription options or unsubscribe:
> https://lists.mpich.org/mailman/listinfo/discuss
_______________________________________________
discuss mailing list discuss at mpich.org
To manage subscription options or unsubscribe:
https://lists.mpich.org/mailman/listinfo/discuss
More information about the discuss
mailing list