Topology

Located in file: MEL.hpp

void MEL::TopoCartesianMakeDims(const int numProcs, const int numdims, int *dims)

Compute the ‘ideal’ dimensions for a topolgy over n-processes.

See
MPI_Dims_create
Parameters
  • numProcs -

    The number of processes in the topology

  • numdims -

    The number of dimensions in the topology

  • dims -

    Pointer to an (already allocated) array of length numdims

void MEL::TopoCartesianMakeDims(const Comm &comm, const int numdims, int *dims)

Compute the ‘ideal’ dimensions for a topolgy over n-processes.

Parameters
  • comm -

    The comm object the topology should represent

  • numdims -

    The number of dimensions in the topology

  • dims -

    Pointer to an (already allocated) array of length numdims

std::vector<int> MEL::TopoCartesianMakeDims(const int numProcs, const int numdims)

Compute the ‘ideal’ dimensions for a topolgy over n-processes.

Return
Returns a std::vector of dimension sizes
Parameters
  • numProcs -

    The number of processes in the topology

  • numdims -

    The number of dimensions in the topology

std::vector<int> MEL::TopoCartesianMakeDims(const Comm &comm, const int numdims)

Compute the ‘ideal’ dimensions for a topolgy over n-processes.

Return
Returns a std::vector of dimension sizes
Parameters
  • comm -

    The comm object the topology should represent

  • numdims -

    The number of dimensions in the topology

Comm MEL::TopoCartesianCreate(const Comm &comm, int numdims, const int *dims, const int *periods)

Create a cartesian topology over a comm world.

See
MPI_Cart_create
Return
Returns a Comm world with an attached topology
Parameters
  • comm -

    The comm object the topology should represent

  • numdims -

    The number of dimensions in the topology

  • dims -

    Pointer to an array of sizes of each dimension

  • periods -

    Pointer to an array of logicals representing if each dimension is periodic or not

Comm MEL::TopoCartesianCreate(const Comm &comm, const std::vector<TopoCartesian_Dim> &dims)

Create a cartesian topology over a comm world.

Return
Returns a Comm world with an attached topology
Parameters
  • comm -

    The comm object the topology should represent

  • dims -

    A std::vector of pairs representing dimension sizes and whether dimensions are periodic

int MEL::TopoCartesianNumDims(const Comm &comm)

Get the number of dimensions in an attached cartesian topology of a comm world.

See
MPI_Cartdim_get
Return
Returns the number of dimensions in the attached cartesian topology
Parameters
  • comm -

    The comm object the topology is attached to

int MEL::TopoCartesianRank(const Comm &comm, const int *coords)

Get the rank within the attached cartesian topology of a comm world.

See
MPI_Cart_rank
Return
Returns the rank in the attached cartesian topology
Parameters
  • comm -

    The comm object the topology is attached to

  • coords -

    Pointer to an array representing the n-dim coordinates in the topology

int MEL::TopoCartesianRank(const Comm &comm, const std::vector<int> coords)

Get the rank within the attached cartesian topology of a comm world.

Return
Returns the rank in the attached cartesian topology
Parameters
  • comm -

    The comm object the topology is attached to

  • coords -

    A std::vector representing the n-dim coordinates in the topology

void MEL::TopoCartesianCoords(const Comm &comm, const int rank, int numdims, int *coords)

Get the n-dim coordinates within the attached cartesian topology of a comm world.

See
MPI_Cart_coords
Parameters
  • comm -

    The comm object the topology is attached to

  • rank -

    The rank within comm

  • numdims -

    The number of dimensions in the topology

  • coords -

    Pointer to an array of numdims ints representing the coordinates

std::vector<int> MEL::TopoCartesianCoords(const Comm &comm, const int rank, int numdims)

Get the n-dim coordinates within the attached cartesian topology of a comm world.

Return
Returns a std::vector representing the n-dim coordinates
Parameters
  • comm -

    The comm object the topology is attached to

  • rank -

    The rank within comm

  • numdims -

    The number of dimensions in the topology

std::vector<int> MEL::TopoCartesianCoords(const Comm &comm, const int rank)

Get the n-dim coordinates within the attached cartesian topology of a comm world.

Return
Returns a std::vector representing the n-dim coordinates
Parameters
  • comm -

    The comm object the topology is attached to

  • rank -

    The rank within comm

std::vector<int> MEL::TopoCartesianCoords(const Comm &comm)

Get the n-dim coordinates within the attached cartesian topology of a comm world.

Return
Returns a std::vector representing the n-dim coordinates
Parameters
  • comm -

    The comm object the topology is attached to

void MEL::TopoCartesianGet(const Comm &comm, int numdims, int *dims, int *periods, int *coords)

Get the properties of an attached cartesian topology of a comm world.

See
MPI_Cart_get
Parameters
  • comm -

    The comm object the topology is attached to

  • numdims -

    The number of dimensions in the topology

  • dims -

    Pointer to an array of n-dims size representing the sizes of each dimension

  • periods -

    Pointer to an array of n-dims size representing whether each dimension is periodic

  • coords -

    Pointer to an array of n-dims size representing the coordinate in each dimension

std::pair<std::vector<int>, std::vector<TopoCartesian_Dim>> MEL::TopoCartesianGet(const Comm &comm)

Get the properties of an attached cartesian topology of a comm world.

Return
Returns a std::pair of a std::vector representing the process coordinates, and a std::vector of pairs representing the dimension sizes and periods
Parameters
  • comm -

    The comm object the topology is attached to

void MEL::TopoCartesianShift(const Comm &comm, int direction, int disp, int &rank_prev, int &rank_next)

Compute the ranks of a left and right shifted neighbor for a given dimension within a topology.

See
MPI_Cart_shift
Parameters
  • comm -

    The comm object the topology is attached to

  • direction -

    The dimension to shift in

  • disp -

    How much to shift by

  • rank_prev -

    The left neighbour

  • rank_next -

    The right neighbour

std::pair<int, int> MEL::TopoCartesianShift(const Comm &comm, int direction, int disp)

Compute the ranks of a left and right shifted neighbor for a given dimension within a topology.

Return
Returns a std::pair representing the ranks of the left and right neighbour
Parameters
  • comm -

    The comm object the topology is attached to

  • direction -

    The dimension to shift in

  • disp -

    How much to shift by

CartesianStencil2D5P MEL::TopoCartesianStencil2D5P(const Comm &comm)

Create a 2D 5-point stencil of ranks representing the neighbouring processes.

Return
Returns a 2D 5-point stencil of comm ranks
Parameters
  • comm -

    The comm object the topology is attached to

CartesianStencil2D9P MEL::TopoCartesianStencil2D9P(const Comm &comm)

Create a 2D 9-point stencil of ranks representing the neighbouring processes.

Return
Returns a 2D 9-point stencil of comm ranks
Parameters
  • comm -

    The comm object the topology is attached to