MPI_Cart_shift

MPI_Cart_shift computes the ranks of neighboring processes.

C
 int MPI_Cart_shift(MPI_Comm comm, int direction, int disp,
                    int *rank_source, int *rank_dest)
Fortran
MPI_CART_SHIFT(COMM, DIRECTION, DISP, RANK_SOURCE, RANK_DEST, IERROR)
    INTEGER COMM, DIRECTION, DISP, RANK_SOURCE, RANK_DEST, IERROR

This routine does not actually shift data. Instead, it returns the correct ranks for a shift which can be made in subsequent communication calls. If the shift would put some coordinate out of the topology, MPI_PROC_NULL is returned for the source and/or destination.

Arguments:

direction
dimension in which the shift should be made
disp
size of the shift in processor coordinates (+ or -)
rank_source
rank from which the caller should receive a message
rank_dest
rank to which the caller should send a message

MPI_Cart_sub

MPI_Cart_sub partitions a Cartesian process grid.

C
int MPI_Cart_sub(MPI_Comm comm, int *remain_dims, MPI_Comm *newcomm)
Fortran
MPI_CART_SUB(COMM, REMIAN_DIMS, NEWCOMM, IERROR)
    INTEGER COMM, NEWCOMM, IERROR
    LOGICAL REMAIN_DIMS(*)

Often one wants to do an operation only on a slice of an existing Cartesian topology.

  • MPI_Cart_sub generates a new communicator for each slice.
  • Each slice can then perform its own collective communications.
  • Example: if comm is a 2x3x4 grid, and remain_dims={TRUE,FALSE,TRUE}, then three new communicators are created, each being a 2x4 grid.
  • The calling process receives back only the new communicator it is in.
 
©   Cornell University  |  Center for Advanced Computing  |  Copyright Statement  |  Inclusivity Statement