MPI_Type_get_value_index(3)

πŸ’– MPI_Type_get_value_index β€” the manual page, but make it cute

okay bestie, so this is the page for MPI_Type_get_value_index from the MPI manual (section 3, the library-call girlies 🧚). Sit down, grab a strawberry lemonade, and let's get into it.


✨ NAME ✨

MPI_Type_get_value_index β€” hands you back a handle to a predefined datatype that's suitable for using with MPI_MINLOC and MPI_MAXLOC, but only if such a predefined type actually exists. if it doesn't? well. that's a whole thing. πŸ™ˆ


🌸 SYNOPSIS 🌸

int MPI_Type_get_value_index(MPI_Datatype value_type, MPI_Datatype index_type,
MPI_Datatype *pair_type)

πŸ’… INPUT PARAMETERS πŸ’…

  • value_type β€” the datatype of the value in the pair (it's a handle, bestie)
  • index_type β€” the datatype of the index in the pair (also a handle)

πŸŽ€ OUTPUT PARAMETERS πŸŽ€

  • pair_type β€” the datatype of the value-index pair (yep, also a handle)

πŸ”₯ THREAD AND INTERRUPT SAFETY πŸ”₯

This routine is thread-safe, no cap. that means multiple threads can use it at the same time and you do not need to bring your own user-provided thread locks. she handles herself. πŸ’…

bUT. and this is the important part. the routine is not interrupt safe. why? typically it's because of memory allocation routines like malloc, or other non-MPICH runtime routines, that are themselves not interrupt-safe. so like, not her fault, it's the friend group she's running with 😭


🌈 NOTES FOR FORTRAN 🌈

Every single MPI routine in Fortran (except MPI_WTIME and MPI_WTICK, the special little exceptions) has an extra argument at the end of the argument list called ierr. ierr is an integer and it means the exact 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. periodt.

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


πŸ’€ ERRORS πŸ’€

okay so all MPI routines (again, except MPI_Wtime and MPI_Wtick) return an error value β€” C routines as the value of the function, and Fortran routines in that last argument. before the value gets returned, the current MPI error handler is called.

🚨 by default, that error handler aborts the MPI job. like, whole program, gone. bestie, do not play with this.

you can change the error handler:

  • MPI_Comm_set_errhandler β€” for communicators
  • MPI_File_set_errhandler β€” for files
  • MPI_Win_set_errhandler β€” for RMA windows

there's also the MPI-1 routine MPI_Errhandler_set, which may be used, but its use is deprecated πŸ‘€ (so like, iykyk, don't do it).

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

and note: MPI does not guarantee that an MPI program can continue past an error. however, MPI implementations will attempt to continue whenever possible. so it's giving hope, but conditional hope. 🫢

Here's the error list, one by one:

  • MPI_SUCCESS β€” no error; the MPI routine completed successfully. we love a clean run ✨
  • MPI_ERR_ARG β€” invalid argument. some argument is invalid and it's not identified by a specific error class (e.g., MPI_ERR_RANK). vague?? iconic?? 😭
  • 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, it's the bare minimum
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to get more information about this error code. it's the "miscellaneous" pile and she's still valid

anyway that's the whole page, you ate that, go call MPI_Type_get_value_index responsibly 🌟

this was MPI_Type_get_value_index(3), baby β€” version dated 4/10/2026, and it lives in the MPI section 3 manual set. mwah, take care of her πŸ’–

πŸ“¦ where this page comes from