SIRIUS 7.5.0
Electronic structure library and applications
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
sirius::mpi::Communicator Class Reference

MPI communicator wrapper. More...

#include <communicator.hpp>

Public Member Functions

 Communicator ()
 Default constructor. More...
 
 Communicator (MPI_Comm mpi_comm__)
 Constructor for existing communicator. More...
 
 Communicator (std::shared_ptr< MPI_Comm > comm__)
 Constructor for new communicator. More...
 
void abort (int errcode__) const
 
Communicator cart_create (int ndims__, int const *dims__, int const *periods__) const
 
Communicator cart_sub (int const *remain_dims__) const
 
Communicator split (int color__) const
 
Communicator duplicate () const
 
MPI_Comm native () const
 Return the native raw MPI communicator handler. More...
 
int rank () const
 Rank of MPI process inside communicator. More...
 
int size () const
 Size of the communicator (number of ranks). More...
 
int cart_rank (std::vector< int > const &coords__) const
 Rank of MPI process inside communicator with associated Cartesian partitioning. More...
 
bool is_null () const
 
void barrier () const
 
template<typename T , op_t mpi_op__ = op_t::sum>
void reduce (T *buffer__, int count__, int root__) const
 
template<typename T , op_t mpi_op__ = op_t::sum>
void reduce (T *buffer__, int count__, int root__, MPI_Request *req__) const
 
template<typename T , op_t mpi_op__ = op_t::sum>
void reduce (T const *sendbuf__, T *recvbuf__, int count__, int root__) const
 
template<typename T , op_t mpi_op__ = op_t::sum>
void reduce (T const *sendbuf__, T *recvbuf__, int count__, int root__, MPI_Request *req__) const
 
template<typename T , op_t mpi_op__ = op_t::sum>
void allreduce (T *buffer__, int count__) const
 Perform the in-place (the output buffer is used as the input buffer) all-to-all reduction. More...
 
template<typename T , op_t op__ = op_t::sum>
void allreduce (std::vector< T > &buffer__) const
 Perform the in-place (the output buffer is used as the input buffer) all-to-all reduction. More...
 
template<typename T , op_t mpi_op__ = op_t::sum>
void iallreduce (T *buffer__, int count__, MPI_Request *req__) const
 
template<typename T >
void bcast (T *buffer__, int count__, int root__) const
 Perform buffer broadcast. More...
 
void bcast (std::string &str__, int root__) const
 
template<typename T >
void allgather (T *buffer__, int const *recvcounts__, int const *displs__) const
 In-place MPI_Allgatherv. More...
 
template<typename T >
void allgather (T const *sendbuf__, int sendcount__, T *recvbuf__, int const *recvcounts__, int const *displs__) const
 Out-of-place MPI_Allgatherv. More...
 
template<typename T >
void allgather (T const *sendbuf__, T *recvbuf__, int count__, int displs__) const
 
template<typename T >
void allgather (T *buffer__, int count__, int displs__) const
 In-place MPI_Allgatherv. More...
 
template<typename T >
void send (T const *buffer__, int count__, int dest__, int tag__) const
 
template<typename T >
Request isend (T const *buffer__, int count__, int dest__, int tag__) const
 
template<typename T >
void recv (T *buffer__, int count__, int source__, int tag__) const
 
template<typename T >
Request irecv (T *buffer__, int count__, int source__, int tag__) const
 
template<typename T >
void gather (T const *sendbuf__, T *recvbuf__, int const *recvcounts__, int const *displs__, int root__) const
 
template<typename T >
void gather (T const *sendbuf__, T *recvbuf__, int offset__, int count__, int root__) const
 Gather data on a given rank. More...
 
template<typename T >
void scatter (T const *sendbuf__, T *recvbuf__, int const *sendcounts__, int const *displs__, int root__) const
 
template<typename T >
void alltoall (T const *sendbuf__, int sendcounts__, T *recvbuf__, int recvcounts__) const
 
