MPI_Type_create_darray(3)

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

✨ MPI_Type_create_darray πŸ’– β€” the vibe check

okay bestie so this is a page from the MPI manual, and honestly? it's giving "let's build a datatype that describes a whole distributed array across your process grid" πŸ‘‘

🌸 NAME 🌸

MPI_Type_create_darray β€” create a datatype representing a distributed array. no cap, that's literally the whole job. πŸ¦‹


πŸ“œ SYNOPSIS πŸ“œ

int MPI_Type_create_darray(int size, int rank, int ndims,
const int array_of_gsizes[],
const int array_of_distribs[],
const int array_of_dargs[],
const int array_of_psizes[], int order,
MPI_Datatype oldtype, MPI_Datatype *newtype)

int MPI_Type_create_darray_c(int size, int rank, int ndims,
const MPI_Count array_of_gsizes[],
const int array_of_distribs[],
const int array_of_dargs[],
const int array_of_psizes[], int order,
MPI_Datatype oldtype, MPI_Datatype *newtype)

two flavors, both iconic πŸ’… β€” the regular one and the _c one that takes MPI_Count for the global sizes. pick your fighter.


🧸 INPUT PARAMETERS 🧸

the stuff you gotta hand over before the magic happens ✨

  • size β€” size of process group (positive integer). how many of y'all are in the group chat, basically.
  • rank β€” rank in process group (non-negative integer). which one of you this call is for. main character identification, fr fr.
  • ndims β€” number of array dimensions as well as process grid dimensions (positive integer). yes, both. same number. cute of it honestly.
  • array_of_gsizes β€” number of elements of type oldtype in each dimension of global array (positive integer).
  • array_of_distribs β€” distribution of array in each dimension (state). state, bestie. not an integer. it's a vibe.
  • array_of_dargs β€” distribution argument in each dimension (positive integer).
  • array_of_psizes β€” size of process grid in each dimension (positive integer).
  • order β€” array storage order flag (state). also a state, not a number. slay.
  • oldtype β€” old datatype (handle). the base serving as the starting point 🫢

🎁 OUTPUT PARAMETERS 🎁

  • newtype β€” new datatype (handle). the glow-up. you get a handle back, you're so welcome πŸ’–

πŸ”’ THREAD AND INTERRUPT SAFETY πŸ”’

This routine is thread-safe. Meaning: multiple threads can use it at the same time and you do NOT need to bring your own thread locks. no gatekeeping, no drama. ✨

BUT β€” and this is the important part 😭 β€” it is not interrupt safe. Typically that's because it uses memory allocation routines like malloc, or other non-MPICH runtime routines, and those are themselves not interrupt-safe. so like… don't interrupt it mid-glow-up. periodt.


🏰 NOTES FOR FORTRAN 🏰

  • Every single MPI routine in Fortran (except for MPI_WTIME and MPI_WTICK) gets an extra argument ierr tacked onto the end of its argument list. ierr is an integer and it means the same thing as the return value does in C. πŸ“
  • In Fortran, MPI routines are subroutines and you invoke them with the call statement. classic Fortran behavior, respect it.
  • All MPI objects (like MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. that's just how it is over there. 🀷

πŸ’€ ERRORS πŸ’€

okay so this is the part where things can go wrong, and we need to talk about it.

All MPI routines (except MPI_Wtime and MPI_Wtick) return an error value β€” C routines return it as the value of the function, and Fortran routines return it in that last argument. Before that value comes back to you, the current MPI error handler gets called. By default, this error handler aborts the MPI job πŸ’₯ (yes, the whole thing, no cap).

You can swap the error handler out with:

  • MPI_Comm_set_errhandler (for communicators)
  • MPI_File_set_errhandler (for files)
  • MPI_Win_set_errhandler (for RMA windows)

The MPI-1 routine MPI_Errhandler_set may be used but its use is deprecated πŸ™ˆ (we don't do that anymore, bestie).

The predefined error handler MPI_ERRORS_RETURN may be used to make error values get returned instead.

heads up: MPI does not guarantee that an MPI program can continue past an error. however, MPI implementations will attempt to continue whenever possible. best effort only, respectfully. 😭

here's the error roster:

  • MPI_SUCCESS β€” no error; the MPI routine completed successfully. we love to see it πŸ‘‘
  • MPI_ERR_ARG β€” invalid argument. some argument is invalid and it is not identified by a specific error class (e.g., MPI_ERR_RANK). vague on purpose, sorry babe.
  • MPI_ERR_TYPE β€” invalid datatype argument. additionally, this one can show up if an uncommitted MPI_Datatype (see MPI_Type_commit) is used in a communication call. commit your datatypes, i am begging you 🫠
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to get more information about this error code. it's the "idk figure it out" of error codes πŸ”₯

🌸 that's the whole page, bestie! this one came from the MPI manual, dated 4/10/2026, and it lives at MPI_Type_create_darray(3) in the manual pages. go build your distributed array, you're doing amazing πŸŽ€πŸ’œβœ¨

πŸ“¦ where this page comes from