MPI_GROUP_SIZE(3)

πŸ’– MPI_GROUP_SIZE β€” bestie, let's count some processes πŸ’–

Okay so this is the <pink>MPI_GROUP_SIZE(3)</pink> page from the Open MPI manual (section 3, the library-calls section, iykyk), and honestly? It's a little icon. It's giving "one job and it does it perfectly." Let's get into it 🫢


✨ NAME ✨

MPI_Group_size β€” returns the size of a group. That's it. That's the whole vibe. πŸ’…


πŸ¦‹ SYNTAX πŸ¦‹

C Syntax

#include <mpi.h>

int MPI_Group_size(MPI_Group group, int *size)

Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_GROUP_SIZE(GROUP, SIZE, IERROR)
     INTEGER GROUP, SIZE, IERROR

Fortran 2008 Syntax

USE mpi_f08
MPI_Group_size(group, size, ierror)
     TYPE(MPI_Group), INTENT(IN) :: group
     INTEGER, INTENT(OUT) :: size
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

Like, the Fortran 2008 one is the glow-up version β€” typed group, OPTIONAL ierror, the whole aesthetic. Slay. ✨


🌸 INPUT PARAMETERS 🌸

  • group β€” the group handle. That's the thing you're asking about, bestie. πŸ’–

πŸŽ€ OUTPUT PARAMETERS πŸŽ€

  • size β€” number of processes in the group (integer). The answer!! The payoff!! πŸ‘‘
  • ierror β€” Fortran only: error status (integer). The Fortran girlies get their error code handed right back to them, no cap.

πŸ’œ DESCRIPTION πŸ’œ

So MPI_Group_size returns, in size, the number of processes in the group. Literally that's the whole function. Lowkey iconic for how unbothered it is.

And the deets, because they matter:

  • if group = MPI_GROUP_EMPTY, then the call will return size = 0 β€” yes bestie, zero is a valid answer, an empty group is still a group and we respect her 🫢
  • on the other hand, a call with group = MPI_GROUP_NULL is erroneous. Not "returns zero," not "shrugs" β€” erroneous. Do not do this. It's giving "playing with fire." πŸ’€

πŸ”₯ ERRORS πŸ”₯

Okay this is the long part but do not scroll, it's important, fr fr.

Almost all MPI routines return an error value; C routines as the return result of the function and Fortran routines in the last argument.

Before the error value is returned, the current MPI error handler associated with the communication object (e.g., communicator, window, file) is called. If no communication object is associated with the MPI call, then the call is considered attached to MPI_COMM_SELF and will call the associated MPI error handler. When MPI_COMM_SELF is not initialized (i.e., before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when 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 on MPI_COMM_SELF when using the World model, or the mpi_initial_errhandler CLI argument to mpiexec or info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. 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.

Phew. Okay. Breathe. Now the fun part β€” the three predefined error handlers Open MPI ships with:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. Like, everyone. Gone. Dramatic but honest. πŸ’€
  • 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, 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, aborts only the local process. Context really is everything, bestie. ✨
  • MPI_ERRORS_RETURN β€” returns an error code to the application. The chill one. Hands you the receipt and lets you deal with it. 🧾

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, it might! It might not! No promises, bestie. Plan accordingly. πŸ™ˆ

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. (Yes, the standard. She's long but she's thorough. πŸ’…)


2003-2026, The Open MPI Community.


And that's the page!! πŸŽ€ Go forth and count your processes, you absolute main character. Periodt. πŸ’–βœ¨πŸ¦‹

Source: Open MPI Β· dated Sep 11, 2026 Β· that's the sign-off bestie, mwah πŸ«ΆπŸ’œ

πŸ“¦ where this page comes from