template<typename T >
void alltoall (T const *sendbuf__, int const *sendcounts__, int const *sdispls__, T *recvbuf__, int const *recvcounts__, int const *rdispls__) const
 

Static Public Member Functions

static void initialize (int required__)
 MPI initialization. More...
 
static void finalize ()
 MPI shut down. More...
 
static bool is_finalized ()
 
static Communicator const & self ()
 
static Communicator const & world ()
 
static Communicator const & null ()
 
static Communicator const & map_fcomm (int fcomm__)
 Mapping between Fortran and SIRIUS MPI communicators. More...
 
static int get_tag (int i__, int j__)
 
static std::string processor_name ()
 

Private Member Functions

void init ()
 

Private Attributes

MPI_Comm mpi_comm_raw_ {MPI_COMM_NULL}
 Raw MPI communicator. More...
 
std::shared_ptr< MPI_Comm > mpi_comm_
 Smart pointer to allocated MPI communicator. More...
 
int rank_ {-1}
 Store communicator's rank. More...
 
int size_ {-1}
 Store communicator's size. More...
 

Detailed Description

MPI communicator wrapper.

Definition at line 240 of file communicator.hpp.

Constructor & Destructor Documentation

◆ Communicator() [1/3]

sirius::mpi::Communicator::Communicator ( )
inline

Default constructor.

Definition at line 261 of file communicator.hpp.

◆ Communicator() [2/3]

sirius::mpi::Communicator::Communicator ( MPI_Comm  mpi_comm__)
inlineexplicit

Constructor for existing communicator.

Definition at line 266 of file communicator.hpp.

◆ Communicator() [3/3]

sirius::mpi::Communicator::Communicator ( std::shared_ptr< MPI_Comm >  comm__)
inlineexplicit

Constructor for new communicator.

Definition at line 273 of file communicator.hpp.

Member Function Documentation

◆ init()

void sirius::mpi::Communicator::init ( )
inlineprivate

Definition at line 252 of file communicator.hpp.

◆ initialize()

static void sirius::mpi::Communicator::initialize ( int  required__)
inlinestatic

MPI initialization.

Definition at line 281 of file communicator.hpp.

◆ finalize()

static void sirius::mpi::Communicator::finalize ( )
inlinestatic

MPI shut down.

Definition at line 295 of file communicator.hpp.

◆ is_finalized()

static bool sirius::mpi::Communicator::is_finalized ( )
inlinestatic

Definition at line 300 of file communicator.hpp.

◆ self()

static Communicator const & sirius::mpi::Communicator::self ( )
inlinestatic

Definition at line 307 of file communicator.hpp.

◆ world()

static Communicator const & sirius::mpi::Communicator::world ( )
inlinestatic

Definition at line 313 of file communicator.hpp.

◆ null()

static Communicator const & sirius::mpi::Communicator::null ( )
inlinestatic

Definition at line 319 of file communicator.hpp.

◆ abort()

void sirius::mpi::Communicator::abort ( int  errcode__) const
inline

Definition at line 325 of file communicator.hpp.

◆ cart_create()

Communicator sirius::mpi::Communicator::cart_create ( int  ndims__,
int const *  dims__,
int const *  periods__ 
) const
inline

Definition at line 330 of file communicator.hpp.

◆ cart_sub()

Communicator sirius::mpi::Communicator::cart_sub ( int const *  remain_dims__) const
inline

Definition at line 337 of file communicator.hpp.

◆ split()

Communicator sirius::mpi::Communicator::split ( int  color__) const
inline

Definition at line 344 of file communicator.hpp.

◆ duplicate()

Communicator sirius::mpi::Communicator::duplicate ( ) const
inline

Definition at line 351 of file communicator.hpp.

◆ map_fcomm()

static Communicator const & sirius::mpi::Communicator::map_fcomm ( int  fcomm__)
inlinestatic

Mapping between Fortran and SIRIUS MPI communicators.

Definition at line 359 of file communicator.hpp.

◆ native()

MPI_Comm sirius::mpi::Communicator::native ( ) const
inline

Return the native raw MPI communicator handler.

