MPI_WIN_LOCK_ALL(3)

πŸ’… MPI_Win_lock_all β€” Open MPI edition, bestie 🫢

okay so this is the Open MPI man page for MPI_Win_lock_all(3), and honestly? it's kind of a big deal. it kicks off an RMA access epoch that locks access to all the processes in your window. let's get into it ✨


🌈 SYNTAX

✨ C Syntax

#include <mpi.h>

int MPI_Win_lock_all(int assert, MPI_Win win)

πŸ’œ Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_WIN_LOCK_ALL(ASSERT, WIN, IERROR)
     INTEGER ASSERT, WIN, IERROR

πŸ¦‹ Fortran 2008 Syntax

USE mpi_f08
MPI_Win_lock_all(assert, win, ierror)
     INTEGER, INTENT(IN) :: assert
     TYPE(MPI_Win), INTENT(IN) :: win
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

πŸŽ€ INPUT PARAMETERS

  • assert β€” your program assertion, and it's an integer. it's basically you pinky-promising something about the context of this call so the implementation can optimize. more on that below πŸ‘€
  • win β€” the window object (a handle). your whole vibe lives here πŸ’…

🌸 OUTPUT PARAMETER

  • ierror β€” Fortran only, bestie: the error status (integer). C girlies get their error as the return value instead.

πŸ‘‘ DESCRIPTION

so this one starts an RMA access epoch to all processes in win, with the lock type MPI_LOCK_SHARED. during the epoch, the calling process can access the window memory on all processes in win using RMA operations. literally all of them. no cap.

⚠️ important: a window locked with MPI_Win_lock_all must be unlocked with MPI_Win_unlock_all. don't leave it hanging, that's not the move.

and before anyone panics β€” this routine is not collective. the ALL is referring to a lock on all members of the group of the window. iykyk 🧚

so what are locks even for? glad you asked πŸ’– they protect:

  • accesses to the locked target window that get effected by RMA calls issued between the lock and unlock call
  • local load/store accesses to a locked local window that are executed between the lock and unlock call

the tea on exclusivity β˜• (this part matters, stay with me):

  • accesses protected by an exclusive lock will not be concurrent at the window site with other accesses to the same window that are lock protected.
  • accesses protected by a shared lock will not be concurrent at the window site with accesses protected by an exclusive lock to the same window.

the assert argument is used to provide assertions on the context of the call, which can be used for various optimizations. (see Section 6.4.4 of the MPI-2 Standard, if you're feeling studious πŸ“š). a value of assert = 0 is always valid. the following assertion value is supported:

⭐ MPI_MODE_NOCHECK

no other processes will hold or attempt to acquire a conflicting lock while the caller holds the window lock. that's the claim you're making. make it wisely 🫢


πŸ’€ NOTES

okay this one's a little scary so listen up πŸ™ˆ

in a client/server environment where clients connect to a server and create windows that span both the client and the server: if a client or server that has obtained a lock on such a window and then terminates abnormally, the server or other clients may hang in a MPI_Win_lock_all call, failing to notice that the peer MPI job has terminated. 😭 brutal. just be aware.


πŸ”₯ ERRORS

almost all MPI routines return an error value β€” C routines as the return result of the function, and Fortran routines in the last argument. classic.

before the error value is returned, the current MPI error handler associated with the communication object (e.g., communicator, window, file) is called. if no communication object is associated with the MPI call, then the call is considered attached to MPI_COMM_SELF and will call the associated MPI error handler. when MPI_COMM_SELF is not initialized (i.e., before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when using the Sessions Model exclusively), the error raises the initial error handler. the initial error handler can be changed by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or the mpi_initial_errhandler CLI argument to mpiexec or info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. if no other appropriate error handler has been set, then the MPI_ERRORS_RETURN error handler is called for MPI I/O functions and the MPI_ERRORS_ABORT error handler is called for all other MPI functions. πŸ’…

Open MPI includes three predefined error handlers that can be used:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. yeah. everyone. πŸ’€
  • MPI_ERRORS_ABORT β€” an error handler that can be invoked on a communicator, window, file, or session. when called on a communicator, it acts as if MPI_Abort was called on that communicator. if called on a window or file, it acts as if MPI_Abort was called on a communicator containing the group of processes in the corresponding window or file. if called on a session, it aborts only the local process.
  • MPI_ERRORS_RETURN β€” returns an error code to the application. the chill one 🫢

MPI applications can also implement their own error handlers by calling:

  • MPI_Comm_create_errhandler then MPI_Comm_set_errhandler
  • MPI_File_create_errhandler then MPI_File_set_errhandler
  • MPI_Session_create_errhandler then MPI_Session_set_errhandler or at MPI_Session_init
  • MPI_Win_create_errhandler then MPI_Win_set_errhandler
note that MPI does not guarantee that an MPI program can continue past an error. so like… don't count on it bestie 😭

see the MPI man page for a full list of MPI error codes. see the Error Handling section of the MPI-3.1 standard for more information. πŸ“–

πŸ‘€ SEE ALSO

  • MPI_Win_unlock_all
  • MPI_Win_lock

2003-2026, The Open MPI Community


aaand that's the whole page, bestie πŸŽ€ big slay, you ate. this little beauty is from Open MPI, dated Sep 11, 2026, and it's filed under MPI_WIN_LOCK_ALL(3). now go lock that window (and unlock it, periodt) πŸ’œβœ¨

πŸ“¦ where this page comes from