MPI_Win_create(3)
π MPI_Win_create(3) π
okay bestie, so this is the MPI manual β yes, that MPI, the message-passing one β and today we're doing MPI_Win_create, aka the rite of passage where you build a one-sided communication window. one-sided!! like you don't even have to knock, you just reach in. main character energy fr fr. π¦
β¨ NAME β¨
MPI_Win_create β Create an MPI Window object for one-sided communication π
πΈ SYNOPSIS πΈ
int MPI_Win_create(void *base, MPI_Aint size, int disp_unit, MPI_Info info,
MPI_Comm comm, MPI_Win *win)
int MPI_Win_create_c(void *base, MPI_Aint size, MPI_Aint disp_unit,
MPI_Info info, MPI_Comm comm, MPI_Win *win)
two flavors, same vibe. the _c one takes a MPI_Aint for disp_unit instead of an int, iykyk. β¨
π INPUT PARAMETERS π
baseβ the initial address of the window, and yes it's a choice type (choice). pick your pointer vibe. π«Άsizeβ size of the window in bytes. non-negative integer, so likeβ¦ zero is fine, negative is NOT. πdisp_unitβ the local unit size for displacements, in bytes. positive integer pls. this is the scaling factor, hold that thought. πinfoβ the info argument (handle). optimization hints live here!commβ an intra-communicator (handle). the group chat, basically.
π OUTPUT PARAMETERS π
winβ the window object (handle). congrats, you birthed a window. π
π NOTES π
so disp_unit? the whole reason it exists is to make address arithmetic in RMA operations not be a nightmare: the target displacement argument of an RMA operation gets scaled by the factor disp_unit that the target process specified, right at window creation. that's the whole trick. β¨
the info argument is basically your little note to the runtime like "hey, here's how i'm prob gonna use this window", so it can optimize. these are the predefined info keys, bestie β memorize them, it's giving study guide:
no_locksβ if you set it to true, the implementation is allowed to assume that passive target synchronization (that'sMPI_Win_lock,MPI_Win_lock_all) will not be used on this window. this implies the window isn't used for 3-party communication, and RMA can be implemented with no (or less) asynchronous agent activity at this process. lowkey huge.accumulate_orderingβ controls the ordering of accumulate operations at the target. the argument string should be a comma-separated list of these read/write ordering rules, where for example"raw"means read-after-write:"rar,raw,war,waw".accumulate_opsβ if you set it tosame_op, the implementation assumes all concurrent accumulate calls to the same target address use the same operation. if you set it tosame_op_no_op, the implementation assumes all concurrent accumulate calls to the same target address use the same operation orMPI_NO_OP. this can eliminate the need to protect access for certain operation types where the hardware can guarantee atomicity. the default issame_op_no_op. πmpi_accumulate_granularityβ controls the desired synchronization granularity for accumulate ops. it sets the size of the memory range, in bytes, for which the MPI library should grab a synchronization primitive to guarantee atomicity of updates. the default is0, which lets the MPI library decide the granularity itself. when the info hint is set to a positive value, the actual range of synchronization is rounded up to the next size that fits the datatype used in the accumulate operation (see MPI standard 4.1). and listen β all processes in the group of a window must set the same value. no lone wolf behavior. π¨
(yes the original really spells it "synchroniation" in that one spot. we don't fix, we report. π )
π§ THREAD AND INTERRUPT SAFETY π§
this routine is thread-safe. that means multiple threads can use it safely with zero user-provided thread locks. slay. β¨
BUT. it is not interrupt safe. typically that's because it uses memory allocation routines like malloc or other non-MPICH runtime routines, and those little guys are themselves not interrupt-safe. so don't be chaotic about it. π
π NOTES FOR FORTRAN π
every MPI routine in Fortran (except for MPI_WTIME and MPI_WTICK) has an extra argument, ierr, at the very end of the argument list. ierr is an integer and means the exact same thing as the return value of the routine in C. in Fortran, MPI routines are subroutines, and you invoke them with the call statement. periodt.
all MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. periodt x2. π
π₯ 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 that last argument. before the value comes back, the current MPI error handler gets called. by default, this error handler aborts the MPI job. dramatic, but real. π
you can swap the error handler with MPI_Comm_set_errhandler (for communicators), MPI_File_set_errhandler (for files), and MPI_Win_set_errhandler (for RMA windows). the MPI-1 routine MPI_Errhandler_set may be used but its use is deprecated. π the predefined handler MPI_ERRORS_RETURN can be used to make error values actually get returned instead of aborting.
heads up: MPI does not guarantee that an MPI program can continue past an error. that said, MPI implementations will attempt to continue whenever possible. so... hope. π«Ά
here's the error lineup:
MPI_SUCCESSβ no error; the MPI routine completed successfully. we love a success arc. πMPI_ERR_ARGβ invalid argument. some argument is invalid and isn't identified by a specific error class (e.g.,MPI_ERR_RANK).MPI_ERR_COMMβ invalid communicator. a common one: using a null communicator in a call (not even allowed inMPI_Comm_rank). πMPI_ERR_DISPβ (the original gives no description here, so bestie, that's the whole entry. blank. iconic in a cursed way.) πΈMPI_ERR_INFOβ Invalid InfoMPI_ERR_SIZEβ (also no description in the original. nothing. empty. we report the silence.) π¦MPI_ERR_OTHERβ other error; useMPI_Error_stringto get more information about this error code.
π SEE ALSO π
MPI_Win_allocateMPI_Win_allocate_sharedMPI_Win_create_dynamicMPI_Win_free
and that's the whole page, bestie!! go build a window, set your disp_unit right, and remember: not interrupt safe, but extremely iconic. π
this was from the MPI manual, version dated 4/10/2026, page MPI_Win_create(3) β mwah, sending you off with a kiss and a memory leakβfree goodbye πβ¨
π¦ 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