MPI_Type_get_extent(3)

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

πŸ’– MPI_Type_get_extent β€” bestie edition πŸ’–

okay so this is a page from the MPI manual (yes, that MPI, the message-passing one), and today's main character is MPI_Type_get_extent ✨


🌸 NAME 🌸

MPI_Type_get_extent β€” get the lower bound and extent for a Datatype πŸ¦‹

like. the shape of your datatype in memory, bestie. where it starts and how far it reaches. iconic behavior honestly.


🌈 SYNOPSIS 🌈

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

two flavors, same vibe. pick your size, babe πŸ’…


πŸŽ€ INPUT PARAMETERS πŸŽ€

  • datatype β€” the datatype you wanna get info on (handle). the little guy you're interrogating πŸ‘‘

πŸ’œ OUTPUT PARAMETERS πŸ’œ

  • lb β€” lower bound of datatype (integer). where it all begins, fr fr 🌱
  • extent β€” extent of datatype (integer). how much room it takes up. she's spacious πŸ’ƒ

🫢 THREAD AND INTERRUPT SAFETY 🫢

This routine is thread-safe. what does that mean? it means multiple threads can use it at the same time without you needing to write a single user-provided thread lock. no extra babysitting required, no cap ✨

however (and this is the important part, so listen up bestie πŸ’€) β€” 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, it's giving thread-safe but not interrupt-safe. two different things, don't get it twisted πŸ™ˆ


🌺 NOTES FOR FORTRAN 🌺

All MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK) have an additional argument ierr at the end of the argument list. ierr is an integer and has the same meaning as the return value of the routine in C. In Fortran, MPI routines are subroutines, and are invoked with the call statement. πŸ‘‘

All MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. that's just the way it is, periodt πŸ’…


πŸ”₯ ERRORS πŸ”₯

All MPI routines (except MPI_Wtime and MPI_Wtick) return an error value; C routines as the value of the function and Fortran routines in the last argument. Before the value is returned, the current MPI error handler is called. By default, this error handler aborts the MPI job. πŸ’€

The error handler may be changed 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 lowkey don't, bestie, we've moved on 🚫

The predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned. Note that MPI does not guarantee that an MPI program can continue past an error; however, MPI implementations will attempt to continue whenever possible. she's trying her best πŸ₯Ί

  • MPI_SUCCESS β€” no error; MPI routine completed successfully. we love a clean run 🌟
  • MPI_ERR_ARG β€” invalid argument. some argument is invalid and is not identified by a specific error class (e.g., MPI_ERR_RANK). vague on purpose, smh πŸ™„
  • 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 first, babe, it's the law πŸ‘‘
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to get more information about this error code. the catch-all. when in doubt, call MPI_Error_string πŸ“

ngl the error section is giving "read the docs or cry" energy, but like, that's just MPI for you 😭

and that's the whole thing bestie!! this page came from the MPI manual, dated 4/10/2026, and if you ever need to find it again it lives under MPI_Type_get_extent(3) πŸ’– mwah, go forth and get those extents πŸ¦‹βœ¨πŸŒˆ

πŸ“¦ where this page comes from