Re: [mpiwg-p2p] Ordering of P2P messages in multithreaded applications
A send of 0 must be issued by one of the two threads before buffer turns to 1. Messages must match in order at receiver and that will lead to ā0\n1\nā being printed at the target. Jeff Sent from my iPhone
On Nov 15, 2018, at 4:16 AM, Joachim Protze via mpiwg-p2p <[email protected]> wrote:
Hi all,
I have a question on the "Semantics of Point-to-Point Communication" in a multithreaded context.
For me the situation for the code below is not clear, especially with respect to the paragraph in MPI-3.1 p.41, l.10-17 :
void test(int rank) { int msg = 0; if (rank == 0) { #pragma omp parallel num_threads(2) #pragma omp critical { MPI_Send(&msg, 1, MPI_INT, 1, 42, MPI_COMM_WORLD); msg++; } } else if (rank == 1) { MPI_Recv(&msg, 1, MPI_INT, 0, 42, MPI_COMM_WORLD, MPI_STATUS_IGNORE); printf("Received %i\n", msg); MPI_Recv(&msg, 1, MPI_INT, 0, 42, MPI_COMM_WORLD, MPI_STATUS_IGNORE); printf("Received %i\n", msg); } }
Two threads on the first process send a message, the first thread sends 0, the second thread send 1. From OpenMP semantics, the first send happens before the second send.
Is there a guarantee, that the other process receives the 0 first?
Thanks, Joachim
-- Dipl.-Inf. Joachim Protze
IT Center Group: High Performance Computing Division: Computational Science and Engineering RWTH Aachen University Seffenter Weg 23 D 52074 Aachen (Germany) Tel: +49 241 80- 24765 Fax: +49 241 80-624765 [email protected] www.itc.rwth-aachen.de
participants (1)
-
Jeff Hammond