MPI_Pack_external(3)
β¨ MPI_Pack_external β¨
okay bestie, welcome to the MPI_Pack_external page from the MPI manual set π this is the one that takes your cute little datatype and squishes it into contiguous memory using the external32 format. iykyk.
πΈ NAME πΈ
MPI_Pack_external β packs a datatype into contiguous memory, using the external32 format π«Ά
π SYNOPSIS π
int MPI_Pack_external(const char *datarep, const void *inbuf, int incount,
MPI_Datatype datatype, void *outbuf, MPI_Aint outsize,
MPI_Aint *position)
int MPI_Pack_external_c(const char *datarep, const void *inbuf,
MPI_Count incount, MPI_Datatype datatype, void *outbuf,
MPI_Count outsize, MPI_Count *position)
two whole flavors, no cap π
π INPUT PARAMETERS π
datarepβ the data representation, and it's a string bestie β¨inbufβ where the input buffer starts (a choice)incountβ how many input data items you're bringing (an integer)datatypeβ the datatype of each one of those input data items (a handle)outsizeβ the size of the output buffer, measured in bytes (an integer)
π¦ INPUT/OUTPUT PARAMETERS π¦
positionβ the current position in the buffer, in bytes (an integer). it goes in, and it comes back out, main character energy fr fr π
π OUTPUT PARAMETERS π
outbufβ where the output buffer starts (a choice)
π₯ THREAD AND INTERRUPT SAFETY π₯
okay so the good news: this routine is thread-safe. that means multiple threads can use it safely with zero user-provided thread locks, no babysitting required π«Ά
the less good news: it 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β¦ interrupt at your own risk π
π NOTES FOR FORTRAN π
every MPI routine in Fortran (except MPI_WTIME and MPI_WTICK) has one extra argument at the end called ierr. ierr is an integer and it 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 β¨
also, all MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. iconic honestly π
π ERRORS π
every MPI routine (except MPI_Wtime and MPI_Wtick) returns an error value β C routines as the value of the function, and Fortran routines in that last argument. before the value gets returned, the current MPI error handler gets called. by default, this error handler aborts the MPI job π³ so yeah, dramatic.
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 β so like, don't π
the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned. note that MPI does not guarantee that an MPI program can continue past an error; however, MPI implementations will attempt to continue whenever possible πͺ
MPI_SUCCESSβ no error, the MPI routine completed successfully, we love to see it π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_COUNTβ invalid count argument. count arguments must be non-negative; a count of zero is often valid.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 bestie π€MPI_ERR_OTHERβ other error; useMPI_Error_stringto get more information about this error code.
lowkey reminder: don't use an uncommittedMPI_Datatypein a communication call. that's aMPI_ERR_TYPEwaiting to happen π«£
and that's the whole page bb!! this was version MPI_Pack_external(3) from the MPI manual, dated 4/10/2026. slay, go pack something π
β¨
π¦ 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