MPI_Put(3)

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

πŸ’– MPI_Put(3) β€” the MPI girlies' guide to yeeting data into somebody else's memory window πŸ’–

okay so bestie. picture this. you're chilling on your little rank, and your friend on another rank has a memory window open, and you're like "hmm. what if I just. put my data in there." and that's literally it. that's the whole function. MPI_Put puts data into a memory window on a remote process. no cap.

<divider>


✨ NAME ✨

MPI_Put β€” put data into a memory window on a remote process 🫢


✨ SYNOPSIS ✨

int MPI_Put(const void *origin_addr, int origin_count,
MPI_Datatype origin_datatype, int target_rank, MPI_Aint target_disp,
int target_count, MPI_Datatype target_datatype, MPI_Win win)

int MPI_Put_c(const void *origin_addr, MPI_Count origin_count,
MPI_Datatype origin_datatype, int target_rank,
MPI_Aint target_disp, MPI_Count target_count,
MPI_Datatype target_datatype, MPI_Win win)

two flavours, because of course. the classic one with int counts, and the _c one with MPI_Count counts for when your numbers are Big. πŸ’…


✨ INPUT PARAMETERS ✨

here's the cast, in order, main character energy only:

  • origin_addr β€” the starting address of your origin buffer (it's a choice, technically, per the original β€” we respect that). this is your stuff, the stuff you're sending.
  • origin_count β€” how many entries are sitting in that origin buffer. non-negative integer, obviously. no negative counts, we don't do that here.
  • origin_datatype β€” the datatype of each entry in the origin buffer. a handle. this is what tells MPI how to read your lil guys.
  • target_rank β€” the rank of the target. like, the friend whose window you're sliding into. non-negative integer.
  • target_disp β€” the displacement from the start of the window over to the target buffer. non-negative integer. this is your little offset, your address within the window, your location.
  • target_count β€” how many entries go in the target buffer. non-negative integer, slay.
  • target_datatype β€” the datatype of each entry in the target buffer. handle. the target's side of the vibe check.
  • win β€” the window object used for communication. handle. this is the whole window situation.

✨ THREAD AND INTERRUPT SAFETY ✨

okay so good news first: this routine is thread-safe πŸ”₯. that means multiple threads can use it with zero user-provided thread locks. you don't have to build a little fence around it, it just behaves.

but bestie. the bad news. it is not interrupt safe 😭. and why? typically it's because of memory allocation routines like malloc, or other non-MPICH runtime routines that are themselves not interrupt-safe. so it's not MPI's fault exactly, it's the company it keeps. still. not interrupt safe. remember it.


✨ NOTES FOR FORTRAN ✨

for my Fortran girlies πŸŽ€ β€” all MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK, the little rebels) have an additional argument ierr at the end of the argument list. ierr is an integer and it means the same thing as the return value of the routine in C. and in Fortran, MPI routines are subroutines, invoked with the call statement. that's the whole vibe.

also! all MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. periodt.


✨ ERRORS ✨

so all MPI routines (except MPI_Wtime and MPI_Wtick) return an error value β€” C routines as the value of the function, Fortran routines in that last argument. and before the value is even returned, the current MPI error handler gets called. by default, that error handler aborts the MPI job. goodbye. no warning. πŸ’€

you can change the 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 β€” do not, ngl. the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned instead. and 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. fingers crossed. 🀞

here's the whole error roster:

  • MPI_SUCCESS β€” no error; the MPI routine completed successfully. we love a clean run. ✨
  • MPI_ERR_BUFFER β€” invalid buffer pointer. usually a null buffer where one is not valid. bestie you cannot pass nothing. πŸ™ˆ
  • MPI_ERR_COUNT β€” invalid count argument. count arguments must be non-negative; a count of zero is often valid. zero is fine! negative is not.
  • MPI_ERR_DISP β€” (the original gives no description here, so I'm just holding the space respectfully. it's giving mystery. πŸ¦‹)
  • 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 be MPI_ANY_SOURCE.
  • MPI_ERR_TYPE β€” invalid datatype argument. additionally, this error can occur if an uncommitted MPI_Datatype (see MPI_Type_commit) is used in a communication call. commit your types!! 😀
  • MPI_ERR_WIN β€” invalid MPI window object. the window is not windowing.
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to get more information about this error code. the catch-all, the it's-complicated one.

✨ SEE ALSO ✨

  • MPI_Rput β€” the sibling, the other one, iykyk 🌈

that's the whole thing bestie, you're officially fluent in MPI_Put. this page is from the MPI manual, MPI_Put(3), dated 4/10/2026 β€” and that's a wrap, mwah πŸ’–πŸ§šπŸ‘‘

πŸ“¦ where this page comes from