MPI_Type_size(3)
π MPI_Type_size(3) β a manual page from the MPI fam π
okay bestie, sit down, hydrate, because today we're learning how to ask MPI how many bytes does this datatype actually eat and honestly? it's giving essential. π
β¨ NAME β¨
MPI_Type_size β returns the number of bytes occupied by entries in the datatype. yes that's the whole job. she's simple, she's iconic, she's booked and busy. π
πΈ SYNOPSIS πΈ
int MPI_Type_size(MPI_Datatype datatype, int *size)
int MPI_Type_size_c(MPI_Datatype datatype, MPI_Count *size)
two flavors, same energy fr fr. π¦
π INPUT PARAMETERS π
datatypeβ the datatype (a handle, bestie, so don't go passing her a random int and expecting magic π)
π«Ά OUTPUT PARAMETERS π«Ά
sizeβ the datatype size, and it comes back as an integer β¨
π₯ THREAD AND INTERRUPT SAFETY π₯
okay so the good news first: this routine is thread-safe. that means you can safely use it from multiple threads and you do not need to bring your own thread locks β no user-provided thread locks required, she handles herself. main character energy, no notes. π
but β and this is the plot twist π β the routine is not interrupt safe. the usual culprit is memory allocation routines like malloc or other non-MPICH runtime routines, because those themselves are not interrupt-safe. so like, respect the boundary, okay?
π NOTES FOR FORTRAN π
so Fortran besties, this part is for you π«Ά:
- Every MPI routine in Fortran (except
MPI_WTIMEandMPI_WTICK) has one extra argument:ierr, tacked on at the end of the argument list.ierris an integer and it means exactly the same thing as the return value of the routine in C. β¨ - In Fortran, MPI routines are subroutines, and you invoke them with the
callstatement. periodt. - All MPI objects β like
MPI_DatatypeandMPI_Commβ are of typeINTEGERin Fortran. yes, all of them. π
π ERRORS π
lowkey important, highkey dramatic: by default, the error handler aborts the MPI job. so maybe read this part before you YOLO your HPC allocation π
All MPI routines (except MPI_Wtime and MPI_Wtick) return an error value β C routines return it as the value of the function, and Fortran routines put it in the last argument. Before that value comes back, the current MPI error handler gets called. By default, this error handler aborts the MPI job. π
You can swap the error handler out with MPI_Comm_set_errhandler (for communicators), MPI_File_set_errhandler (for files), and MPI_Win_set_errhandler (for RMA windows). There's also the MPI-1 routine MPI_Errhandler_set, and you may use it, but heads up: its use is deprecated. π©
If you'd rather get error values returned instead of getting your job nuked, use the predefined error handler MPI_ERRORS_RETURN. And real talk: 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 "we'll try bestie, no promises." π«
Here's the error code menu π:
MPI_SUCCESSβ no error; the MPI routine completed successfully. slay. β¨MPI_ERR_ARGβ invalid argument. Some argument is invalid and isn't identified by a specific error class (e.g.,MPI_ERR_RANK). πMPI_ERR_TYPEβ invalid datatype argument. Additionally, this error can occur if an uncommittedMPI_Datatype(seeMPI_Type_commit) is used in a communication call. commit your types, bestie, i'm begging πMPI_ERR_OTHERβ other error; useMPI_Error_stringto get more information about this error code. π§
and that's the whole page, no cap. go forth and count your bytes, queen ππ¦π
mwah π β this was MPI_Type_size(3) from the MPI manual, dated 4/10/2026. take care of her, she's iconic.
π¦ where this page comes from
- nixos 26.05: mpich 5.0.1
- ubuntu stonking: mpich-doc 5.0.1-9 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms