MPI_GRAPHDIMS_GET(3)

πŸ’« MPI_GRAPHDIMS_GET πŸ’«

okay bestie, gather round, because this is the Open MPI manual page for MPI_Graphdims_get, and it's lowkey one of those tiny functions that saves your whole entire life when you're trying to figure out how big your graph arrays gotta be. ✨

It's in section 3 (the library calls girlies), and it does exactly one thing: it tells you the dimensions of a graph topology hiding inside a communicator. no cap.


🌸 NAME 🌸

MPI_Graphdims_get β€” pulls out the graph topology info that's chillin' inside a communicator. πŸ¦‹


✨ 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 rockin' that graph structure, it's a handle. πŸ‘‘

πŸŽ€ OUTPUT PARAMETERS πŸŽ€

  • nnodes β€” how many nodes are in the graph, as an integer. count 'em up bestie πŸ“
  • nedges β€” how many edges are in the graph, also an integer. the connections fr fr πŸ”₯
  • ierror β€” Fortran only, babes: the error status, as an integer. πŸ’…

🌈 DESCRIPTION 🌈

So MPI_Graphdims_get and MPI_Graph_get are a lil duo β€” they retrieve the graph-topology information that some other call associated with a communicator in the first place, specifically MPI_Graph_create. that's the origin story, iconic honestly.

The whole point of MPI_Graphdims_get? The info it hands you lets you dimension your index and edges vectors correctly before you call MPI_Graph_get. like, you cannot just guess the size, that's giving chaos. use this first, then go forth and MPI_Graph_get. 🌟


πŸ’€ ERRORS πŸ’€

okay here's the part where we get serious for a sec. almost every MPI routine returns an error value β€” C routines hand it back as the return result of the function, and Fortran routines put it in that last argument. noted. ✍️

Before that error value ever gets returned, the current MPI error handler associated with the communication object (think: communicator, window, file) gets called. and if there's no communication object attached to the MPI call? then the call is considered attached to MPI_COMM_SELF and it'll call the associated MPI error handler for that. now when MPI_COMM_SELF isn't initialized β€” like 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. 😭

And that initial error handler can be changed! you do it by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when you're on the World model, or via the mpi_initial_errhandler CLI argument to mpiexec, or the info key to MPI_Comm_spawn / MPI_Comm_spawn_multiple. and if literally 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 all the other MPI functions. that's just how it is. πŸ’…

Open MPI ships three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. yeah. all of them. πŸ’€
  • MPI_ERRORS_ABORT β€” an error handler you can invoke on a communicator, window, file, or session. when it's called on a communicator, it acts as if MPI_Abort was called on that communicator. if it's called on a window or a file, it acts as if MPI_Abort was called on a communicator containing the group of processes in the corresponding window or file. and if it's called on a session, it aborts only the local process. local queen behavior. πŸ‘‘
  • MPI_ERRORS_RETURN β€” returns an error code to the application. simple, clean, respectful. ✨

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
🚨 important bestie: note that MPI does not guarantee that an MPI program can continue past an error. so don't be out here assuming you can just vibe through it.

See the MPI man page for a full list of MPI error codes. πŸ‘€

See the Error Handling section of the MPI-3.1 standard if you want the deep lore. πŸ“š

See also:

  • MPI_Graph_create

2003-2026, The Open MPI Community


and that's the whole page, bestie!! 🫢 written up on Sep 10, 2026, from Open MPI, living in section 3 as MPI_GRAPHDIMS_GET(3). go dimension those vectors correctly and slay. πŸ’œπŸ§šπŸŒΈ

πŸ“¦ where this page comes from