# Process grids¶

Th Grid class is responsible for converting MPI communicators into a two-dimensional process grid meant for distributing matrices (ala the soon-to-be-discussed DistMatrix<T,U,V> class).

class Grid
Grid(mpi::Comm comm = mpi::COMM_WORLD, GridOrder order = COLUMN_MAJOR)

Construct a process grid over the specified communicator and let Elemental decide the process grid dimensions. If no communicator is specified, mpi::COMM_WORLD is used. The processes in the chosen communicator are arranged into a two-dimensional grid in a column-major order by default but a row-major ordering can also be specified.

Grid(mpi::Comm comm, int height, GridOrder order = COLUMN_MAJOR)

Construct a process grid over the specified communicator with the given height. Note that the size of the communicator must be divisible by height. The processes in the chosen communicator are arranged into a two-dimensional grid in a column-major order by default but a row-major ordering can also be specified.

Simple interface (simpler version of distribution-based interface)

int Row() const

Return the index of the row of the process grid that this process lies in.

int Col() const

Return the index of the column of the process grid that this process lies in.

int Rank() const

Return our process’s rank in the grid: in the case that the processes in the grid were arranged with a column-major ordering, this is VCRank(), otherwise, it is VRRank().

int Height() const

Return the height of the process grid.

int Width() const

Return the width of the process grid.

int Size() const

Return the number of active processes in the process grid. This number is equal to Height() $$\times$$ Width().

GridOrder Order() const

Returns whether the processes were ordered in a COLUMN_MAJOR or ROW_MAJOR manner in order to form the process grid.

mpi::Comm ColComm() const

Return the communicator for this process’s column of the process grid.

mpi::Comm RowComm() const

Return the communicator for this process’s row of the process grid.

mpi::Comm Comm() const

Return the communicator for the process grid: in the case that the processes in the grid were arranged with a column-major ordering, this is VCComm(), otherwise, it is VRComm().

Distribution-based interface

int MCRank() const

Return our process’s rank in the MC (Matrix Column) communicator. This corresponds to our row in the process grid.

int MRRank() const

Return our process’s rank in the MR (Matrix Row) communicator. This corresponds to our column in the process grid.

int VCRank() const

Return our process’s rank in the VC (Vector Column) communicator. This corresponds to our rank in a column-major ordering of the process grid.

int VRRank() const

Return our process’s rank in the VR (Vector Row) communicator. This corresponds to our rank in a row-major ordering of the process grid.

int MCSize() const

Return the size of the MC (Matrix Column) communicator, which is equivalent to the height of the process grid.

int MRSize() const

Return the size of the MR (Matrix Row) communicator, which is equivalent to the width of the process grid.

int VCSize() const

Return the size of the VC (Vector Column) communicator, which is equivalent to the size of the process grid.

int VRSize() const

Return the size of the VR (Vector Row) communicator, which is equivalent to the size of the process grid.

mpi::Comm MCComm() const

Return the MC (Matrix Column) communicator. This consists of the set of processes within our column of the grid (ordered top-to-bottom).

mpi::Comm MRComm() const

Return the MR (Matrix Row) communicator. This consists of the set of processes within our row of the grid (ordered left-to-right).

mpi::Comm VCComm() const

Return the VC (Vector Column) communicator. This consists of the entire set of processes in the grid, but ordered in a column-major fashion.

mpi::Comm VRComm() const

Return the VR (Vector Row) communicator. This consists of the entire set of processes in the grid, but ordered in a row-major fashion.

Grid(mpi::Comm viewingComm, mpi::Group owningGroup, int height, GridOrder order = COLUMN_MAJOR)

Construct a process grid where only a subset of the participating processes should actively participate in the process grid. In particular, viewingComm should consist of the set of all processes constructing this Grid instance, and owningGroup should define a subset of the processes in viewingComm. The height of the process grid is set to the specified value and either a column-major or row-major ordering of the participating processes is used to form the grid. Most users should not call this routine, as this type of grid is only supported for a few DistMatrix types. Note that the size of owningGroup must be divisible by height.

int GCD() const

Return the greatest common denominator of the height and width of the process grid.

int LCM() const

Return the lowest common multiple of the height and width of the process grid.

bool HaveViewers() const

Return true if there are processes which constructed this Grid instance but are not a member of the grid.

bool InGrid() const

Return true if our process is actively participating in the process grid.

int OwningRank() const

Return our process’s rank within the set of processes that are actively participating in the grid.

int ViewingRank() const

Return our process’s rank within the entire set of processes that constructed this grid.

int VCToViewingMap() const

Map the given column-major grid rank to the rank in the (potentially) larger set of processes which constructed the grid.

mpi::Group OwningGroup() const

Return the group of processes which is actively participating in the grid.

mpi::Comm OwningComm() const

Return the communicator for the set of processes actively participating in the grid. Note that this can only be valid if the calling process is an active member of the grid!

mpi::Comm ViewingComm() const

Return the communicator for the entire set of processes which constructed the grid.

int DiagPath() const

Return our unique diagonal index in an tesselation of the process grid.

int DiagPath(int vectorColRank) const

Return the unique diagonal index of the process with the given column-major vector rank in an tesselation of the process grid.

int DiagPathRank() const

Return our process’s rank out of the set of processes lying in our diagonal of the tesselation of the process grid.

int DiagPathRank(int vectorColRank) const

Return the rank of the given process out of the set of processes in its diagonal of the tesselation of the process grid.

Grid comparison functions

bool operator==(const Grid &A, const Grid &B)

Returns true if !A! and !B! are the same process grid.

bool operator!=(const Grid &A, const Grid &B)

Returns true if !A! and !B! are different process grids.