<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr">







I am testing on x86_64 platform.<br><br>I have tried to built both the mpich and the mcs lock code with -O0 to avoid agressive optimization. After your suggestion I have also tried to make volatile int *pblocked pointing to lmem[blocked] in the MCSLockAcquire function and volatile int *pnextrank pointing to lmem[nextRank] in MCSLockRelease, but it does not appear to make a difference.<br><br>On suggestion from Richard Warren I have also tried building the code using openmpi-2.0.2 without any luck (however it appears to acquire the lock a couple of extra times before failing) which I find troubling.<br><br>I think I will give up using local load/stores and will see if I can figure out if rewrite using MPI calls like MPI_Fetch_and_op  as you suggest. Thanks for your help.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 6, 2017 at 7:20 PM, Jeff Hammond <span dir="ltr"><<a href="mailto:jeff.science@gmail.com" target="_blank">jeff.science@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">What processor architecture are you testing?<div><br></div><div>Maybe set lmem to volatile or read it with MPI_Fetch_and_op rather than a load.  MPI_Win_sync cannot prevent the compiler from caching *lmem in a register.<div><div><br></div><div>Jeff</div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Sat, Mar 4, 2017 at 12:30 AM, Ask Jakobsen <span dir="ltr"><<a href="mailto:afj@qeye-labs.com" target="_blank">afj@qeye-labs.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hi,<br><br>I have downloaded the source code for the MCS lock from the excellent book "Using Advanced MPI" from <a href="http://www.mcs.anl.gov/research/projects/mpi/usingmpi/examples-advmpi/rma2/mcs-lock.c" target="_blank">http://www.mcs.anl.gov/researc<wbr>h/projects/mpi/usingmpi/<wbr>examples-advmpi/rma2/mcs-lock.<wbr>c</a><div><br></div><div>I have made a very simple piece of test code for testing the MCS lock but it works at random and often never escapes the busy loops in the acquire and release functions (see attached source code). The code appears semantically correct to my eyes.</div><div><br></div><div><div><font face="monospace, monospace">#include <stdio.h></font></div><div><font face="monospace, monospace">#include <mpi.h></font></div><div><font face="monospace, monospace">#include "mcs-lock.h"</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">int main(int argc, char *argv[])</font></div><div><font face="monospace, monospace">{</font></div><div><font face="monospace, monospace">  MPI_Win win;</font></div><div><font face="monospace, monospace">  MPI_Init( &argc, &argv );</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  MCSLockInit(MPI_COMM_WORLD, &win);</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  int rank, size;</font></div><div><font face="monospace, monospace">  MPI_Comm_rank(MPI_COMM_WORLD, &rank);</font></div><div><font face="monospace, monospace">  MPI_Comm_size(MPI_COMM_WORLD, &size);</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  printf("rank: %d, size: %d\n", rank, size);</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  MCSLockAcquire(win);</font></div><div><font face="monospace, monospace">  printf("rank %d aquired lock\n", rank);   fflush(stdout);</font></div><div><font face="monospace, monospace">  MCSLockRelease(win);</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  MPI_Win_free(&win); </font></div><div><font face="monospace, monospace">  MPI_Finalize();</font></div><div><font face="monospace, monospace">  return 0;</font></div><div><font face="monospace, monospace">}</font></div></div><div><font face="monospace, monospace"><br></font></div><div><br></div><div>I have tested on several hardware platforms and mpich-3.2 and mpich-3.3a2 but with no luck.<div><div><font face="monospace, monospace" style="font-size:12.8px"><br></font></div><div>It appears that the MPI_Win_Sync are not "refreshing" the local data or I have a bug I can't spot.</div><div><br></div></div></div><div>A simple unfair lock like <a href="http://www.mcs.anl.gov/research/projects/mpi/usingmpi/examples-advmpi/rma2/ga_mutex1.c" target="_blank">http://www.mcs.anl.gov/researc<wbr>h/projects/mpi/usingmpi/<wbr>examples-advmpi/rma2/ga_<wbr>mutex1.c</a> works perfectly.</div><div><br></div><div>Best regards, Ask Jakobsen<br><div><div><div><br></div></div></div></div></div>
<br></div></div>______________________________<wbr>_________________<br>
discuss mailing list     <a href="mailto:discuss@mpich.org" target="_blank">discuss@mpich.org</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss" rel="noreferrer" target="_blank">https://lists.mpich.org/mailma<wbr>n/listinfo/discuss</a><span class="HOEnZb"><font color="#888888"><br></font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_5263917469182007993gmail_signature" data-smartmail="gmail_signature">Jeff Hammond<br><a href="mailto:jeff.science@gmail.com" target="_blank">jeff.science@gmail.com</a><br><a href="http://jeffhammond.github.io/" target="_blank">http://jeffhammond.github.io/</a></div>
</font></span></div>
<br>______________________________<wbr>_________________<br>
discuss mailing list     <a href="mailto:discuss@mpich.org">discuss@mpich.org</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss" rel="noreferrer" target="_blank">https://lists.mpich.org/<wbr>mailman/listinfo/discuss</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><font size="1"><b>Ask Jakobsen</b><br>R&D<br><br><span style="color:rgb(255,153,102)">Q</span>eye Labs<br>Lersø Parkallé 107<br>2100 Copenhagen Ø <br>Denmark<br><br>mobile: +45 2834 6936<br>email: afj@Qeye-Labs.com<br></font></div></div></div></div>
</div>