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 ifMPI_Abortwas called on that communicator. if it's called on a window or file, it acts as ifMPI_Abortwas 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_errhandlerand thenMPI_Comm_set_errhandlerMPI_File_create_errhandlerand thenMPI_File_set_errhandlerMPI_Session_create_errhandlerand thenMPI_Session_set_errhandler, or atMPI_Session_initMPI_Win_create_errhandlerand thenMPI_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 π
π Copyright π
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
- ubuntu stonking: openmpi-doc 5.0.10-6 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms