MPI_WIN_FREE(3)
π NAME π
MPI_Win_free β frees the window object and gives you back a null handle, periodt.
(also hi, this is the MPI_WIN_FREE(3) page from Open MPI, section 3, we love a classic β¨)
πΈ SYNTAX πΈ
C Syntax
#include <mpi.h>
int MPI_Win_free(MPI_Win *win)
Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_WIN_FREE(WIN, IERROR)
INTEGER WIN, IERROR
Fortran 2008 Syntax
USE mpi_f08
MPI_Win_free(win, ierror)
TYPE(MPI_Win), INTENT(INOUT) :: win
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π INPUT/OUTPUT PARAMETER π
winβ the window object, aka the handle. π«
π¦ OUTPUT PARAMETER π¦
ierrorβ Fortran only bestie: the error status, an integer. That's it, that's the whole vibe. π
π DESCRIPTION π
Okay so MPI_Win_free frees the window object win and hands you back a null handle (equal to MPI_WIN_NULL). Bye window, you served. π
This is a collective call β meaning it's executed by all processes in the group associated with win. Everybody shows up. No skipping, no lurking. π
And here's the part where you gotta be careful: a process can only invoke it after it has completed its involvement in RMA communications on window win. Translation: the process has to have called MPI_Win_fence, or it has to have called MPI_Win_unlock to match a previous call to MPI_Win_lock. Once you've done your lil RMA duties, you're clear. β
When the call returns, the window memory can be freed. Frozen, freed, done. π§
lowkey the "after you're done with RMA" rule is not a suggestion bestie, it's the whole game π
π NOTES π
If the window was created through MPI_Win_allocate or MPI_Win_allocate_shared, then the memory buffer that got allocated in that call will be freed when you call MPI_Win_free. So likeβ¦ don't double-free it, it's handled. π«Ά
β ERRORS β
Almost all MPI routines return an error value, girlies. In C routines it's the return result of the function, and in Fortran routines it lands in the last argument.
Before that error value is returned, the current MPI error handler associated with the communication object (think: communicator, window, file) gets called. And if there's literally no communication object associated with the MPI call, then that call is considered attached to MPI_COMM_SELF and it'll call the associated MPI error handler.
Now β when MPI_COMM_SELF is not initialized (i.e., 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. And you can change that initial error handler:
- by calling
MPI_Comm_set_errhandleronMPI_COMM_SELFwhen using the World model, or - with the
mpi_initial_errhandlerCLI argument tompiexec, or - with the 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. That's just how it is. π
Open MPI includes three predefined error handlers that you can use:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. drastic but make it fashion π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. iykyk π
See also:
MPI_Win_createMPI_Win_allocateMPI_Win_allocate_shared
π COPYRIGHT π
2003-2026, The Open MPI Community. π
okay that's the whole page bestie, slay, go free those windows responsibly π«Άβ¨ this was the Open MPI MPI_WIN_FREE(3) page, dated Sep 10, 2026 β mwah, no cap, bye π
π
π¦ where this page comes from
- ubuntu stonking: openmpi-doc 5.0.10-6 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms