MPIX_Op_create_x(3)

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

✨ MPIX_Op_create_x(3) ✨

okay so bestie, welcome to the MPI manual, section 3 (that's the library-calls girlies πŸ’…). Today's main character is MPIX_Op_create_x, and she's here to let you build your own reduction op with a lil extra something attached. Let's get into it fr fr πŸ¦‹


🌸 NAME 🌸

MPIX_Op_create_x β€” creates a user-defined reduction op with an extra_state ✨


πŸŽ€ SYNOPSIS πŸŽ€

int MPIX_Op_create_x(MPIX_User_function_x *user_fn_x,
MPIX_Destructor_function *destructor_fn, int commute,
void *extra_state, MPI_Op *op)

πŸ’– INPUT PARAMETERS πŸ’–

  • user_fn_x β€” your own user-defined function, the one that takes an extra_state (it's a function, bestie)
  • destructor_fn β€” the callback that fires when the op gets freed (also a function)
  • commute β€” true if it's commutative, false if it's not (logical)
  • extra_state β€” the extra state (None)

πŸ‘‘ OUTPUT PARAMETERS πŸ‘‘

  • op β€” the operation (a handle, hold onto it)

🧚 NOTES ON MPIX_USER_FUNCTION_X 🧚

So the calling list for this user function type is literally:

typedef void (MPIX_User_function_x) (void * a, void * b,
MPI_Count len, MPI_Datatype datatype,
void *extra_state);

And yes, there are a few differences from MPI_User_function used in MPI_Op_create. Not me listing them:

  1. It passes len and datatype as scalar input, rather than as addresses. no pointers, periodt.
  2. The len is of MPI_Count, rather than int. glow up ✨
  3. It accepts a void *extra_state which is passed from users during MPIX_Op_create_x. that's the whole vibe of this function honestly.

πŸ”₯ THREAD AND INTERRUPT SAFETY πŸ”₯

This routine is thread-safe. Which means it may be safely used by multiple threads without needing any user-provided thread locks. slay, no mutex required πŸ’…

BUT. And this is important bestie β€” the routine is not interrupt safe. Typically this is because of the use of memory allocation routines such as malloc or other non-MPICH runtime routines that are themselves not interrupt-safe. so like, don't come for her, it's not her fault 😭


🌈 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 they're invoked with the call statement. that's just how Fortran does 🫢

All MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. iconic, honestly.


πŸ’€ 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. πŸ’€ yeah. dramatic but true.

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 β€” like, retire her already. 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. fingers crossed 🀞

  • MPI_SUCCESS β€” no error; the MPI routine completed successfully. ate, no crumbs ✨
  • MPI_ERR_ARG β€” invalid argument. Some argument is invalid and is not identified by a specific error class (e.g., MPI_ERR_RANK). girl what did you pass in 😭
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to get more information about this error code. the "mystery flavour" error, use the lookup bestie πŸ”

and that's the whole page, bestie! go forth and make your very own reduction op, extra_state and all. πŸ’–

this has been MPIX_Op_create_x(3) from the MPI manual, dated 4/10/2026. mwah, take care of her 🫢✨

πŸ“¦ where this page comes from