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 in array_of_displacements and array_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 of MPI_Aint, Fortran: array of integer). yes, bytes β€” that's the whole point of the h, 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 if MPI_Abort was called on that communicator. if called on a window or file, acts as if MPI_Abort was 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_errhandler then MPI_Comm_set_errhandler
  • MPI_File_create_errhandler then MPI_File_set_errhandler
  • MPI_Session_create_errhandler then MPI_Session_set_errhandler or at MPI_Session_init
  • MPI_Win_create_errhandler then MPI_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_struct
  • MPI_Type_create_hvector
  • MPI_Type_indexed

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