Fwd: [Beowulf] mutex (remote memory access) question for MPI-2

William Gropp gropp at mcs.anl.gov
Tue Aug 2 16:59:13 PDT 2005

At 07:10 AM 8/2/2005, Plinius Frobenius wrote:

>Thanks, but I want :
>Get -  do some calculations - Put
>Get -  do some calculations - Put
>So, if it goes wrong, you still can have the following:
>y Gets - x Gets - x calculates - x Puts - y calculates - y Puts
>Where the calculations of x are completely lost, because y used the wrong 
>value to do his calculations.
>So, I think (I'm not sure though) that this can't be done with only lock 
>and unlock before the gets and puts?

Yes, you are correct here.  MPI-2, unfortunately, didn't provide any 
built-in mutex support.  It is possible to construct a mutex, but because 
there is no get-modify-put operation (such as fetch and increment), it 
isn't as easy as it should be.  Unless you are planning on using thousands 
of processes, the "non-scalable" implementation of fetch and increment 
described in Using MPI-2 can be used to create a simple 
mutex.  Alternatively, if the MPI implementation that you are using 
supports MPI_THREAD_MULTIPLE, you can use a simple mutex manager in a 
separate thread with which you communicate with point-to-point operations.


>Is this correct? And how would you solve this?
>Thanks for ideas and help.
>On 8/1/05, William Gropp <<mailto:gropp at mcs.anl.gov>gropp at mcs.anl.gov > wrote:
>At 12:49 PM 7/31/2005, Plinius Frobenius wrote:
> >Hi,
> >I've red through the chapter in "Using MPI-2" about mutexes.
> >Suppose that you know in advance that only one cumputer (say node y) can
> >access the memory-window on node x (except node x itself).
> >How should your mutex-code look like (you still need a mutex, since both x
> >and y can access the memory)? (since you won't need the entire
> >"tree-mutex-code" provided by Rajeev Thakur, I guess, since there are only
> >two processes able to acces the memory...). I haven't enough experience
> >yet to find this one by myself, and really need it for the program I'm
> >working on.
>You don't need mutexes for this.  Simply use MPI_Win_lock with a mode of
>MPI_LOCK_EXCLUSIVE, followed by either MPI_Put, MPI_Get, or MPI_Accumulate
>(from node y) or simple language access on node x (e.g., *a = 1; where a
>points into node x's memory window)., followed by MPI_Win_unlock.
> >Thanks for any ideas/hints/help...
> >_______________________________________________
> >Beowulf mailing list, <mailto:Beowulf at beowulf.org>Beowulf at beowulf.org
> >To change your subscription (digest mode or unsubscribe) visit
> ><http://www.beowulf.org/mailman/listinfo/beowulf>http://www.beowulf.org/m 
> ailman/listinfo/beowulf
>William Gropp
>Beowulf mailing list, Beowulf at beowulf.org
>To change your subscription (digest mode or unsubscribe) visit 

William Gropp

More information about the Beowulf mailing list