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 ifMPI_Abortwas called on that communicator. if called on a window or file, it acts as ifMPI_Abortwas 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_errhandlerthenMPI_Comm_set_errhandlerMPI_File_create_errhandlerthenMPI_File_set_errhandlerMPI_Session_create_errhandlerthenMPI_Session_set_errhandleror atMPI_Session_initMPI_Win_create_errhandlerthenMPI_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_allMPI_Win_lock
π COPYRIGHT
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
- arch rolling: openmpi 5.0.11-1 Β· BSD-3-Clause AND LicenseRef-MPICH
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms