MPI_TYPE_CREATE_DARRAY(3)
π« MPI_TYPE_CREATE_DARRAY β¨
okay bestie, welcome to the Open MPI manual page for MPI_Type_create_darray π yes it makes a distributed array datatype, and yes it's giving big-brain energy. i'm literally so obsessed with this one. sit down, grab a strawberry π, we're doing this together.
πΈ NAME πΈ
MPI_Type_create_darray β Creates a distributed array datatype; (yeah there's a semicolon at the end, that's just canon, don't @ me π
)
π SYNTAX π
β¨ C Syntax β¨
#include <mpi.h>
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)
β¨ Fortran Syntax β¨
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_TYPE_CREATE_DARRAY(SIZE, RANK, NDIMS, ARRAY_OF_GSIZES,
ARRAY_OF_DISTRIBS, ARRAY_OF_DARGS, ARRAY_OF_PSIZES, ORDER,
OLDTYPE, NEWTYPE, IERROR)
INTEGER SIZE, RANK, NDIMS, ARRAY_OF_GSIZES(*), ARRAY_OF_DISTRIBS(*),
ARRAY_OF_DARGS(*), ARRAY_OF_PSIZES(*), ORDER, OLDTYPE,
NEWTYPE, IERROR
β¨ Fortran 2008 Syntax β¨
USE mpi_f08
MPI_Type_create_darray(size, rank, ndims, array_of_gsizes,
array_of_distribs, array_of_dargs, array_of_psizes, order,
oldtype, newtype, ierror)
INTEGER, INTENT(IN) :: size, rank, ndims, array_of_gsizes(ndims),
array_of_distribs(ndims), array_of_dargs(ndims),
array_of_psizes(ndims), order
TYPE(MPI_Datatype), INTENT(IN) :: oldtype
TYPE(MPI_Datatype), INTENT(OUT) :: newtype
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π§ INPUT PARAMETERS π§
here's the whole cast, and every one of them is a main character π«Ά
sizeβ Size of process group (positive integer). no zeros, no negatives, be normal about it πrankβ Rank in process group (nonnegative integer). that's your lil name tag in the group chat.ndimsβ Number of array dimensions as well as process grid dimensions (positive integer). so yes, it's doing double duty, she's versatile πarray_of_gsizesβ Number of elements of typeoldtypein each dimension of global array (array of positive integers). literally "how big is the whole thing" timesndims.array_of_distribsβ Distribution of array in each dimension (array of state). this is where you pick your vibe per dimension, see the three options below πarray_of_dargsβ Distribution argument in each dimension (array of positive integers). the receipts for the distribution choices.array_of_psizesβ Size of process grid in each dimension (array of positive integers). how many processes are stacked along each axis πorderβ Array storage order flag (state). Fortran or C, pick your fighter.oldtypeβ Old data type (handle). the building block, the blueprint, the icon herself.
π OUTPUT PARAMETERS π
newtypeβ New data type (handle). the glow-up, freshly created β¨ierrorβ Fortran only: Error status (integer). only the Fortran girlies get this one π
π¦ DESCRIPTION π¦
so MPI_Type_create_darray can be used to generate the data types corresponding to the distribution of an ndims-dimensional array of oldtype elements onto an ndims-dimensional grid of logical processes. unused dimensions of array_of_psizes should be set to 1 β like, don't leave them blank, set them to 1, okay? π
for a call to MPI_Type_create_darray to be correct, this equation has to be satisfied:
ndims-1
pi array_of_psizes[i] = size
i=0
that's a big pi (the product one) running fromi=0up tondims-1, multiplying all thearray_of_psizes[i]together, and the result has to equalsize. the math girlies ate with this one π₯
the ordering of processes in the process grid is assumed to be row-major, as in the case of virtual Cartesian process topologies in the MPI Standard <https://www.mpi-forum.org/docs/>.
each dimension of the array can be distributed in one of three ways:
MPI_DISTRIBUTE_BLOCKβ Block distributionMPI_DISTRIBUTE_CYCLICβ Cyclic distributionMPI_DISTRIBUTE_NONEβ Dimension not distributed.
the constant MPI_DISTRIBUTE_DFLT_DARG specifies a default distribution argument. the distribution argument for a dimension that is not distributed is ignored β she said "not my problem" π
for any dimension i in which the distribution is MPI_DISTRIBUTE_BLOCK, it erroneous to specify array_of_dargs[i] * array_of_psizes[i] < array_of_gsizes[i].
β οΈ bestie please read that again. that's an error condition, we do not do that. that is a direct violation, no cap.
for example, the HPF layout ARRAY(CYCLIC(15)) corresponds to MPI_DISTRIBUTE_CYCLIC with a distribution argument of 15, and the HPF layout ARRAY(BLOCK) corresponds to MPI_DISTRIBUTE_BLOCK with a distribution argument of MPI_DISTRIBUTE_DFLT_DARG. π
the order argument is used as in MPI_Type_create_subarray to specify the storage order. therefore, arrays described by this type constructor may be stored in Fortran (column-major) or C (row-major) order. valid values for order are MPI_ORDER_FORTRAN and MPI_ORDER_C. π
this routine creates a new MPI data type with a typemap defined in terms of a function called βcyclic()β (see below). π§
without loss of generality, it suffices to define the typemap for the MPI_DISTRIBUTE_CYCLIC case where MPI_DISTRIBUTE_DFLT_DARG is not used. periodt.
MPI_DISTRIBUTE_BLOCK and MPI_DISTRIBUTE_NONE can be reduced to the MPI_DISTRIBUTE_CYCLIC case for dimension i as follows. π
MPI_DISTRIBUTE_BLOCK with array_of_dargs[i] equal to MPI_DISTRIBUTE_DFLT_DARG is equivalent to MPI_DISTRIBUTE_CYCLIC with array_of_dargs[i] set to
(array_of_gsizes[i] + array_of_psizes[i] - 1)/array_of_psizes[i]
if array_of_dargs[i] is not MPI_DISTRIBUTE_DFLT_DARG, then MPI_DISTRIBUTE_BLOCK and DISTRIBUTE_CYCLIC are equivalent. π€
MPI_DISTRIBUTE_NONE is equivalent to MPI_DISTRIBUTE_CYCLIC with array_of_dargs[i] set to array_of_gsizes[i].
finally, MPI_DISTRIBUTE_CYCLIC with array_of_dargs[i] equal to MPI_DISTRIBUTE_DFLT_DARG is equivalent to MPI_DISTRIBUTE_CYCLIC with array_of_dargs[i] set to 1. π
β NOTES β
for both Fortran and C arrays, the ordering of processes in the process grid is assumed to be row-major. this is consistent with the ordering used in virtual Cartesian process topologies in MPI. to create such virtual process topologies, or to find the coordinates of a process in the process grid, etc., users may use the corresponding functions provided in MPI. π you don't have to hand-roll it, bestie, the tooling exists.
π ERRORS π
almost all MPI routines return an error value; C routines as the return result of the function and Fortran routines in the last argument. (yes, that's the ierror besties π)
before the error value is returned, the current MPI error handler associated with the communication object (e.g., communicator, window, file) is called. if no communication object is associated with the MPI call, then the call is considered attached to MPI_COMM_SELF and will call the associated MPI error handler. when MPI_COMM_SELF is not initialized (i.e., before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when using the Sessions Model exclusively) the error raises the initial error handler. the initial error handler can be changed by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or the mpi_initial_errhandler CLI argument to mpiexec or info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. if no other appropriate error handler has been set, then the MPI_ERRORS_RETURN error handler is called for MPI I/O functions and the MPI_ERRORS_ABORT error handler is called for all other MPI functions.
Open MPI includes three predefined error handlers that can be used: π
MPI_ERRORS_ARE_FATALβ Causes the program to abort all connected MPI processes. she's dramatic and she's not sorry πMPI_ERRORS_ABORTβ An error handler that can be invoked on a communicator, window, file, or session. When called on a communicator, it acts as ifMPI_Abortwas called on that communicator. If called on a window or file, acts as ifMPI_Abortwas called on a communicator containing the group of processes in the corresponding window or file. If called on a session, aborts only the local process.MPI_ERRORS_RETURNβ Returns an error code to the application. the chill one, she just hands you the receipt π«Ά
MPI applications can also implement their own error handlers by calling:
MPI_Comm_create_errhandlerthenMPI_Comm_set_errhandlerMPI_File_create_errhandlerthenMPI_File_set_errhandlerMPI_Session_create_errhandlerthenMPI_Session_set_errhandleror atMPI_Session_initMPI_Win_create_errhandlerthenMPI_Win_set_errhandler
note that MPI does not guarantee that an MPI program can continue past an error. π so like, handle your errors, fr fr.
see the MPI man page for a full list of MPI error codes.
see the Error Handling section of the MPI-3.1 standard for more information. π
π Copyright π
2003-2026, The Open MPI Community
okay that's the whole page, you ate that π thanks for reading all the way to the bottom, you're literally the best. this was the OPEN MPI manual, MPI_TYPE_CREATE_DARRAY(3) edition, dated Sep 10, 2026, brought to you by the 2003-2026, The Open MPI Community π now go forth and distribute some arrays, bestie π¦β¨
π¦ where this page comes from
- ubuntu stonking: openmpi-doc 5.0.10-6 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms