MPI_GRAPH_NEIGHBORS_COUNT(3)

πŸ’– MPI_GRAPH_NEIGHBORS_COUNT(3) πŸ’–

okay bestie, we're vibing in Open MPI land today and this one is literally just "hey, how many friends does this node have?" energy. That's it. That's the whole function. 🫢

✨ NAME ✨

MPI_Graph_neighbors_count β€” tells you the number of neighbors of a node that's part of a graph topology. it's giving headcount at the function. no cap. πŸ’…


🌸 SYNTAX 🌸

πŸ’œ C Syntax

#include <mpi.h>

int MPI_Graph_neighbors_count(MPI_Comm comm, int rank,
    int *nneighbors)

πŸ’œ Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'

MPI_GRAPH_NEIGHBORS_COUNT(COMM, RANK, NNEIGHBORS, IERROR)
    INTEGER COMM, RANK, NNEIGHBORS, IERROR

πŸ’œ Fortran 2008 Syntax

USE mpi_f08

MPI_Graph_neighbors_count(comm, rank, nneighbors, ierror)
    TYPE(MPI_Comm), INTENT(IN) :: comm
    INTEGER, INTENT(IN) :: rank
    INTEGER, INTENT(OUT) :: nneighbors
    INTEGER, OPTIONAL, INTENT(OUT) :: ierror

πŸŽ€ INPUT PARAMETERS πŸŽ€

  • comm : the communicator that's lowkey carrying a graph topology (it's a handle). 🌈
  • rank : the rank of the process inside the group of comm (an integer, bestie).

πŸ¦‹ OUTPUT PARAMETERS πŸ¦‹

  • nneighbors : the number of neighbors of the process you pointed at (an integer). this is the answer you came for, and it ate. πŸ‘‘
  • ierror : Fortran only β€” error status (integer).

🌟 DESCRIPTION 🌟

So MPI_Graph_neighbors_count and MPI_Graph_neighbors are the duo that hand you adjacency info for a general, graph topology. iconic pair fr fr. MPI_Graph_neighbors_count specifically returns the number of neighbors for the process that rank is pointing at. that's the whole job. slay. ✨


πŸ’€ ERRORS πŸ’€

Almost every MPI routine hands back an error value, and the way it does that depends on the language, bestie: C routines return it as the result of the function, and Fortran routines tuck it into the last argument. no escaping it. πŸ™ˆ

Before that error value comes back to you, the current MPI error handler that's tied to the communication object (think: communicator, window, file) gets called. If there's no communication object attached to the MPI call, then the call is treated as attached to MPI_COMM_SELF and it calls the error handler associated with that. And when MPI_COMM_SELF isn't initialized β€” like before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when you're running the Sessions Model exclusively β€” the error raises the initial error handler. You can swap that initial error handler out by calling MPI_Comm_set_errhandler on MPI_COMM_SELF (that's the World model route), or via the mpi_initial_errhandler CLI argument to mpiexec, or via an info key to MPI_Comm_spawn/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 every other MPI function. periodt. πŸ’…

Open MPI ships three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” Causes the program to abort all connected MPI processes. πŸ’€
  • 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.
  • MPI_ERRORS_RETURN β€” Returns an error code to the application.

MPI applications can also implement their very own error handlers, main character style, 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
⚠️ heads up bestie: MPI does not guarantee that an MPI program can continue past an error. like, at all. 😭

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_Graph_neighbors

2003-2026, The Open MPI Community


and that's the whole page, bestie β€” go forth and count those neighbors. this was Open MPI, documented on Sep 10, 2026, and honestly? she served. πŸŽ€βœ¨πŸ’–

πŸ“¦ where this page comes from