<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><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">http://www.mcs.anl.gov/research/projects/mpi/usingmpi/examples-advmpi/rma2/mcs-lock.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">http://www.mcs.anl.gov/research/projects/mpi/usingmpi/examples-advmpi/rma2/ga_mutex1.c</a> works perfectly.</div><div><br></div><div>Best regards, Ask Jakobsen<br><div><div><div><br></div></div></div></div></div>