<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body dir="auto">
Dan,
<div><br>
</div>
<div>The matching *is* ordered in this case.  So the program will print 0 followed by 1.</div>
<div><br>
</div>
<div>MPI does not order delivery of the actual data, but the first message is guaranteed to go into the first buffer.  If the second message ends up going first, the MPI implementation will need to buffer it.</div>
<div><br>
</div>
<div>  — Pavan<br>
<br>
<div id="AppleMailSignature" dir="ltr">Sent from my iPhone</div>
<div dir="ltr"><br>
On Nov 15, 2018, at 7:56 AM, HOLMES Daniel via mpiwg-p2p <<a href="mailto:mpiwg-p2p@lists.mpi-forum.org">mpiwg-p2p@lists.mpi-forum.org</a>> wrote:<br>
<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hi Joachim,
<div class=""><br class="">
</div>
<div class="">There is no guarantee of ordering between the two sends because they are logically concurrent. If they were issued on the same thread then MPI guarantees delivery order will be identical to the sequential issuing order.</div>
<div class=""><br class="">
</div>
<div class="">Many MPI libraries are very likely to deliver these messages "in order”, that is, the first one to be called chronologically at the sender process is likely to leave first and therefore likely to arrive first. Interleaving execution of the sending
 threads may change the issuing order on the network and out-of-order networks may change the order of arrival.</div>
<div class=""><br class="">
</div>
<div class="">On the other hand, if an MPI implementation is internally using sequence numbers (or a similar mechanism) to enforce ordering for the same-thread case, then it may also (incidentally) reconstruct the issuing order for this case. However, you cannot
 rely on this behaviour being portable from system to system or from MPI library to MPI library.<br class="">
<div class=""><br class="webkit-block-placeholder">
</div>
<div class="">If you wish to enforce a particular ordering of these messages, then you can use tags to differentiate each from the other. There is an argument for always using tags in this type of situation to increase program readability.</div>
<div class=""><br class="">
</div>
<div class="">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Cheers,</div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Dan.</div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
—<br class="">
Dr Daniel Holmes PhD<br class="">
Applications Consultant in HPC Research<br class="">
<a href="mailto:d.holmes@epcc.ed.ac.uk" class="">d.holmes@epcc.ed.ac.uk</a><br class="">
Phone: +44 (0) 131 651 3465<br class="">
Mobile: +44 (0) 7940 524 088<br class="">
Address: Room 2.09, Bayes Centre, 47 Potterrow, Central Area, Edinburgh, EH8 9BT</div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
—</div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.</div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
—</div>
</div>
<br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 15 Nov 2018, at 04:16, Joachim Protze via mpiwg-p2p <<a href="mailto:mpiwg-p2p@lists.mpi-forum.org" class="">mpiwg-p2p@lists.mpi-forum.org</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">Hi all,<br class="">
<br class="">
I have a question on the "Semantics of Point-to-Point Communication" in a multithreaded context.<br class="">
<br class="">
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 :<br class="">
<br class="">
<br class="">
void test(int rank) {<br class="">
 int msg = 0;<br class="">
 if (rank == 0) {<br class="">
#pragma omp parallel num_threads(2)<br class="">
#pragma omp critical<br class="">
   {<br class="">
     MPI_Send(&msg, 1, MPI_INT, 1, 42, MPI_COMM_WORLD);<br class="">
     msg++;<br class="">
   }<br class="">
 } else if (rank == 1) {<br class="">
   MPI_Recv(&msg, 1, MPI_INT, 0, 42, MPI_COMM_WORLD, MPI_STATUS_IGNORE);<br class="">
   printf("Received %i\n", msg);<br class="">
   MPI_Recv(&msg, 1, MPI_INT, 0, 42, MPI_COMM_WORLD, MPI_STATUS_IGNORE);<br class="">
   printf("Received %i\n", msg);<br class="">
 }<br class="">
}<br class="">
<br class="">
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.<br class="">
<br class="">
Is there a guarantee, that the other process receives the 0 first?<br class="">
<br class="">
Thanks,<br class="">
Joachim<br class="">
<br class="">
<br class="">
-- <br class="">
Dipl.-Inf. Joachim Protze<br class="">
<br class="">
IT Center<br class="">
Group: High Performance Computing<br class="">
Division: Computational Science and Engineering<br class="">
RWTH Aachen University<br class="">
Seffenter Weg 23<br class="">
D 52074  Aachen (Germany)<br class="">
Tel: +49 241 80- 24765<br class="">
Fax: +49 241 80-624765<br class="">
<a href="mailto:protze@itc.rwth-aachen.de" class="">protze@itc.rwth-aachen.de</a><br class="">
<a href="http://www.itc.rwth-aachen.de">www.itc.rwth-aachen.de</a><br class="">
<br class="">
_______________________________________________<br class="">
mpiwg-p2p mailing list<br class="">
<a href="mailto:mpiwg-p2p@lists.mpi-forum.org">mpiwg-p2p@lists.mpi-forum.org</a><br class="">
<a href="https://lists.mpi-forum.org/mailman/listinfo/mpiwg-p2p">https://lists.mpi-forum.org/mailman/listinfo/mpiwg-p2p</a><br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
<blockquote type="cite">
<div dir="ltr"><span>The University of Edinburgh is a charitable body, registered in</span><br>
<span>Scotland, with registration number SC005336.</span><br>
</div>
</blockquote>
<blockquote type="cite">
<div dir="ltr"><span>_______________________________________________</span><br>
<span>mpiwg-p2p mailing list</span><br>
<span><a href="mailto:mpiwg-p2p@lists.mpi-forum.org">mpiwg-p2p@lists.mpi-forum.org</a></span><br>
<span><a href="https://lists.mpi-forum.org/mailman/listinfo/mpiwg-p2p">https://lists.mpi-forum.org/mailman/listinfo/mpiwg-p2p</a></span><br>
</div>
</blockquote>
</div>
</body>
</html>