mptensor v0.4.0
Parallel Library for Tensor Network Methods
Loading...
Searching...
No Matches
mptensor::mpi_wrapper Namespace Reference

Wrappers of MPI library. More...

Functions

template<typename C >
MPI_Datatype mpi_datatype ()
 Template function for MPI Datatype.
 
template<>
MPI_Datatype mpi_datatype< char > ()
 
template<>
MPI_Datatype mpi_datatype< signed char > ()
 
template<>
MPI_Datatype mpi_datatype< unsigned char > ()
 
template<>
MPI_Datatype mpi_datatype< short > ()
 
template<>
MPI_Datatype mpi_datatype< unsigned short > ()
 
template<>
MPI_Datatype mpi_datatype< int > ()
 
template<>
MPI_Datatype mpi_datatype< unsigned int > ()
 
template<>
MPI_Datatype mpi_datatype< long int > ()
 
template<>
MPI_Datatype mpi_datatype< unsigned long int > ()
 
template<>
MPI_Datatype mpi_datatype< long long int > ()
 
template<>
MPI_Datatype mpi_datatype< unsigned long long int > ()
 
template<>
MPI_Datatype mpi_datatype< double > ()
 
template<>
MPI_Datatype mpi_datatype< complex > ()
 
template<typename C >
C allreduce_sum (C val, const MPI_Comm &comm)
 Calculate a summation over MPI communicator.
 
template<typename C >
std::vector< Callreduce_vec (const std::vector< C > &vec, const MPI_Comm &comm)
 Calculate a summation of each element of vector over MPI communicator.
 
template<typename C >
void allreduce (const C *sendbuf, C *recvbuf, int count, MPI_Op op, const MPI_Comm &comm)
 Wrapper of MPI_Allreduce.
 
template<typename C >
void sendrecv (const C *sendbuf, int sendcount, int dest, int sendtag, C *recvbuf, int recvcount, int source, int recvtag, const MPI_Comm &comm)
 Wrapper of MPI_Sendrecv.
 
template<typename C >
void sendrecv (const std::vector< C > &send_vec, int dest, int sendtag, std::vector< C > &recv_vec, int source, int recvtag, const MPI_Comm &comm)
 Wrapper of MPI_Sendrecv for std::vector.
 
template<typename C >
void alltoall (const C *sendbuf, int sendcount, C *recvbuf, int recvcount, const MPI_Comm &comm)
 Wrapper of MPI_Alltoall.
 
template<typename C >
void alltoallv (const C *sendbuf, const int *sendcounts, const int *sdispls, C *recvbuf, const int *recvcounts, const int *rdispls, const MPI_Comm &comm)
 Wrapper of MPI_Alltoallv.
 
template<typename C >
void bcast (C *buffer, int count, int root, const MPI_Comm &comm)
 Wrapper of MPI_Bcast.
 

Detailed Description

Wrappers of MPI library.

Function Documentation

◆ allreduce()

template<typename C >
void mptensor::mpi_wrapper::allreduce ( const C sendbuf,
C recvbuf,
int  count,
MPI_Op  op,
const MPI_Comm comm 
)
inline

Wrapper of MPI_Allreduce.

Parameters
[in]sendbufsend buffer
[out]recvbufreceive buffer
[in]countthe number in send buffer
[in]opOpreation
[in]commMPI Communicator

◆ allreduce_sum()

template<typename C >
C mptensor::mpi_wrapper::allreduce_sum ( C  val,
const MPI_Comm comm 
)
inline

Calculate a summation over MPI communicator.

Parameters
[in]valvalue to be summed.
[in]commMPI communicator.
Returns
summation of val.

◆ allreduce_vec()

template<typename C >
std::vector< C > mptensor::mpi_wrapper::allreduce_vec ( const std::vector< C > &  vec,
const MPI_Comm comm 
)
inline

Calculate a summation of each element of vector over MPI communicator.

Parameters
[in]vecvector to be summed.
[in]commMPI communicator.
Returns
resulted vector.

◆ alltoall()

template<typename C >
void mptensor::mpi_wrapper::alltoall ( const C sendbuf,
int  sendcount,
C recvbuf,
int  recvcount,
const MPI_Comm comm 
)
inline

Wrapper of MPI_Alltoall.

Parameters
[in]sendbufStarting address of send buffer.
[in]sendcountThe number of elements to send.
[out]recvbufAddress of receive buffer.
[in]recvcountThe number of elements to receive.
[in]commCommunicator over which data is to be exchanged.

◆ alltoallv()

template<typename C >
void mptensor::mpi_wrapper::alltoallv ( const C sendbuf,
const int sendcounts,
const int sdispls,
C recvbuf,
const int recvcounts,
const int rdispls,
const MPI_Comm comm 
)
inline

Wrapper of MPI_Alltoallv.

Parameters
[in]sendbufStarting address of send buffer.
[in]sendcountsInteger array, where entry i specifies the number of elements to send to rank i.
[in]sdisplsInteger array, where entry i specifies the displacement (offset from sendbuf, in units of sendtype) from which to send data to rank i.
[out]recvbufAddress of receive buffer.
[in]recvcountsInteger array, where entry j specifies the number of elements to receive from rank j.
[in]rdisplsInteger array, where entry j specifies the displacement (offset from recvbuf, in units of recvtype) to which data from rank j should be written.
[in]commCommunicator over which data is to be exchanged.

◆ bcast()

template<typename C >
void mptensor::mpi_wrapper::bcast ( C buffer,
int  count,
int  root,
const MPI_Comm comm 
)
inline

Wrapper of MPI_Bcast.

Parameters
bufferStarting address of buffer.
countNumber of entries in buffer.
rootRank of broadcast root.
commCommunicator.

◆ mpi_datatype()

template<typename C >
MPI_Datatype mptensor::mpi_wrapper::mpi_datatype ( )
inline

Template function for MPI Datatype.

◆ mpi_datatype< char >()

◆ mpi_datatype< complex >()

◆ mpi_datatype< double >()

◆ mpi_datatype< int >()

◆ mpi_datatype< long int >()

◆ mpi_datatype< long long int >()

◆ mpi_datatype< short >()

◆ mpi_datatype< signed char >()

◆ mpi_datatype< unsigned char >()

◆ mpi_datatype< unsigned int >()

◆ mpi_datatype< unsigned long int >()

◆ mpi_datatype< unsigned long long int >()

◆ mpi_datatype< unsigned short >()

◆ sendrecv() [1/2]

template<typename C >
void mptensor::mpi_wrapper::sendrecv ( const C sendbuf,
int  sendcount,
int  dest,
int  sendtag,
C recvbuf,
int  recvcount,
int  source,
int  recvtag,
const MPI_Comm comm 
)
inline

Wrapper of MPI_Sendrecv.

Parameters
[in]sendbufsend buffer
[in]sendcountthe number of elements to send
[in]destRank of destination
[in]sendtagSend tag
[out]recvbufreceive buffer
[in]recvcountthe number of elements to receive
[in]sourceRank of source
[in]recvtagReceive tag
[in]commMPI Communicator

◆ sendrecv() [2/2]

template<typename C >
void mptensor::mpi_wrapper::sendrecv ( const std::vector< C > &  send_vec,
int  dest,
int  sendtag,
std::vector< C > &  recv_vec,
int  source,
int  recvtag,
const MPI_Comm comm 
)
inline

Wrapper of MPI_Sendrecv for std::vector.

Parameters
[in]send_vecsend vector
[in]destRank of destination
[in]sendtagSend tag
[out]recv_vecreceive vector
[in]sourceRank of source
[in]recvtagReceive tag
[in]commMPI Communicator