MPI_Win_shared_query(3)
πΈ MPI_Win_shared_query β the MPI_Win_shared_query(3) page, but make it cute πΈ
okay bestie, sit down, hydrate, because we're about to ask a shared memory window exactly where its little patch of memory lives and how big it is π this is MPI_Win_shared_query from the MPI manual (you know, section 3, the good section) β¨
β¨ NAME β¨
MPI_Win_shared_query β query the size and base pointer for a patch of a shared memory window π«Ά like, "hi window, bestie, whatcha got and where is it"
π SYNOPSIS π
int MPI_Win_shared_query(MPI_Win win, int rank, MPI_Aint *size, int *disp_unit,
void *baseptr)
int MPI_Win_shared_query_c(MPI_Win win, int rank, MPI_Aint *size,
MPI_Aint *disp_unit, void *baseptr)
yes there are two of them, the plain one and the _c one, and ngl the _c one is just giving slightly different types energy π
π INPUT PARAMETERS π
winβ the shared memory window object (a handle, she's a whole situation)rankβ rank in the group of windowwin, orMPI_PROC_NULL(a non-negative integer, no cap)
π¦ OUTPUT PARAMETERS π¦
sizeβ size of the window segment (non-negative integer, so zero is allowed, we love a zero)disp_unitβ local unit size for displacements, in bytes (positive integer, pls be positive)baseptrβ address for load/store access to the window segment (a choice π )
π NOTES π
The baseptr that comes back to you points to the calling process's address space, specifically at the shared segment belonging to the target rank. that's the whole vibe, no cap π§
π₯ THREAD AND INTERRUPT SAFETY π₯
This routine is thread-safe, periodt. That means you can safely call it from multiple threads and you do not need to bring your own user-provided thread locks, she handles herself π
BUT β and this is the important part, bestie β the routine is not interrupt safe π typically this is because of memory allocation routines like malloc, or other non-MPICH runtime routines that are themselves not interrupt-safe. so like... don't interrupt her mid-glow-up, iykyk.
π NOTES FOR FORTRAN π
All MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK) have an additional argument ierr at the end of the argument list. ierr is an integer and has the same meaning as the return value of the routine in C. In Fortran, MPI routines are subroutines, and they're invoked with the call statement β Fortran was like "we do things differently here" and honestly, valid π
All MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. iconic behavior, no notes.
π ERRORS π
All MPI routines (except MPI_Wtime and MPI_Wtick) return an error value; C routines as the value of the function and Fortran routines in the last argument. Before that value is returned, the current MPI error handler gets called. By default, this error handler aborts the MPI job π so like, she's dramatic by default.
The error handler may be changed with:
MPI_Comm_set_errhandler(for communicators)MPI_File_set_errhandler(for files)MPI_Win_set_errhandler(for RMA windows)
The MPI-1 routine MPI_Errhandler_set may be used but its use is deprecated β so lowkey don't, bestie.
The predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned instead of the whole job just evaporating.
Note that MPI does not guarantee that an MPI program can continue past an error; however, MPI implementations will attempt to continue whenever possible. so like... she'll try her best, but no promises π
Here are the error codes, the whole set, no skips:
MPI_SUCCESSβ No error; MPI routine completed successfully. slay πMPI_ERR_ARGβ Invalid argument. Some argument is invalid and is not identified by a specific error class (e.g.,MPI_ERR_RANK).MPI_ERR_RANKβ Invalid source or destination rank. Ranks must be between zero and the size of the communicator minus one; ranks in a receive (MPI_Recv,MPI_Irecv,MPI_Sendrecv, etc.) may also beMPI_ANY_SOURCE.MPI_ERR_WINβ Invalid MPI window object π she does not recognize that window, sorry.MPI_ERR_OTHERβ Other error; useMPI_Error_stringto get more information about this error code.
π SEE ALSO π
MPI_Win_allocate_shared
fr fr, that's the whole page, nothing skipped, every flag and error code accounted for, main character energy only π
okay bye bestie, love u, go query those windows π«Ά this was the MPI_Win_shared_query(3) page from the MPI manual, dated 4/10/2026 β¨ mwah π
π¦ where this page comes from
- nixos 26.05: mpich 5.0.1
- ubuntu stonking: mpich-doc 5.0.1-9 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms