MPI_Type_create_darray(3)
β¨ 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 typeoldtypein 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_WTIMEandMPI_WTICK) gets an extra argumentierrtacked onto the end of its argument list.ierris 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
callstatement. classic Fortran behavior, respect it. - All MPI objects (like
MPI_Datatype,MPI_Comm) are of typeINTEGERin 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 uncommittedMPI_Datatype(seeMPI_Type_commit) is used in a communication call. commit your datatypes, i am begging you π«MPI_ERR_OTHERβ other error; useMPI_Error_stringto 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
- 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