Skip to content

MPI_PROC_NULL in Topology Creation #4675

@omor1

Description

@omor1

I'm trying to create a binary tree topology using MPI_Dist_graph_create_adjacent(), simplifying the graph boundaries by using MPI_PROC_NULL. This allows specifying all nodes in a consistent way.
I'm not sure this is allowed by the specification; I could find no information either way.
However, the neighborhood collectives specify that the borders of a cartesian topology act as though they send and receive from MPI_PROC_NULL. It could be useful to be able to obtain similar behavior in a generic graph.

Example code is given below:

int world_rank;
int world_size;
int neighbor[3];

MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
MPI_Comm_size(MPI_COMM_WORLD, &world_size);

neighbor[0] = world_rank > 0 ? (world_rank-1)/2 : MPI_PROC_NULL;
neighbor[1] = 2*world_rank+1 < world_size ? 2*world_rank+1 : MPI_PROC_NULL;
neighbor[2] = 2*world_rank+2 < world_size ? 2*world_rank+2 : MPI_PROC_NULL;

MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD,
                               3, neighbor, MPI_UNWEIGHTED,
                               3, neighbor, MPI_UNWEIGHTED,
                               MPI_INFO_NULL, true, &CommTree);

Currently this code results in the following error:

*** An error occurred in MPI_Dist_graph_create_adjacent invalid sources
*** reported by process [3896508417,2]
*** on communicator MPI_COMM_WORLD
*** MPI_ERR_ARG: invalid argument of some other kind
*** MPI_ERRORS_ARE_FATAL (processes in this communicator will now abort,
***    and potentially your MPI job)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions