MPI_Put(3)
π 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 beMPI_ANY_SOURCE.MPI_ERR_TYPEβ invalid datatype argument. additionally, this error can occur if an uncommittedMPI_Datatype(seeMPI_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; useMPI_Error_stringto 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
- 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