MPI_TYPE_SET_ATTR(3)

πŸ’… MPI_TYPE_SET_ATTR(3) β€” like, the Open MPI manual page, bestie ✨

okay so this is the MPI_TYPE_SET_ATTR page from Open MPI, and it's literally about attaching attribute vibes to datatypes. let's get into it πŸŽ€


🌸 NAME 🌸

MPI_Type_set_attr β€” sets a key value/attribute pair to a data type. that's it. that's the whole job. iconic of it honestly 🫢


✨ SYNTAX ✨

πŸ’œ C Syntax

#include <mpi.h>

int MPI_Type_set_attr(MPI_Datatype type, int type_keyval,
     void *attribute_val)

πŸ’œ Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_TYPE_SET_ATTR(TYPE, TYPE_KEYVAL, ATTRIBUTE_VAL, IERROR)
     INTEGER TYPE, TYPE_KEYVAL, IERROR
     INTEGER(KIND=MPI_ADDRESS_KIND) ATTRIBUTE_VAL

πŸ’œ Fortran 2008 Syntax

USE mpi_f08
MPI_Type_set_attr(datatype, type_keyval, attribute_val, ierror)
     TYPE(MPI_Datatype), INTENT(IN) :: datatype
     INTEGER, INTENT(IN) :: type_keyval
     INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(IN) :: attribute_val
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

πŸ”„ INPUT/OUTPUT PARAMETER πŸ”„

  • type β€” the data type we're attaching the attribute to (it's a handle). yes bestie it's both input and output, she contains multitudes πŸ’…

🧚 INPUT PARAMETERS 🧚

  • type_keyval β€” the key value (an integer). the little name-tag for your attribute fr fr.
  • attribute_val β€” the attribute value itself. the actual content. the main character 🌟

πŸ¦‹ OUTPUT PARAMETER πŸ¦‹

  • ierror β€” Fortran only: the error status (integer). Fortran girlies get their errors handed to them in the last argument, no cap.

πŸ’– DESCRIPTION πŸ’–

so for the given data type, MPI_Type_set_attr sets the key value to the value of the specified attribute. that's the tea β˜• β€” key value in, attribute value attached, slay.


😭 ERRORS 😭

almost all MPI routines return an error value, okay? C routines give it back as the return result of the function, and Fortran routines put it in that last argument. both valid, both slay πŸ’…

before the error value 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 associated with the MPI call? then the call gets treated as attached to MPI_COMM_SELF and it calls the associated MPI error handler. periodt.

when MPI_COMM_SELF is not initialized (i.e., before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when you're using the Sessions Model exclusively) the error raises the initial error handler. and you can change that initial error handler:

  • by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or
  • with the mpi_initial_errhandler CLI argument to mpiexec, or
  • with the info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple.

and if no other appropriate error handler has been set? then the MPI_ERRORS_RETURN error handler is called for MPI I/O functions, and the MPI_ERRORS_ABORT error handler is called for all other MPI functions. that's just how it is 🫠

Open MPI ships three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. like, everyone. dramatic but effective πŸ’€
  • 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 if MPI_Abort was called on that communicator. if 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. if called on a session, it aborts only the local process. versatile queen πŸ‘‘
  • 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 then MPI_Comm_set_errhandler
  • MPI_File_create_errhandler then MPI_File_set_errhandler
  • MPI_Session_create_errhandler then MPI_Session_set_errhandler or at MPI_Session_init
  • MPI_Win_create_errhandler then MPI_Win_set_errhandler
⚠️ note that MPI does not guarantee that an MPI program can continue past an error. like, no promises bestie, be careful out there πŸ™ˆ

see the MPI man page for a full list of MPI error codes. and see the Error Handling section of the MPI-3.1 standard for more information. iykyk πŸ“š


πŸ‘€ SEE ALSO: πŸ‘€

  • MPI_Type_get_attr

2003-2026, The Open MPI Community


and that's the whole page, bestie!! πŸ¦‹βœ¨ this was Open MPI, MPI_TYPE_SET_ATTR(3), dated Sep 11, 2026 β€” go forth and attach those attributes, you absolute icon πŸ’–πŸ“πŸ‘‘

πŸ“¦ where this page comes from