Jonas,
The MPI standard states in §6.12 that
> All processes must call collective operations (blocking and
nonblocking) in the same order per communicator.
In your first example (the one posted on SO) this is not the case
because there is no ordering among the threads. Two processes might post
Igather with different root arguments in a different order. The
operations do not match, which is erroneous. The results can a deadlock,
an error, or the hounds of hell coming at you.
I don't think your second example is correct either: All threads start
the same operation without inter-thread synchronization so they can be
interleaved at the MPI level. The Igather that Thread 1 starts in
Process 1 might be matched with the Igather started on Thread 2 on
Process 2 (if Thread 1 starts its Igather before Thread 2 on Process 1
and Thread 2 posts its Igather before Thread 1 on Process 2). So Thread
1 will receive the wrong data.
HTH
Joseph
On 1/15/22 6:33 AM, Jonas Thies via mpi-comments wrote:
>
> Dear MPI forum,
>
> I posted a technical question on StackOverflow and was advised to ask
> it in this mailing list.
>
> The original post is here:
> https://stackoverflow.com/questions/70697604/is-mpi-igather-thread-safe
>
> In a nutshell, I am trying to call independentĀ MPI_Igathers in an
> OpenMP-parallel for-loop (after testing for MPI_THREAD_MULTIPLE),
>
> and am getting a deadlock apparently caused by mismatched sends and
> receives, even in a very much stripped down example.
>
> Any help on wether my code is not standard-conforming would be greatly
> appreciated. I attached two versions of the code for convenience, one
> of them is also in the StackOverflow post. The _v2 version does not
> deadlock but produces incorrect results when run with multiple MPI
> processes and multiple OpenMP thread per process.
>
> Thanks and best wishes,
>
> Jonas
>
> --
> *J. Thies*
> Assistant Professor
>
> TU Delft
> Faculty Electrical Engineering, Mathematics and Computer Science
> Institute of Applied Mathematics and High Performance Computing Center
> Mekelweg 4
> 2628 CD Delft
>
> T +31 15 27 XXXX
> *J.Thies(a)tudelft.nl*
>
> _______________________________________________
> mpi-comments mailing list
> mpi-comments(a)lists.mpi-forum.org
> https://lists.mpi-forum.org/mailman/listinfo/mpi-comments
Dear MPI forum,
I posted a technical question on StackOverflow and was advised to ask it
in this mailing list.
The original post is here:
https://stackoverflow.com/questions/70697604/is-mpi-igather-thread-safe
In a nutshell, I am trying to call independentĀ MPI_Igathers in an
OpenMP-parallel for-loop (after testing for MPI_THREAD_MULTIPLE),
and am getting a deadlock apparently caused by mismatched sends and
receives, even in a very much stripped down example.
Any help on wether my code is not standard-conforming would be greatly
appreciated. I attached two versions of the code for convenience, one of
them is also in the StackOverflow post. The _v2 version does not
deadlock but produces incorrect results when run with multiple MPI
processes and multiple OpenMP thread per process.
Thanks and best wishes,
Jonas
--
*J. Thies*
Assistant Professor
TU Delft
Faculty Electrical Engineering, Mathematics and Computer Science
Institute of Applied Mathematics and High Performance Computing Center
Mekelweg 4
2628 CD Delft
T +31 15 27 XXXX
*J.Thies(a)tudelft.nl*