MPI_Type_create_hindexed(3)

πŸ“¦
version 5.0.1 Β· 5 versions
, in nixos 26.05, ubuntu stonking

πŸ’… MPI_Type_create_hindexed β€” bestie's guide πŸ’…

okay so this is from the MPI manual, section 3 (that's the library-functions girlies, obviously), and it's literally the glow-up tool for making a datatype that's an indexed datatype but with its displacements measured in bytes instead of in extents. no cap.

✨ NAME ✨

MPI_Type_create_hindexed β€” Create a datatype for an indexed datatype with displacements in bytes πŸ¦‹

🌸 SYNOPSIS 🌸

int MPI_Type_create_hindexed(int count, const int array_of_blocklengths[],
const MPI_Aint array_of_displacements[],
MPI_Datatype oldtype, MPI_Datatype *newtype)
int MPI_Type_create_hindexed_c(MPI_Count count,
const MPI_Count array_of_blocklengths[],
const MPI_Count array_of_displacements[],
MPI_Datatype oldtype, MPI_Datatype *newtype)

look at her. two whole forms. the big-girl _c version with MPI_Count for when your counts are giving astronomically huge πŸ”₯


πŸŽ€ INPUT PARAMETERS πŸŽ€

  • count β€” the number of blocks, and ALSO the number of entries in array_of_displacements and array_of_blocklengths. it's a non-negative integer bestie, don't play games πŸ’€
  • array_of_blocklengths β€” how many elements are in each block (non-negative integer, obviously)
  • array_of_displacements β€” the byte displacement of each block (an integer)
  • oldtype β€” the old datatype (that's a handle, mwah)

πŸ’– OUTPUT PARAMETERS πŸ’–

  • newtype β€” the new datatype, your freshly served handle (also a handle)

🧚 THREAD AND INTERRUPT SAFETY 🧚

so this routine is thread-safe. periodt. that means multiple threads can use it at the same time and you do NOT need to bring your own thread locks, she handles herself πŸ‘‘

but um. she is not interrupt safe. the way that this is a thing is typically because of memory allocation routines like malloc or other non-MPICH runtime routines that are themselves not interrupt-safe. so like. mind the gap πŸ™ˆ


🌈 NOTES FOR FORTRAN 🌈

every MPI routine in Fortran (except for MPI_WTIME and MPI_WTICK, those two are the exceptions, they're built different) has an extra argument called ierr chilling at the end of the argument list. ierr is an integer and it means exactly the same thing as the return value of the routine in C. in Fortran, MPI routines are subroutines, and you invoke them with the call statement. yes, call. svc.

also, all MPI objects (like MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. that's just the vibe over there πŸ’œ


πŸ’€ ERRORS πŸ’€

all MPI routines (except MPI_Wtime and MPI_Wtick) return an error value. C routines give it back as the value of the function, and Fortran routines put it in the last argument. before that value comes back at you, the current MPI error handler gets called. by default, this error handler literally aborts the whole MPI job 😭 so like, don't be sloppy bestie.

you can change the error handler with MPI_Comm_set_errhandler (for communicators), MPI_File_set_errhandler (for files), and MPI_Win_set_errhandler (for RMA windows). the MPI-1 routine MPI_Errhandler_set may be used but its use is deprecated β€” so like, we don't do that anymore, it's giving 1994.

the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned instead.

⚠️ note that MPI does not guarantee that an MPI program can continue past an error. however, MPI implementations will attempt to continue whenever possible. key word attempt πŸ’…
  • MPI_SUCCESS β€” no error, the routine completed successfully. slay! ✨
  • MPI_ERR_ARG β€” invalid argument. some argument is invalid and is not identified by a specific error class (e.g., MPI_ERR_RANK).
  • MPI_ERR_COUNT β€” invalid count argument. count arguments must be non-negative; a count of zero is often valid. (yes, zero can be valid, she's not like other counts πŸ’…)
  • MPI_ERR_TYPE β€” invalid datatype argument. additionally, this error can occur if an uncommitted MPI_Datatype (see MPI_Type_commit) is used in a communication call. commit your types bestie, don't be sending out uncommitted datatypes, embarrassing 😳
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to get more information about this error code.

and that's the whole page, no notes, you ate this fr fr 🫢

this has been the MPI manual, page MPI_Type_create_hindexed(3), dated 4/10/2026 β€” sending you all the love, go build something iconic with it πŸ‘‘πŸ’–β­

πŸ“¦ where this page comes from