MPI_TYPE_GET_TRUE_EXTENT_X(3)

πŸ’… MPI_TYPE_GET_TRUE_EXTENT_X(3) β€” an Open MPI moment ✨

okay bestie, sit down, because today we're learning about MPI_Type_get_true_extent and MPI_Type_get_true_extent_x β€” the twin icons from the Open MPI manual. They return the true lower bound and extent of a data type's corresponding typemap, and the whole vibe is that they ignore MPI_UB and MPI_LB markers. no cap, that's the entire personality. πŸŽ€


🌸 SYNOPSIS 🌸

✨ C Syntax

#include <mpi.h>

int MPI_Type_get_true_extent(MPI_Datatype datatype,
     MPI_Aint *true_lb, MPI_Aint *true_extent)
int MPI_Type_get_true_extent_x(MPI_Datatype datatype,
     MPI_Count *true_lb, MPI_Count *true_extent)

πŸ¦‹ Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_TYPE_GET_TRUE_EXTENT(DATATYPE, TRUE_LB, TRUE_EXTENT, IERROR)
     INTEGER DATATYPE, IERROR
     INTEGER(KIND=MPI_ADDRESS_KIND) TRUE_LB, TRUE_EXTENT
MPI_TYPE_GET_TRUE_EXTENT_X(DATATYPE, TRUE_LB, TRUE_EXTENT, IERROR)
     INTEGER DATATYPE, IERROR
     INTEGER(KIND=MPI_COUNT_KIND) TRUE_LB, TRUE_EXTENT

🌈 Fortran 2008 Syntax

USE mpi_f08
MPI_Type_get_true_extent(datatype, true_lb, true_extent, ierror)
     TYPE(MPI_Datatype), INTENT(IN) :: datatype
     INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(OUT) :: true_lb, true_extent
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror
MPI_Type_get_true_extent_x(datatype, true_lb, true_extent, ierror)
     TYPE(MPI_Datatype), INTENT(IN) :: datatype
     INTEGER(KIND = MPI_COUNT_KIND), INTENT(OUT) :: true_lb, true_extent
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

πŸ’– INPUT PARAMETER πŸ’–

  • datatype β€” the data type you're being nosy about, bestie. it's a handle, and it's the one you want info on. πŸ‘‘

🫢 OUTPUT PARAMETERS 🫢

  • true_lb β€” the true lower bound of the data type. it's an integer, it's giving "where does the actual data start". ⭐
  • true_extent β€” the true size of the data type. also an integer. literally the real estate footprint, no rounding, no games. πŸ”₯
  • ierror β€” Fortran only, bestie! it's the error status, and yes it's an integer. πŸ’€

🧚 DESCRIPTION 🧚

so the true_lb parameter returns the offset of the lowest unit of store that is addressed by the data type β€” meaning the lower bound of the corresponding typemap, with MPI_LB markers completely ignored. bye to those markers, we don't see them. πŸ™ˆ

and true_extent returns the true size of the data type: the extent of the corresponding typemap, ignoring both MPI_LB and MPI_UB markers, and performing no rounding for alignment. zero alignment glow-up. none. periodt.

for both functions: if either the true_lb or true_extent parameter can't express the value it's supposed to return (like, the parameter is literally too small to hold the output value), it gets set to MPI_UNDEFINED. that's the fallback queen. πŸ‘‘

true_extent is the minimum number of bytes of memory necessary to hold a data type, uncompressed. so it's the raw, un-squished size. πŸ“

if you want the detailed lore and definitions of these parameters in relation to the typemap, go read section 4.1.8 of the MPI-3 standard. iykyk. πŸ“š


😭 ERRORS 😭

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

before that error value comes back, the current MPI error handler associated with the communication object (think: communicator, window, file) gets called. and if there's no communication object attached to the MPI call, then the call is considered attached to MPI_COMM_SELF and it'll call the associated MPI error handler. simple as that.

when MPI_COMM_SELF isn't 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 using the World model, or via the mpi_initial_errhandler CLI argument to mpiexec, or the info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. so many options, so little time. πŸ’…

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 other MPI functions. that's the rule. πŸ¦‹

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 effective. πŸ’€
  • 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, it 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, it aborts only the local process. context is everything, bestie. ✨
  • MPI_ERRORS_RETURN β€” returns an error code to the application. the chill 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. so don't be cute about it. πŸ™ˆ

see the MPI man page for a full list of MPI error codes, and see the Error Handling section of the MPI-3.1 standard for more info. go off, queen. πŸ‘‘πŸ“–


2003-2026, The Open MPI Community


and that's the whole page, bestie!! πŸŽ€βœ¨ no cap, you ate that. stay iconic out there in typemap land β€” πŸ’– signed off from the Open MPI corner of the universe, dated Sep 11, 2026. periodt. πŸ’…πŸŒˆπŸ¦‹

πŸ“¦ where this page comes from