MPI_WIN_UNLOCK(3)

πŸ’– MPI_Win_unlock πŸ’–

okay so this is the Open MPI manual page for MPI_Win_unlock, aka MPI_WIN_UNLOCK(3) β€” yes bestie, we're doing RMA today, put your little MPI hat on πŸŽ€


πŸ¦‹ NAME πŸ¦‹

MPI_Win_unlock β€” closes out an RMA access epoch that you opened with a call to MPI_Win_lock.

like. it's the goodbye half of the lock/unlock situationship. periodt.


✨ SYNTAX ✨

🌸 C Syntax 🌸

#include <mpi.h>

int MPI_Win_unlock(int rank, MPI_Win win)

🌸 Fortran Syntax 🌸

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

🌸 Fortran 2008 Syntax 🌸

USE mpi_f08
MPI_Win_unlock(rank, win, ierror)
     INTEGER, INTENT(IN) :: rank
     TYPE(MPI_Win), INTENT(IN) :: win
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

πŸ“ INPUT PARAMETERS πŸ“

  • rank β€” rank of the window. nonnegative integer, so keep it cute and keep it >= 0 πŸ’…
  • win β€” the window object (handle). the whole point of the operation, honestly.

πŸŽ€ OUTPUT PARAMETER πŸŽ€

  • ierror β€” Fortran only: error status (integer).

πŸ‘‘ DESCRIPTION πŸ‘‘

MPI_Win_unlock completes an RMA access epoch that was started by a call to MPI_Win_lock. and the way it does that is so thorough: any RMA operations you issued during that period will have completed both at the origin and at the target by the time this call returns. both sides. no loose ends. iconic ✨

so what are locks even for? locks protect accesses to the locked target window that were made by RMA calls issued between the lock and the unlock call, AND they protect local load/store accesses to a locked local window that you executed between the lock and the unlock call. yes, local load/store too, don't forget the local side bestie 🫢

and here's the exclusivity tea:

  • 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

read that twice, it's giving subtle. 🌈


πŸ’€ ERRORS πŸ’€

almost all MPI routines return an error value, okay? C routines hand it back as the return result of the function, and Fortran routines put it in that last argument. classic.

before the error value is returned, the current MPI error handler associated with the communication object (e.g., communicator, window, file) gets called. and if there's no communication object associated with the MPI call? then the call is considered attached to MPI_COMM_SELF and will call the associated MPI error handler. and when MPI_COMM_SELF is not initialized β€” meaning before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when you're using the Sessions Model exclusively β€” the error raises the initial error handler. you can change that initial error handler by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when you're using the World model, or with the mpi_initial_errhandler CLI argument to mpiexec, or with an info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. πŸ™ˆ

and if no other appropriate error handler has been set, then MPI_ERRORS_RETURN is called for MPI I/O functions and MPI_ERRORS_ABORT is called for all other MPI functions.

Open MPI ships three predefined error handlers you can use, and they are:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. like, everyone. gone. πŸ’€
  • 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, no drama, just a code 🫢

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

  • MPI_Comm_create_errhandler and then MPI_Comm_set_errhandler
  • MPI_File_create_errhandler and then MPI_File_set_errhandler
  • MPI_Session_create_errhandler and then MPI_Session_set_errhandler, or at MPI_Session_init
  • MPI_Win_create_errhandler and then MPI_Win_set_errhandler
⚠️ note that MPI does not guarantee that an MPI program can continue past an error. so like, plan accordingly bestie 😭

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

and also, literally:

  • MPI_Win_lock
  • MPI_Win_unlock_all

2003-2026, The Open MPI Community


that's the whole page, bestie πŸ’œ this dropped Sep 10, 2026, it's the MPI_WIN_UNLOCK(3) page, and it lives under Open MPI. go close your access epochs responsibly, lock and unlock, always in pairs, iykyk 🧚✨

πŸ“¦ where this page comes from