MPI_OP_COMMUTATIVE(3)

πŸ’– MPI_OP_COMMUTATIVE πŸ’–

okay bestie, welcome to the Open MPI manual, page MPI_OP_COMMUTATIVE(3) β€” yes the third section, we're in library-call territory, very demure, very mindful πŸŽ€

✨ NAME ✨

MPI_Op_commutative β€” bestie, this is literally just a vibe check for your reduction operation. You're asking: is this op commutative or not? That's it. That's the whole function. πŸ¦‹


✨ SYNTAX ✨

πŸ’… C Syntax

#include <mpi.h>

int MPI_Op_commutative(MPI_Op op, int *commute)

πŸ’… Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_OP_COMMUTATIVE(OP, COMMUTE, IERROR)
     LOGICAL COMMUTE
     INTEGER OP, IERROR

πŸ’… Fortran 2008 Syntax

USE mpi_f08
MPI_Op_commutative(op, commute, ierror)
     TYPE(MPI_Op), INTENT(IN) :: op
     INTEGER, INTENT(OUT) :: commute
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

✨ INPUT PARAMETER ✨

  • op β€” the operation, as a handle. That's the thing you're interrogating. πŸ‘‘

✨ OUTPUT PARAMETERS ✨

  • commute β€” true if op is commutative, false if it's not. Logical, periodt. πŸ’–
  • ierror β€” Fortran only, babes: the error status, an integer. πŸ™ˆ

✨ DESCRIPTION ✨

Reduction operations can be queried for their commutativity. That's the plot. You hand over an op, it tells you whether it commutes. slay 🌈


✨ ERRORS ✨

ngl, here's where it gets real β€” almost every MPI routine gives you back an error value. C routines? That's the return result of the function. Fortran routines? It's the last argument. 🌸

Before the error value comes back to you, the current MPI error handler that's attached to the communication object (think: communicator, window, file) gets called. And if no communication object is tied to the MPI call at all, then the call is considered attached to MPI_COMM_SELF and it'll call the error handler associated with that. Now β€” when MPI_COMM_SELF is not initialized (aka 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 instead. You can swap out that initial error handler by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when you're in the World model, or via the mpi_initial_errhandler CLI argument to mpiexec, or with the info key to MPI_Comm_spawn / MPI_Comm_spawn_multiple. And if literally no other appropriate error handler has been set? Then the MPI_ERRORS_RETURN handler gets called for MPI I/O functions, and MPI_ERRORS_ABORT gets called for all the other MPI functions. 😭

Open MPI ships three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. yeah. everyone. πŸ’€
  • MPI_ERRORS_ABORT β€” an error handler you can invoke on a communicator, window, file, or session. Called on a communicator, it acts as if MPI_Abort was called on that communicator. 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. Called on a session, it aborts only the local process.
  • MPI_ERRORS_RETURN β€” returns an error code back to your application. chill of it honestly. 🫢

Your MPI application can also implement its own error handlers by calling:

  • MPI_Comm_create_errhandler and then MPI_Comm_set_errhandler
  • MPI_File_create_errhandler and then MPI_File_set_errhandler
  • MPI_Session_create_errhandler and then MPI_Session_set_errhandler, or at MPI_Session_init
  • MPI_Win_create_errhandler and then MPI_Win_set_errhandler
⚠️ Heads up bestie: note that MPI does not guarantee that an MPI program can continue past an error. Like, at all. Do not make plans after this error. 🚨

See the MPI man page for a full list of MPI error codes.

See the Error Handling section of the MPI-3.1 standard for more information.

See also:

  • MPI_Op_create

2003-2026, The Open MPI Community


and that's the whole page, no cap πŸ’œ thanks for reading my little manual moment β€” this was the Open MPI MPI_OP_COMMUTATIVE(3) page, version dated Sep 10, 2026, footer and all, and you ate it up fr fr βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from