Definition at line 371 of file communicator.hpp.

◆ get_tag()

static int sirius::mpi::Communicator::get_tag ( int  i__,
int  j__ 
)
inlinestatic

Definition at line 376 of file communicator.hpp.

◆ processor_name()

static std::string sirius::mpi::Communicator::processor_name ( )
inlinestatic

Definition at line 384 of file communicator.hpp.

◆ rank()

int sirius::mpi::Communicator::rank ( ) const
inline

Rank of MPI process inside communicator.

Definition at line 393 of file communicator.hpp.

◆ size()

int sirius::mpi::Communicator::size ( ) const
inline

Size of the communicator (number of ranks).

Definition at line 399 of file communicator.hpp.

◆ cart_rank()

int sirius::mpi::Communicator::cart_rank ( std::vector< int > const &  coords__) const
inline

Rank of MPI process inside communicator with associated Cartesian partitioning.

Definition at line 405 of file communicator.hpp.

◆ is_null()

bool sirius::mpi::Communicator::is_null ( ) const
inline

Definition at line 416 of file communicator.hpp.

◆ barrier()

void sirius::mpi::Communicator::barrier ( ) const
inline

Definition at line 421 of file communicator.hpp.

◆ reduce() [1/4]

template<typename T , op_t mpi_op__ = op_t::sum>
void sirius::mpi::Communicator::reduce ( T *  buffer__,
int  count__,
int  root__ 
) const
inline

Definition at line 431 of file communicator.hpp.

◆ reduce() [2/4]

template<typename T , op_t mpi_op__ = op_t::sum>
void sirius::mpi::Communicator::reduce ( T *  buffer__,
int  count__,
int  root__,
MPI_Request *  req__ 
) const
inline

Definition at line 443 of file communicator.hpp.

◆ reduce() [3/4]

template<typename T , op_t mpi_op__ = op_t::sum>
void sirius::mpi::Communicator::reduce ( T const *  sendbuf__,
T *  recvbuf__,
int  count__,
int  root__ 
) const
inline

Definition at line 455 of file communicator.hpp.

◆ reduce() [4/4]

template<typename T , op_t mpi_op__ = op_t::sum>
void sirius::mpi::Communicator::reduce ( T const *  sendbuf__,
T *  recvbuf__,
int  count__,
int  root__,
MPI_Request *  req__ 
) const
inline

Definition at line 462 of file communicator.hpp.

◆ allreduce() [1/2]

template<typename T , op_t mpi_op__ = op_t::sum>
void sirius::mpi::Communicator::allreduce ( T *  buffer__,
int  count__ 
) const
inline

Perform the in-place (the output buffer is used as the input buffer) all-to-all reduction.

Definition at line 470 of file communicator.hpp.

◆ allreduce() [2/2]

template<typename T , op_t op__ = op_t::sum>
void sirius::mpi::Communicator::allreduce ( std::vector< T > &  buffer__) const
inline

Perform the in-place (the output buffer is used as the input buffer) all-to-all reduction.

Definition at line 478 of file communicator.hpp.

◆ iallreduce()

template<typename T , op_t mpi_op__ = op_t::sum>
void sirius::mpi::Communicator::iallreduce ( T *  buffer__,
int  count__,
MPI_Request *  req__ 
) const
inline

Definition at line 484 of file communicator.hpp.

◆ bcast() [1/2]

template<typename T >
void sirius::mpi::Communicator::bcast ( T *  buffer__,
int  count__,
int  root__ 
) const
inline

Perform buffer broadcast.

Definition at line 495 of file communicator.hpp.

◆ bcast() [2/2]

void sirius::mpi::Communicator::bcast ( std::string &  str__,
int  root__ 
) const
inline

Definition at line 503 of file communicator.hpp.

◆ allgather() [1/4]

template<typename T >
void sirius::mpi::Communicator::allgather ( T *  buffer__,
int const *  recvcounts__,
int const *  displs__ 
) const
inline

In-place MPI_Allgatherv.

Definition at line 522 of file communicator.hpp.

