mptensor  v0.3.0
Parallel Library for Tensor Network Methods
mpi_wrapper.hpp
Go to the documentation of this file.
1 /*
2  mptensor - Parallel Library for Tensor Network Methods
3 
4  Copyright 2016 Satoshi Morita
5 
6  mptensor is free software: you can redistribute it and/or modify it
7  under the terms of the GNU Lesser General Public License as
8  published by the Free Software Foundation, either version 3 of the
9  License, or (at your option) any later version.
10 
11  mptensor is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with mptensor. If not, see
18  <https://www.gnu.org/licenses/>.
19 */
20 
29 #ifndef _MPI_WRAPPER_HPP_
30 #define _MPI_WRAPPER_HPP_
31 
32 #ifndef _NO_MPI
33 
34 #include <mpi.h>
35 #include <vector>
36 
37 namespace mptensor {
38 
40 namespace mpi_wrapper {
41 
43 
49 template <typename C>
50 C allreduce_sum(C val, const MPI_Comm &comm);
51 
53 
59 template <typename C>
60 std::vector<C> allreduce_vec(const std::vector<C> &vec, const MPI_Comm &comm);
61 
63 
73 template <typename C>
74 void send_recv_vector(const std::vector<C> &send_vec, int dest, int sendtag,
75  std::vector<C> &recv_vec, int source, int recvtag,
76  const MPI_Comm &comm, MPI_Status &status);
77 
79 
91 template <typename C>
92 void alltoallv(const C *sendbuf, const int *sendcounts, const int *sdispls,
93  C *recvbuf, const int *recvcounts, const int *rdispls,
94  const MPI_Comm &comm);
95 
97 
103 template <typename C>
104 void bcast(C *buffer, int count, int root, const MPI_Comm &comm);
105 
106 } // namespace mpi_wrapper
107 } // namespace mptensor
108 
109 #endif // _NO_MPI
110 #endif // _MPI_WRAPPER_HPP_
std::vector< C > allreduce_vec(const std::vector< C > &vec, const MPI_Comm &comm)
Calculate a summation of each element of vector over MPI communicator.
void bcast(C *buffer, int count, int root, const MPI_Comm &comm)
Wrapper of MPI_Bcast.
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.
void send_recv_vector(const std::vector< C > &send_vec, int dest, int sendtag, std::vector< C > &recv_vec, int source, int recvtag, const MPI_Comm &comm, MPI_Status &status)
Wrapper of MPI_Sendrecv.
C allreduce_sum(C val, const MPI_Comm &comm)
Calculate a summation over MPI communicator.
Definition: complex.hpp:34