mpi_controller_class Module

Houses object used to interface with MPI outside of PETSc


Used by


Interfaces

interface

  • private pure module function getWorldRank(this) result(rank)

    Getter for worldRank

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(in) :: this

    Return Value integer(kind=ik)

interface

  • private pure module function getWorldSize(this) result(size)

    Getter for worldSize

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(in) :: this

    Return Value integer(kind=ik)

interface

  • private pure module function getRowRank(this) result(rank)

    Getter for rowRank

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(in) :: this

    Return Value integer(kind=ik)

interface

  • private pure module function getRowSize(this) result(size)

    Getter for rowSize

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(in) :: this

    Return Value integer(kind=ik)

interface

  • private pure module function getColRank(this) result(rank)

    Getter for columnRank

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(in) :: this

    Return Value integer(kind=ik)

interface

  • private pure module function getColSize(this) result(size)

    Getter for columnSize

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(in) :: this

    Return Value integer(kind=ik)

interface

  • private pure module function getXHaloWidth(this) result(xHaloWidth)

    Getter for xHaloWidth

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(in) :: this

    Return Value integer(kind=ik)

interface

  • private module function isTrueEverywhere(this, input) result(isTrue)

    Return true if input is true on every processor

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this
    logical, intent(inout) :: input

    Return Value logical

interface

  • private module function allreduceMin(this, input) result(min)

    Return min value on all processors

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this
    real(kind=rk), intent(inout) :: input

    Return Value real(kind=rk)

interface

  • private module function allreduceMax(this, input) result(max)

    Return max value on all processors

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this
    real(kind=rk), intent(inout) :: input

    Return Value real(kind=rk)

interface

  • private module subroutine initMPIController(this, numProcsX, numProcsH)

    MPI controller initialization routine - initializes communicators used outside of PETSc. Optionally sets up row/column communicators.

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this
    integer(kind=ik), intent(in), optional :: numProcsX

    Number of processes in the x-direction

    integer(kind=ik), intent(in), optional :: numProcsH

    Number of processes in the h-direction

interface

  • private module subroutine setUpRows(this, numProcsX, numProcsH)

    Set up row/column communication in controller

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this
    integer(kind=ik), intent(in) :: numProcsX

    Number of processes in the x-direction

    integer(kind=ik), intent(in) :: numProcsH

    Number of processes in the h-direction

interface

  • private module subroutine calculateRowDistData(this, partitionObj, xHaloWidth, numV)

    Initialize distribution DoF data used in exchanging distribution data in a row

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this
    type(Partition), intent(in) :: partitionObj

    Partition object used to retrieve DoF information

    integer(kind=ik), intent(in) :: xHaloWidth

    Halo width in x-direction

    integer(kind=ik), intent(in) :: numV

    Number of cells in v-grid

interface

  • private module subroutine initializeNeighbourPairs(this, periodic)

    Initialize neighbour pairs - if periodic in X adds additional pair to handle this

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this
    logical, intent(in) :: periodic

interface

  • private module subroutine broadcastVarInRow(this, varContainer, name)

    Broadcast variable with given name from row rank 0 process to other row processes - to be used only with non-distribution variables

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this
    type(VariableContainer), intent(inout) :: varContainer

    Variable container in which to broadcasty

    character(len=*), intent(in) :: name

    Name of variable to broadcast

interface

  • private module subroutine exchangeDistVarInRow(this, varContainer, name)

    Exchanges a distribution variable in a processor row

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this
    type(VariableContainer), intent(inout) :: varContainer

    Variable container in which to broadcast

    character(len=*), intent(in) :: name

    Name of variable to broadcast

interface

  • private module subroutine exchangeVarXHalos(this, varContainer, name, varIsDist)

    Exchanges a halos in x direction for given variable

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this
    type(VariableContainer), intent(inout) :: varContainer

    Variable container in which to perform halo exchange

    character(len=*), intent(in) :: name

    Name of variable to exchange

    logical, intent(in) :: varIsDist

    Set to true if variable is a distribution

interface

  • private module subroutine gatherVar(this, localVec, globVec, varIsDist)

    Gather variable values into global vector for output on rank 0. If globVec in not allocated it will be allocated to the correct size, otherwise it is assumed it is of the correct size.

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this
    real(kind=rk), intent(in), dimension(:) :: localVec

    Local vector to gather

    real(kind=rk), intent(inout), allocatable, dimension(:) :: globVec

    Global vector on rank 0 to gather into

    logical, intent(in) :: varIsDist

    Set to true if the gathered variable is a distribution

interface

  • private module subroutine scatterVar(this, globVec, localVec, varIsDist)

    Scatter global variable values into local vector from rank 0.

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this
    real(kind=rk), intent(inout), dimension(:) :: globVec

    Global vector on rank 0 to scatter from

    real(kind=rk), intent(inout), allocatable, dimension(:) :: localVec

    Local vector to scatter into

    logical, intent(in) :: varIsDist

    Set to true if the scattered variable is a distribution