◆ allgather() [2/4]

template<typename T >
void sirius::mpi::Communicator::allgather ( T const *  sendbuf__,
int  sendcount__,
T *  recvbuf__,
int const *  recvcounts__,
int const *  displs__ 
) const
inline

Out-of-place MPI_Allgatherv.

Definition at line 534 of file communicator.hpp.

◆ allgather() [3/4]

template<typename T >
void sirius::mpi::Communicator::allgather ( T const *  sendbuf__,
T *  recvbuf__,
int  count__,
int  displs__ 
) const
inline

Definition at line 545 of file communicator.hpp.

◆ allgather() [4/4]

template<typename T >
void sirius::mpi::Communicator::allgather ( T *  buffer__,
int  count__,
int  displs__ 
) const
inline

In-place MPI_Allgatherv.

Definition at line 569 of file communicator.hpp.

◆ send()

template<typename T >
void sirius::mpi::Communicator::send ( T const *  buffer__,
int  count__,
int  dest__,
int  tag__ 
) const
inline

Definition at line 589 of file communicator.hpp.

◆ isend()

template<typename T >
Request sirius::mpi::Communicator::isend ( T const *  buffer__,
int  count__,
int  dest__,
int  tag__ 
) const
inline

Definition at line 598 of file communicator.hpp.

◆ recv()

template<typename T >
void sirius::mpi::Communicator::recv ( T *  buffer__,
int  count__,
int  source__,
int  tag__ 
) const
inline

Definition at line 609 of file communicator.hpp.

◆ irecv()

template<typename T >
Request sirius::mpi::Communicator::irecv ( T *  buffer__,
int  count__,
int  source__,
int  tag__ 
) const
inline

Definition at line 619 of file communicator.hpp.

◆ gather() [1/2]

template<typename T >
void sirius::mpi::Communicator::gather ( T const *  sendbuf__,
T *  recvbuf__,
int const *  recvcounts__,
int const *  displs__,
int  root__ 
) const
inline

Definition at line 630 of file communicator.hpp.

◆ gather() [2/2]

template<typename T >
void sirius::mpi::Communicator::gather ( T const *  sendbuf__,
T *  recvbuf__,
int  offset__,
int  count__,
int  root__ 
) const
inline

Gather data on a given rank.

Definition at line 643 of file communicator.hpp.

◆ scatter()

template<typename T >
void sirius::mpi::Communicator::scatter ( T const *  sendbuf__,
T *  recvbuf__,
int const *  sendcounts__,
int const *  displs__,
int  root__ 
) const
inline

Definition at line 668 of file communicator.hpp.

◆ alltoall() [1/2]

template<typename T >
void sirius::mpi::Communicator::alltoall ( T const *  sendbuf__,
int  sendcounts__,
T *  recvbuf__,
int  recvcounts__ 
) const
inline

Definition at line 679 of file communicator.hpp.

◆ alltoall() [2/2]

template<typename T >
void sirius::mpi::Communicator::alltoall ( T const *  sendbuf__,
int const *  sendcounts__,
int const *  sdispls__,
T *  recvbuf__,
int const *  recvcounts__,
int const *  rdispls__ 
) const
inline

Definition at line 689 of file communicator.hpp.

Member Data Documentation

◆ mpi_comm_raw_

MPI_Comm sirius::mpi::Communicator::mpi_comm_raw_ {MPI_COMM_NULL}
private

Raw MPI communicator.

Definition at line 244 of file communicator.hpp.

◆ mpi_comm_

std::shared_ptr<MPI_Comm> sirius::mpi::Communicator::mpi_comm_
private

Smart pointer to allocated MPI communicator.

Definition at line 246 of file communicator.hpp.

◆ rank_

int sirius::mpi::Communicator::rank_ {-1}
private

Store communicator's rank.

Definition at line 248 of file communicator.hpp.

◆ size_

int sirius::mpi::Communicator::size_ {-1}
private

Store communicator's size.

Definition at line 250 of file communicator.hpp.


The documentation for this class was generated from the following file: