MPI_WIN_SHARED_QUERY(3)
π MPI_Win_shared_query β Query a shared memory window
okay bestie, welcome to the MPI_WIN_SHARED_QUERY(3) page from the Open MPI manual β yes that's the manual name, consider it folded in and slayed β¨ This is the whole thing, every crumb, no cap.
β¨ SYNTAX β¨
πΈ C Syntax
#include <mpi.h>
int MPI_Win_shared_query (MPI_Win win, int rank, MPI_Aint *size,
int *disp_unit, void *baseptr)
π Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_WIN_SHARED_QUERY(WIN, RANK, SIZE, DISP_UNIT, BASEPTR, IERROR)
INTEGER WIN, RANK, DISP_UNIT, IERROR
INTEGER(KIND=MPI_ADDRESS_KIND) SIZE, BASEPTR
π¦ Fortran 2008 Syntax
USE mpi_f08
MPI_Win_shared_query(win, rank, size, disp_unit, baseptr, ierror)
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
TYPE(MPI_Win), INTENT(IN) :: win
INTEGER, INTENT(IN) :: rank
INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(OUT) :: size
INTEGER, INTENT(OUT) :: disp_unit
TYPE(C_PTR), INTENT(OUT) :: baseptr
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π INPUT PARAMETERS π
winβ your shared memory window object (it's a handle, bestie β hold it gently π«Ά).rankβ the rank inside the group of windowwin, and it's a non-negative integer β ORMPI_PROC_NULL. those are your two moods, pick one π .
β OUTPUT PARAMETERS β
sizeβ how big the window segment is (a non-negative integer, she's giving measurements π).disp_unitβ the local unit size for displacements, in bytes (a positive integer β bytes, always bytes).baseptrβ the address you use for load/store access to that window segment (it's a choice, literally).ierrorβ Fortran girlies only: error status, and yes it's an integer π.
π DESCRIPTION π
so MPI_Win_shared_query queries the process-local address for remote memory segments that were created with MPI_Win_allocate_shared. And here's the iconic plot twist: this function can totally return different process-local addresses for the same physical memory on different processes. yes, same memory, different addresses, main character energy on every rank π
The memory it hands you back can be used for load/store accesses β but only subject to the constraints defined in MPI-3.1 section 11.7. read that section, i'm begging π
Also: this function can only be called with windows of flavor MPI_WIN_FLAVOR_SHARED. If the window you passed isn't that flavor, the error MPI_ERR_RMA_FLAVOR gets raised. wrong vibe detected, call rejected π
And when rank is MPI_PROC_NULL, the pointer, disp_unit, and size you get back are the pointer, disp_unit, and size of the memory segment belonging to the lowest rank that specified size > 0 β like, she goes looking for the first rank that actually brought something to the group chat.
And if all the processes in the group attached to the window specified size = 0? Then the call returns size = 0 and a baseptr as if MPI_Alloc_mem was called with size = 0. empty window, empty vibes, still valid π«
π§ C NOTES π§
The parameter baseptr is of type void * so that you can pass any pointer object for it. The argument you provide should be a pointer to a pointer of arbitrary type (e.g. void **). double pointer, double the fun, iykyk β¨
π ERRORS π
Almost all MPI routines return an error value β C routines hand it back as the return result of the function, and Fortran routines put it in the last argument. classic.
Before that 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. That 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. okay? okay π«Ά
Open MPI includes three predefined error handlers you can use β lineup time:
MPI_ERRORS_ARE_FATALβ Causes the program to abort all connected MPI processes. everyone's leaving the party, no survivors π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, acts as ifMPI_Abortwas called on a communicator containing the group of processes in the corresponding window or file. If called on a session, aborts only the local process. context-aware chaos, honestly iconic.MPI_ERRORS_RETURNβ Returns an error code to the application. the polite one. she just tells you and lets you deal π
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. like, fr fr, don't assume you can just keep going after one.
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_Alloc_memMPI_Win_allocate_shared
π COPYRIGHT π
2003-2026, The Open MPI Community
and that's the whole page bestie, go forth and share your memory safely πβ¨
kisses from the Open MPI girlies β this was MPI_WIN_SHARED_QUERY(3), dated Sep 11, 2026, mwah π
π¦ 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