MPI_Win_create(3)

πŸ“¦
version 5.0.1 Β· 5 versions
, in nixos 26.05, ubuntu stonking

πŸ’– 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's MPI_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 to same_op, the implementation assumes all concurrent accumulate calls to the same target address use the same operation. if you set it to same_op_no_op, the implementation assumes all concurrent accumulate calls to the same target address use the same operation or MPI_NO_OP. this can eliminate the need to protect access for certain operation types where the hardware can guarantee atomicity. the default is same_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 is 0, 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 in MPI_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 Info
  • MPI_ERR_SIZE β€” (also no description in the original. nothing. empty. we report the silence.) πŸ¦‹
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to get more information about this error code.

🌈 SEE ALSO 🌈

  • MPI_Win_allocate
  • MPI_Win_allocate_shared
  • MPI_Win_create_dynamic
  • MPI_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