1.4.1. Grid and Communication

1.4.1.1. chase::grid::MpiGrid2D

template<GridMajor MajorOrder>
class MpiGrid2D : public chase::grid::MpiGrid2DBase

Templated class for creating and managing a 2D MPI grid.

The MpiGrid2D class is a templated class derived from MpiGrid2DBase that manages a 2D MPI grid with specified row and column dimensions. The grid can be configured to use either row-major or column-major ordering.

Template Parameters:

MajorOrder – Specifies the major ordering of the grid (RowMajor or ColMajor).

Public Functions

inline MpiGrid2D(int row_dim, int col_dim, MPI_Comm comm)

Constructs a 2D MPI grid with specified row and column dimensions.

Parameters:
  • row_dim – Number of rows in the grid.

  • col_dim – Number of columns in the grid.

  • comm – MPI communicator used to create the grid.

inline MpiGrid2D(MPI_Comm comm)

Constructs a 2D MPI grid with dimensions derived from the communicator.

Parameters:

comm – MPI communicator used to create the grid.

inline ~MpiGrid2D()

Destructor to clean up resources associated with the MPI grid.

inline bool operator==(const MpiGrid2D<MajorOrder> &other) const

Equality operator to compare two MpiGrid2D instances.

Parameters:

other – The other MpiGrid2D instance to compare with.

Returns:

true if the two grids are identical, false otherwise.

inline bool operator!=(const MpiGrid2D<MajorOrder> &other) const

Inequality operator to compare two MpiGrid2D instances.

Parameters:

other – The other MpiGrid2D instance to compare with.

Returns:

true if the two grids are different, false otherwise.

inline virtual MPI_Comm get_row_comm() const override

Returns the row communicator for the grid.

Returns:

MPI_Comm Row communicator.

inline virtual MPI_Comm get_col_comm() const override

Returns the column communicator for the grid.

Returns:

MPI_Comm Column communicator.

inline virtual MPI_Comm get_comm() const override

Returns the global communicator for the grid.

Returns:

MPI_Comm Global communicator.

inline virtual int get_nprocs() const override

Returns the number of processes in the grid.

Returns:

int Number of processes.

inline virtual int get_myRank() const override

Returns the rank of the current process in the grid.

Returns:

int Rank of the current process.

inline virtual int *get_coords() override

Returns the coordinates of the current process in the grid.

Returns:

Pointer to an array containing the coordinates.

inline virtual int *get_dims() override

Returns the dimensions of the grid.

Returns:

Pointer to an array containing the grid dimensions.

inline virtual GridMajor getGridMajor() const override

Returns the major ordering of the grid.

Returns:

GridMajor The grid’s major ordering (RowMajor or ColMajor).

inline virtual ncclComm_t get_nccl_comm() const override

Returns the NCCL global communicator for the grid.

Returns:

MPI_Comm Global communicator.

inline virtual ncclComm_t get_nccl_row_comm() const override

Returns the NCCL row communicator for the grid.

Returns:

MPI_Comm Global communicator.

inline virtual ncclComm_t get_nccl_col_comm() const override

Returns the NCCL column communicator for the grid.

Returns:

MPI_Comm Global communicator.

inline virtual int get_blacs_colcomm_ctxt() override

Returns the ScaLAPACK context of column communicator.

Returns:

MPI_Comm Global communicator.

inline virtual int get_blacs_rowcomm_ctxt() override

Returns the ScaLAPACK context of row communicator.

Returns:

MPI_Comm Global communicator.

inline virtual int get_blacs_comm2D_ctxt() override

Returns the ScaLAPACK context of 2D communicator.

Returns:

MPI_Comm Global communicator.

1.4.1.2. chase::grid::MpiGrid2DBase

class MpiGrid2DBase

Abstract base class for managing a 2D MPI grid.

The MpiGrid2DBase class provides an abstract interface for managing an MPI 2D grid. It defines virtual functions for obtaining MPI communicators, grid coordinates, dimensions, and other relevant properties of the grid. It supports optional integration with NCCL and ScaLAPACK.

Subclassed by chase::grid::MpiGrid2D< MajorOrder >

Public Functions

virtual ~MpiGrid2DBase() = default
virtual MPI_Comm get_row_comm() const = 0

Returns the row communicator for the grid.

Returns:

MPI_Comm Row communicator.

virtual MPI_Comm get_col_comm() const = 0

Returns the column communicator for the grid.

Returns:

MPI_Comm Column communicator.

virtual MPI_Comm get_comm() const = 0

Returns the global communicator for the grid.

Returns:

MPI_Comm Global communicator.

virtual int *get_coords() = 0

Returns the coordinates of the current process in the grid.

Returns:

Pointer to an array containing the coordinates.

virtual int *get_dims() = 0

Returns the dimensions of the grid.

Returns:

Pointer to an array containing the grid dimensions.

virtual int get_nprocs() const = 0

Returns the number of processes in the grid.

Returns:

int Number of processes.

virtual int get_myRank() const = 0

Returns the rank of the current process in the grid.

Returns:

int Rank of the current process.

virtual GridMajor getGridMajor() const = 0

Returns the major ordering of the grid.

Returns:

GridMajor The grid’s major ordering (RowMajor or ColMajor).

virtual ncclComm_t get_nccl_comm() const = 0

Returns the NCCL global communicator for the grid.

Returns:

MPI_Comm Global communicator.

virtual ncclComm_t get_nccl_row_comm() const = 0

Returns the NCCL row communicator for the grid.

Returns:

MPI_Comm Global communicator.

virtual ncclComm_t get_nccl_col_comm() const = 0

Returns the NCCL column communicator for the grid.

Returns:

MPI_Comm Global communicator.

virtual int get_blacs_colcomm_ctxt() = 0

Returns the ScaLAPACK context of column communicator.

Returns:

MPI_Comm Global communicator.

virtual int get_blacs_rowcomm_ctxt() = 0

Returns the ScaLAPACK context of row communicator.

Returns:

MPI_Comm Global communicator.

virtual int get_blacs_comm2D_ctxt() = 0

Returns the ScaLAPACK context of 2D communicator.

Returns:

MPI_Comm Global communicator.

1.4.1.3. Backend Types

The backend types are documented as part of the namespace. For detailed information about chase::grid::backend::MPI and chase::grid::backend::NCCL, see the namespace documentation below or refer to the source code.