[mpich-discuss] MCS lock and MPI RMA problem

Ask Jakobsen afj at qeye-labs.com
Sun Mar 5 01:35:48 CST 2017


Hi Richard,

The window is initialised in MCSLockInit (see book author's code
http://www.mcs.anl.gov/research/projects/mpi/usingmpi/examples-advmpi/rma2/mcs-lock.c)

void MCSLockInit(MPI_Comm comm, MPI_Win *win)
{
  int      *lmem, rank;
  MPI_Aint winsize;
  MPI_Comm_rank(comm,&rank);

  if (MCS_LOCKRANK == MPI_KEYVAL_INVALID)
    MPI_Win_create_keyval(MPI_WIN_NULL_COPY_FN,
			  MPI_WIN_NULL_DELETE_FN,
			  &MCS_LOCKRANK, (void*)0);

  winsize = 2 * sizeof(int);
  if (rank == 0) winsize += sizeof(int);
  MPI_Win_allocate(winsize, sizeof(int), MPI_INFO_NULL, comm,
                   &lmem, win);
  lmem[nextRank] = -1;
  lmem[blocked]  = 0;
  if (rank == 0) {
    lmem[lockTail] = -1;
  }
  MPI_Win_set_attr(*win, MCS_LOCKRANK, (void*)(MPI_Aint)rank);
  MPI_Barrier(comm);
}

Best regards, Ask

Date: Sat, 4 Mar 2017 19:03:13 +0000
> From: Richard Warren <Richard.Warren at hdfgroup.org>
> To: "discuss at mpich.org" <discuss at mpich.org>
> Subject: Re: [mpich-discuss] MCS lock and MPI RMA problem
> Message-ID:
>         <BY2PR17MB0406FB1E6C8D6DC76CF45279EF2A0 at BY2PR17MB0406.
> namprd17.prod.outlook.com>
>
> Content-Type: text/plain; charset="us-ascii"
>
> I don't see that you've actually created an MPI_Win object anywhere.  My
> guess is that you need to use MPI_Win_create to initialize your window
> before you can do any locks or other RMA operations with it.
>
> ________________________________
> From: Ask Jakobsen <afj at qeye-labs.com>
> Sent: Saturday, March 4, 2017 3:30:09 AM
> To: discuss at mpich.org
> Subject: [mpich-discuss] MCS lock and MPI RMA problem
>
> Hi,
>
> I have downloaded the source code for the MCS lock from the excellent book
> "Using Advanced MPI" from http://www.mcs.anl.gov/research/projects/mpi/
> usingmpi/examples-advmpi/rma2/mcs-lock.c
>
> 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.
>
> #include <stdio.h>
> #include <mpi.h>
> #include "mcs-lock.h"
>
> int main(int argc, char *argv[])
> {
>   MPI_Win win;
>   MPI_Init( &argc, &argv );
>
>   MCSLockInit(MPI_COMM_WORLD, &win);
>
>   int rank, size;
>   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
>   MPI_Comm_size(MPI_COMM_WORLD, &size);
>
>   printf("rank: %d, size: %d\n", rank, size);
>
>
>   MCSLockAcquire(win);
>   printf("rank %d aquired lock\n", rank);   fflush(stdout);
>   MCSLockRelease(win);
>
>
>   MPI_Win_free(&win);
>   MPI_Finalize();
>   return 0;
> }
>
>
> I have tested on several hardware platforms and mpich-3.2 and mpich-3.3a2
> but with no luck.
>
> It appears that the MPI_Win_Sync are not "refreshing" the local data or I
> have a bug I can't spot.
>
> A simple unfair lock like http://www.mcs.anl.gov/research/projects/mpi/
> usingmpi/examples-advmpi/rma2/ga_mutex1.c works perfectly.
>
> Best regards, Ask Jakobsen
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://lists.mpich.org/pipermail/discuss/attachments/
> 20170304/c292bfaf/attachment.html>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mpich.org/pipermail/discuss/attachments/20170305/0e5c350b/attachment.html>
-------------- next part --------------
_______________________________________________
discuss mailing list     discuss at mpich.org
To manage subscription options or unsubscribe:
https://lists.mpich.org/mailman/listinfo/discuss


More information about the discuss mailing list