[mpiwg-p2p] Ordering of P2P messages in multithreaded applications

Joachim Protze protze at itc.rwth-aachen.de
Thu Nov 15 04:16:17 CST 2018


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
protze at itc.rwth-aachen.de
www.itc.rwth-aachen.de

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4915 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.mpi-forum.org/pipermail/mpiwg-p2p/attachments/20181115/80ecd798/attachment.p7s>


More information about the mpiwg-p2p mailing list