MPI_TYPE_GET_EXTENT(3)

πŸ’– MPI_TYPE_GET_EXTENT πŸ’–

okay so bestie, welcome to the Open MPI corner of the universe πŸ¦‹ this little page is about MPI_Type_get_extent and MPI_Type_get_extent_x, and yes they do exactly what the name says: they hand you back the lower bound and the extent of a data type. iconic behavior honestly πŸ’…


✨ SYNTAX ✨

🌸 C Syntax

#include <mpi.h>

int MPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint *lb,
     MPI_Aint *extent)
int MPI_Type_get_extent_x(MPI_Datatype datatype, MPI_Count *lb,
     MPI_Count *extent)

🌸 Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_TYPE_GET_EXTENT(DATATYPE, LB, EXTENT, IERROR)
     INTEGER DATATYPE, IERROR
     INTEGER(KIND=MPI_ADDRESS_KIND) LB, EXTENT
MPI_TYPE_GET_EXTENT_X(DATATYPE, LB, EXTENT, IERROR)
     INTEGER DATATYPE, IERROR
     INTEGER(KIND=MPI_COUNT_KIND) LB, EXTENT

🌸 Fortran 2008 Syntax

USE mpi_f08
MPI_Type_get_extent(datatype, lb, extent, ierror)
     TYPE(MPI_Datatype), INTENT(IN) :: datatype
     INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(OUT) :: lb, extent
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror
MPI_Type_get_extent_x(datatype, lb, extent, ierror)
     TYPE(MPI_Datatype), INTENT(IN) :: datatype
     INTEGER(KIND = MPI_COUNT_KIND), INTENT(OUT) :: lb, extent
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

πŸ“₯ INPUT PARAMETER πŸ“₯

  • datatype β€” the data type, aka a handle. that's the vibe you're interrogating πŸ”

πŸ“€ OUTPUT PARAMETERS πŸ“€

  • lb β€” the lower bound of the data type (an integer, bestie).
  • extent β€” the data type extent (also an integer, we love consistency πŸ’–).
  • ierror β€” Fortran only: the error status (integer). yeah it lives in the argument list here, that's just how Fortran rolls πŸ™ˆ

🫢 DESCRIPTION 🫢

MPI_Type_get_extent returns the lower bound and the extent of datatype. that's it, that's the whole job, and it does it flawlessly ✨

and for either function, if either the lb or extent parameter can't actually express the value that wants to be returned (like, say, the parameter is literally too small to hold the output value 😭), then it gets set to MPI_UNDEFINED. so if you see MPI_UNDEFINED staring back at you, that's what happened β€” no cap.


πŸ‘‘ NOTE πŸ‘‘

using MPI_Type_get_extent is strongly recommended over the legacy MPI-1 functions MPI_Type_extent and MPI_Type_lb. those two are giving dusty, and we don't do dusty here πŸ’… the new one is the main character, periodt.


πŸ’€ ERRORS πŸ’€

almost all MPI routines return an error value β€” C routines give it back as the return result of the function, and Fortran routines tuck it into that last argument. classic.

before that error value ever gets returned, 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 at all? then the call is considered attached to MPI_COMM_SELF and it'll call the associated MPI error handler for that. and when MPI_COMM_SELF isn't initialized (so: before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when you're going full Sessions Model and nothing else) β€” the error raises the initial error handler. that initial error handler can be changed 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 via an info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. and 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. okay? okay πŸŽ€

Open MPI ships three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. yeah. all of them. 😭
  • 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. and if it's called on a session, it aborts only the local process.
  • MPI_ERRORS_RETURN β€” returns an error code to the application. polite king behavior 🫢

MPI applications can also go fully DIY and 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
heads up bestie: MPI does not guarantee that an MPI program can continue past an error. so don't be out here assuming you can just vibe through it πŸ”₯

see the MPI man page for a full list of MPI error codes. also see the Error Handling section of the MPI-3.1 standard if you want the whole deep dive. iykyk πŸ“š


2003-2026, The Open MPI Community


and that's the whole page, bestie πŸ¦‹πŸŒ· this was the Open MPI MPI_TYPE_GET_EXTENT(3) man page, dated Sep 10, 2026. go get those extents, you absolute legend πŸ‘‘πŸ’œ

πŸ“¦ where this page comes from