MPI_GRAPHDIMS_GET(3)

πŸ’… MPI_GRAPHDIMS_GET πŸ’…

okay bestie, so this one is from the Open MPI manual, section 3, and it's called MPI_GRAPHDIMS_GET β€” yes the whole name is uppercase, it's giving very shouty but also iconic. let's get into it 🫢


✨ NAME ✨

MPI_Graphdims_get β€” retrieves the graph topology info that's hanging out with a communicator. like, the dimensions of the graph, not the whole thing. keep reading, you'll see πŸ’–


✨ SYNTAX ✨

πŸŽ€ C Syntax πŸŽ€

#include <mpi.h>

int MPI_Graphdims_get(MPI_Comm comm, int *nnodes, int *nedges)

πŸŽ€ Fortran Syntax πŸŽ€

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

MPI_GRAPHDIMS_GET(COMM, NNODES, NEDGES, IERROR)
    INTEGER COMM, NNODES, NEDGES, IERROR

πŸŽ€ Fortran 2008 Syntax πŸŽ€

USE mpi_f08

MPI_Graphdims_get(comm, nnodes, nedges, ierror)
    TYPE(MPI_Comm), INTENT(IN) :: comm
    INTEGER, INTENT(OUT) :: nnodes, nedges
    INTEGER, OPTIONAL, INTENT(OUT) :: ierror

✨ INPUT PARAMETER ✨

  • comm β€” the communicator for the group that's got a graph structure going on (a handle). it's the friend group, basically 🫢

✨ OUTPUT PARAMETERS ✨

  • nnodes β€” how many nodes are in the graph (integer). the headcount of the party πŸŽ‰
  • nedges β€” how many edges are in the graph (integer). the connections, the group-chat threads, the lore πŸ’€
  • ierror β€” Fortran only: the error status (integer). C girlies, you get yours as the return value, no cap.

✨ DESCRIPTION ✨

so MPI_Graphdims_get and MPI_Graph_get are the duo that retrieves the graph-topology info that was associated with a communicator by MPI_Graph_create. they're a matching set, like besties who finish each other's sentences πŸ’…

the info you get from MPI_Graphdims_get is exactly what you need to dimension the vectors index and edges correctly for a call to MPI_Graph_get. literally its whole job β€” it's the "how big does my array need to be" girlie so the other function can get to work without you guessing and crying 😭


✨ ERRORS ✨

almost every MPI routine returns an error value, okay? C routines hand it back as the return result of the function, and Fortran routines put it in the last argument. that's just how they do it. πŸŽ€

before the error value is returned, the current MPI error handler associated with the communication object (e.g., communicator, window, file) gets called. and 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. 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. okay that was a lot, drink some water πŸ“

Open MPI includes three predefined error handlers that can be used:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. like, everyone. gone. 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. so, context-aware chaos πŸ”₯
  • MPI_ERRORS_RETURN β€” returns an error code to the application. the polite one. the one that lets you handle it yourself πŸ’–

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, don't count on it bestie, no cap 😭

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_create β€” go read that one next, it's the origin story 🌈


2003-2026, The Open MPI Community


and that's the whole page, periodt πŸ’… the source is Open MPI, dated Sep 11, 2026 β€” go forth and dimension your vectors correctly, queen πŸ‘‘πŸ¦‹

πŸ“¦ where this page comes from