MPI_TYPE_MATCH_SIZE(3)
π MPI_Type_match_size β bestie edition π
okay so this is MPI_TYPE_MATCH_SIZE(3) from the Open MPI manual, and honestly? it's kind of a bop. it's that one little function that goes "hey, you got a type and a size? say less, here's a datatype that matches." iconic behavior fr fr. π¦
MPI_Type_match_size β returns an MPI datatype of a given type and size β¨
β¨ SYNOPSIS β¨
π C Syntax
#include <mpi.h>
int MPI_Type_match_size(int typeclass, int size,
MPI_Datatype *type)
π Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_TYPE_MATCH_SIZE(TYPECLASS, SIZE, TYPE, IERROR)
INTEGER TYPECLASS, SIZE, TYPE, IERROR
π Fortran 2008 Syntax
USE mpi_f08
MPI_Type_match_size(typeclass, size, datatype, ierror)
INTEGER, INTENT(IN) :: typeclass, size
TYPE(MPI_Datatype), INTENT(OUT) :: datatype
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
πΈ INPUT PARAMETERS πΈ
typeclassβ the generic type specifier, bestie. it's an integer πsizeβ how big the representation is, in bytes. also an integer π«Ά
π OUTPUT PARAMETERS π
typeβ a datatype that's got the right type AND the right size. it's a handle, bestie πierrorβ Fortran only, babes: the error status, as an integer
π¦ DESCRIPTION π¦
so what does this actually do. the function hands you back an MPI datatype that matches a local variable of type (typeclass, size). and here's the tea: the returned type is a reference (handle) to a predefined named datatype, NOT a duplicate. meaningβ¦ you cannot free it. do not try it. it's not yours to free. periodt. π
the value of typeclass can be set to one of these three, depending on the datatype you're manifesting:
MPI_TYPECLASS_REALMPI_TYPECLASS_INTEGERMPI_TYPECLASS_COMPLEX
MPI_type_match_size can be used to obtain a size-specific type that matches a Fortran numeric intrinsic type, and the little two-step is: first call MPI_Sizeof <#mpi-sizeof> to compute the variable size, then call MPI_Type_match_size to find a suitable datatype. in C, use the sizeof builtin instead of MPI_Sizeof <#mpi-sizeof>. slay. β¨
β οΈ it is erroneous to specify a size that the compiler doesn't support. like, don't do that. the compiler does not know her. π
π ERRORS π
almost all MPI routines return an error value, bestie. for C routines it's the return result of the function, and for Fortran routines it's in that last argument. standard.
before the error value comes back to you, the current MPI error handler associated with the communication object (think: communicator, window, file) gets called. if there's no communication object associated with the MPI call, then the call counts as attached to MPI_COMM_SELF and it'll call the associated MPI error handler. and when MPI_COMM_SELF is not initialized (i.e., before MPI_Init <#mpi-init>/MPI_Init_thread <#mpi-init-thread>, after MPI_Finalize <#mpi-finalize>, or when you're using the Sessions Model exclusively), the error raises the initial error handler.
the initial error handler can be changed by calling MPI_Comm_set_errhandler <#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>/MPI_Comm_spawn_multiple <#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 the other MPI functions.
Open MPI ships with three predefined error handlers you can use, and they are:
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 called on a communicator, it acts as ifMPI_Abort<#mpi-abort> was called on that communicator. if called on a window or file, it acts as ifMPI_Abort<#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. selective king behavior π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<#mpi-comm-create-errhandler> thenMPI_Comm_set_errhandler<#mpi-comm-set-errhandler>MPI_File_create_errhandler<#mpi-file-create-errhandler> thenMPI_File_set_errhandler<#mpi-file-set-errhandler>MPI_Session_create_errhandler<#mpi-session-create-errhandler> thenMPI_Session_set_errhandler<#mpi-session-set-errhandler> or atMPI_Session_init<#mpi-session-init>MPI_Win_create_errhandler<#mpi-win-create-errhandler> thenMPI_Win_set_errhandler<#mpi-win-set-errhandler>
β οΈ note that MPI does not guarantee that an MPI program can continue past an error. no cap.
see the MPI man page <#open-mpi> for a full list of MPI error codes <#open-mpi-errors>. π
see the Error Handling section of the MPI-3.1 standard for more information.
See also:
MPI_Sizeof<#mpi-sizeof>MPI_Type_get_extent<#mpi-type-get-extent>
π Copyright π
2003-2026, The Open MPI Community
okay that's the whole page bestie, you ate that. π
and just so you know where this came from: it's the Open MPI manual, page MPI_TYPE_MATCH_SIZE(3), dated Sep 10, 2026. go forth and match those sizes, you main character. πβ¨π¦
π¦ 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