MPI_TYPE_CREATE_HINDEXED(3)

πŸ“¦
version 5.0.10 Β· 4 versions
, in ubuntu stonking

πŸ’– MPI_TYPE_CREATE_HINDEXED(3) πŸ’–

okay so this is the Open MPI manual, bestie, and we're about to talk about the most slay little datatype constructor in the whole MPI_Type_* family. buckle up πŸŽ€


✨ NAME ✨

MPI_Type_create_hindexed β€” creates an indexed datatype with offsets in bytes.

🌸 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, aka the number of entries in array_of_displacements and array_of_blocklengths. it's an integer, no cap. πŸ“
  • array_of_blocklengths β€” how many elements live in each block. it's an array of nonnegative integers, so like, be normal about it. ✨
  • array_of_displacements β€” the byte displacement of each block. in C it's an array of MPI_Aint; in Fortran it's an array of integer. ✨
  • oldtype β€” the old datatype, as a handle. the blueprint, the blueprint πŸ’…

πŸ“€ OUTPUT PARAMETERS πŸ“€

  • newtype β€” your brand new datatype handle. main character energy fr fr. πŸ‘‘
  • ierror β€” Fortran only: the error status, as an integer. πŸ™ˆ

πŸ’… DESCRIPTION πŸ’…

so like β€” this function is literally identical to MPI_Type_indexed except for ONE thing, and it's the thing that matters: the block displacements in array_of_displacements are given in bytes, not in multiples of the oldtype extent. that's the whole vibe check. πŸ”₯

say oldtype has 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)}

like, look at that math. it ate. 🫢

🚨 ERRORS 🚨

almost all MPI routines hand back an error value, bestie: C routines give it to you as the return result of the function, and Fortran routines put it in the last argument. πŸŽ€

before that error value even gets returned, the current MPI error handler associated with the communication object (think: communicator, window, file) gets called. if there's no communication object attached to the MPI call, then the call counts as attached to MPI_COMM_SELF and it'll 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 you're using the Sessions Model exclusively), the error raises the initial error handler. and you can change that initial error handler by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when you're in the World model, or by using the mpi_initial_errhandler CLI argument to mpiexec, or the info key to MPI_Comm_spawn / MPI_Comm_spawn_multiple. if no other appropriate error handler has been set, then MPI_ERRORS_RETURN gets called for MPI I/O functions and MPI_ERRORS_ABORT gets called for all the other MPI functions. it's giving "the system has opinions". 😭

Open MPI ships with three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. dramatic, but make it everyone. πŸ’€
  • MPI_ERRORS_ABORT β€” an error handler that can be invoked on a communicator, window, file, or session. when it's called on a communicator, it acts as if MPI_Abort was called on that communicator. if it's called on a window or file, it acts as if MPI_Abort was called on a communicator containing the group of processes in the corresponding window or file. if it's called on a session, it aborts only the local process. ✨
  • MPI_ERRORS_RETURN β€” returns an error code to the application. polite. respectful. πŸŽ€

MPI applications can also implement their own error handlers by calling:

  • MPI_Comm_create_errhandler and then MPI_Comm_set_errhandler
  • MPI_File_create_errhandler and then MPI_File_set_errhandler
  • MPI_Session_create_errhandler and then MPI_Session_set_errhandler, or at MPI_Session_init
  • MPI_Win_create_errhandler and then MPI_Win_set_errhandler
note that MPI does not guarantee that an MPI program can continue past an error. so like, don't count on it, babe. 😭

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


okay that's the whole page, bestie, ily 🫢 it's from Sep 10, 2026 and it lives in the MPI_TYPE_CREATE_HINDEXED(3) slot of the Open MPI manual β€” go build something iconic with it. πŸ’œβœ¨πŸ‘‘

πŸ“¦ where this page comes from