interface

  • private module subroutine broadcastReal(this, vec, rootProc)

    Broadcast real vector from rank rootProc

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this
    real(kind=rk), intent(inout), dimension(:) :: vec
    integer(kind=ik), intent(in), optional :: rootProc

interface

  • private module subroutine broadcastInt(this, vec)

    Broadcast integer vector from rank 0

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this
    integer(kind=ik), intent(inout), dimension(:) :: vec

interface

  • private module subroutine broadcastLogical(this, vec)

    Broadcast logical vector from rank 0

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this
    logical, intent(inout), dimension(:) :: vec

interface

  • private module subroutine broadcastCharacter(this, vec)

    Broadcast character vector from rank 0

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this
    character(len=:), intent(inout), allocatable :: vec

interface

  • private module subroutine barrier(this)

    Calls MPI barrier on commWorld

    Arguments

    Type IntentOptional Attributes Name
    class(MPIController), intent(inout) :: this

Derived Types

type, public ::  CommunicationData

Contains lists of variables to broadcast in processor rows and variables participating in halo exchange

Components

Type Visibility Attributes Name Initial
type(StringArray), public, allocatable, dimension(:) :: varsToBroadcast

Variables to broadcast/exchange in processor row

type(StringArray), public, allocatable, dimension(:) :: haloExchangeVars

Variables that should participate in halo exchange

type(StringArray), public, allocatable, dimension(:) :: scalarsToBroadcast

Scalar variables to broadcast everywhere

integer(kind=ik), public, allocatable, dimension(:) :: scalarRoots

Root processes for each broadcast scalar

type, public, extends(Object) ::  MPIController

Provides a centralized interface with MPI and various support routines compatible with ReMKiT1D needs

Components

Type Visibility Attributes Name Initial
logical, public :: userDefined = .false.

True only if user explicitly sets it to true

type(MPI_Comm), private :: worldComm

Main MPI_Comm_World

type(MPI_Comm), private :: rowComm

Communicator for processors rows (those with the same x-domain but different h-domains)

type(MPI_Comm), private :: colComm

Communicator for processor columns (those with the same h-domain but different x-domains)

integer(kind=ik), private :: worldRank

Current process' world rank

integer(kind=ik), private :: worldSize

Size of worldComm

integer(kind=ik), private :: rowRank

Current process' row rank

integer(kind=ik), private :: rowSize

Size of rowComm

integer(kind=ik), private :: colRank

Current process' column rank

integer(kind=ik), private :: colSize

Size of colComm

integer(kind=ik), private :: rowNumX

Number of x-grid points in local processor row

integer(kind=ik), private, allocatable, dimension(:) :: colNumX

Number of x-grid points in each column processor

integer(kind=ik), private, allocatable, dimension(:) :: xDispls

Displacement in x-direction used for MPI gather

integer(kind=ik), private :: xHaloWidth

Halo width in x-direction

integer(kind=ik), private :: numV

Number of velocity cells in grid

integer(kind=ik), private :: numH

Number of harmonics in grid

integer(kind=ik), public, allocatable, dimension(:) :: rowNumH

locNumH for each processor in row

integer(kind=ik), public, allocatable, dimension(:) :: rowHOffset

harmonic offset for each processor in row

type(RealArray), public, allocatable, dimension(:) :: distBuffer

Distribution variable buffer used in halo exchange

type(IntArray), public, allocatable, dimension(:) :: neighbourPairs

Int array for each x-grid neighbour pair with entry of length 2 first element is left neighbour rank, second is right - allows for periodic domain

logical, public :: rowsSetUp

True if row data is set up and ready for communication

Type-Bound Procedures

procedure, public :: isDefined => isDefinedObject
procedure, public :: makeDefined => makeDefinedObject
procedure, public :: makeUndefined => makeUndefinedObject
procedure, public :: getWorldRank
procedure, public :: getWorldSize
procedure, public :: getRowRank
procedure, public :: getRowSize
procedure, public :: getColRank
procedure, public :: getColSize
procedure, public :: getXHaloWidth
procedure, public :: calculateRowDistData
procedure, public :: initializeNeighbourPairs
procedure, public :: broadcastVarInRow
procedure, public :: exchangeDistVarInRow
procedure, public :: exchangeVarXHalos
procedure, public :: broadcastReal
procedure, public :: broadcastInt
procedure, public :: broadcastLogical
procedure, public :: broadcastCharacter
procedure, public :: barrier
procedure, public :: gatherVar
procedure, public :: scatterVar
procedure, public :: setUpRows
procedure, public :: isTrueEverywhere
procedure, public :: allreduceMax
procedure, public :: allreduceMin
procedure, public :: init => initMPIController