MPI_TYPE_CREATE_HINDEXED(3)
π MPI_TYPE_CREATE_HINDEXED(3) β Open MPI
okay bestie, sit down, because today we're building a datatype and honestly it's giving artisan craft project β¨ this one lives in the Open MPI world (that's the manual we're in, iykyk) and it's called MPI_Type_create_hindexed β it creates an indexed datatype with offsets in bytes. periodt.
πΈ SYNTAX
π C Syntax
#include <mpi.h>
int MPI_Type_create_hindexed(int count, int *array_of_blocklengths,
MPI_Aint *array_of_displacements, MPI_Datatype oldtype,
MPI_Datatype *newtype)
π¦ Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_TYPE_CREATE_HINDEXED(COUNT, ARRAY_OF_BLOCKLENGTHS,
ARRAY_OF_DISPLACEMENTS, OLDTYPE, NEWTYPE, IERROR)
INTEGER COUNT, ARRAY_OF_BLOCKLENGTHS(*)
INTEGER ARRAY_OF_DISPLACEMENTS(*), OLDTYPE, NEWTYPE
INTEGER IERROR
π INPUT PARAMETERS
countβ the number of blocks, and lowkey also the number of entries inarray_of_displacementsandarray_of_blocklengths(integer). like, they all gotta match, no cap π«Άarray_of_blocklengthsβ how many elements are in each block (array of nonnegative integers). keep it nonnegative bestie, that's the vibe check.array_of_displacementsβ the byte displacement of each block (C: array ofMPI_Aint, Fortran: array of integer). yes, bytes β that's the whole point of theh, we'll get there πoldtypeβ the old datatype (handle).
β¨ OUTPUT PARAMETERS
newtypeβ the new datatype (handle). your fresh new creation, main character energy πierrorβ Fortran only: error status (integer).
π DESCRIPTION
so this function is literally identical to MPI_Type_indexedβ¦ except π the block displacements in array_of_displacements are specified in bytes, rather than in multiples of the oldtype extent. that's it. that's the difference. iconic.
let's say oldtype has the type map
{(type(0), disp(0)), ..., (type(n-1), disp(n-1))},
with extent ex. let B be the array_of_blocklength argument and D be the array_of_displacements argument. the newly created datatype has
n x S^count-1
(i=0) B[i] entries:
{(type(0), disp(0) + D[0]),...,(type(n-1), disp(n-1) + D[0]),...,
(type(0), disp(0) + (D[0] + B[0]-1)* ex),...,
type(n-1), disp(n-1) + (D[0]+ B[0]-1)* ex),...,
(type(0), disp(0) + D[count-1]),...,(type(n-1), disp(n-1) + D[count-1]),...,
(type(0), disp(0) + D[count-1] + (B[count-1] -1)* ex),...,
(type(n-1), disp(n-1) + D[count-1] + (B[count-1] -1)* ex)}
ngl that's a lot of math but likeβ¦ it slays π§
π ERRORS
almost all MPI routines return an error value, bestie β C routines as the return result of the function, and Fortran routines in the last argument. gotta check 'em.
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. dramatic? yes. effective? also yes π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 polite one π«Ά
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. like, fr fr, don't count on it.
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.
π SEE ALSO
MPI_Type_create_structMPI_Type_create_hvectorMPI_Type_indexed
π COPYRIGHT
2003-2026, The Open MPI Community
and that's the whole page, bestie β much love from the Open MPI crew, dated Sep 11, 2026 π go forth and build your weird byte-offset datatypes, you absolute icon πβ¨
π¦ where this page comes from
- arch rolling: openmpi 5.0.11-1 Β· BSD-3-Clause AND LicenseRef-MPICH
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms