QMCPACK
CommOperatorsMPI.h File Reference
+ Include dependency graph for CommOperatorsMPI.h:

Go to the source code of this file.

Functions

template<typename T >
void gsum (T &, int)
 dummy declarations to be specialized More...
 
template<>
void gsum (int &g, int gid)
 
template<unsigned N>
void gsum (qmcplusplus::TinyVector< double, N > &g, int gid)
 
template<>
void gsum (std::vector< int > &g, int gid)
 
template<>
void gsum (double &g, int gid)
 
template<unsigned N>
void gsum (qmcplusplus::TinyVector< int, N > &g, int gid)
 
template<>
void gsum (std::vector< double > &g, int gid)
 
template<>
void gsum (qmcplusplus::Matrix< double > &g, int gid)
 
template<>
void gsum (std::vector< std::complex< double >> &g, int gid)
 

Function Documentation

◆ gsum() [1/9]

void gsum ( T &  ,
int   
)
inline

dummy declarations to be specialized

Definition at line 23 of file CommOperatorsMPI.h.

24 {
25  throw std::runtime_error("Need specialization for gsum(T&, int)");
26 }

◆ gsum() [2/9]

void gsum ( int &  g,
int  gid 
)
inline

Definition at line 147 of file CommOperatorsMPI.h.

148 {
149  int gt = g;
150  MPI_Allreduce(&(gt), &(g), 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
151 }

◆ gsum() [3/9]

void gsum ( qmcplusplus::TinyVector< double, N > &  g,
int  gid 
)
inline

Definition at line 154 of file CommOperatorsMPI.h.

References TinyVector< T, D >::begin(), and qmcplusplus::Units::force::N.

155 {
156  //TinyVector<double,N> gt = g;
157  //MPI_Allreduce(gt.begin(), g.begin(), N, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
159  MPI_Allreduce(g.begin(), gt.begin(), N, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
160  g = gt;
161 }
Fixed-size array.
Definition: OhmmsTinyMeta.h:30

◆ gsum() [4/9]

void gsum ( std::vector< int > &  g,
int  gid 
)
inline

Definition at line 164 of file CommOperatorsMPI.h.

165 {
166  std::vector<int> gt(g.size(), 0);
167  MPI_Allreduce(&(g[0]), &(gt[0]), g.size(), MPI_INT, MPI_SUM, MPI_COMM_WORLD);
168  g = gt;
169 }

◆ gsum() [5/9]

void gsum ( double &  g,
int  gid 
)
inline

Definition at line 172 of file CommOperatorsMPI.h.

173 {
174  double gt = g;
175  MPI_Allreduce(&(gt), &(g), 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
176 }

◆ gsum() [6/9]

void gsum ( qmcplusplus::TinyVector< int, N > &  g,
int  gid 
)
inline

Definition at line 179 of file CommOperatorsMPI.h.

References TinyVector< T, D >::begin(), and qmcplusplus::Units::force::N.

180 {
181  //TinyVector<double,N> gt = g;
182  //MPI_Allreduce(gt.begin(), g.begin(), N, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
184  MPI_Allreduce(g.begin(), gt.begin(), N, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
185  g = gt;
186 }
Fixed-size array.
Definition: OhmmsTinyMeta.h:30

◆ gsum() [7/9]

void gsum ( std::vector< double > &  g,
int  gid 
)
inline

Definition at line 189 of file CommOperatorsMPI.h.

190 {
191  std::vector<double> gt(g.size(), 0.0);
192  MPI_Allreduce(&(g[0]), &(gt[0]), g.size(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
193  g = gt;
194 }

◆ gsum() [8/9]

void gsum ( qmcplusplus::Matrix< double > &  g,
int  gid 
)
inline

Definition at line 197 of file CommOperatorsMPI.h.

References Matrix< T, Alloc >::begin(), copy(), Matrix< T, Alloc >::data(), Matrix< T, Alloc >::end(), and Matrix< T, Alloc >::size().

198 {
199  //TinyVector<double,N> gt = g;
200  //MPI_Allreduce(gt.begin(), g.begin(), N, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
201  std::vector<double> gt(g.size());
202  copy(g.begin(), g.end(), gt.begin());
203  MPI_Allreduce(g.data(), &gt[0], g.size(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
204  copy(gt.begin(), gt.end(), g.data());
205 }
Container_t::iterator begin()
Definition: OhmmsMatrix.h:89
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
size_type size() const
Definition: OhmmsMatrix.h:76
Container_t::iterator end()
Definition: OhmmsMatrix.h:90

◆ gsum() [9/9]

void gsum ( std::vector< std::complex< double >> &  g,
int  gid 
)
inline

Definition at line 902 of file CommOperatorsMPI.h.

903 {
904  std::vector<std::complex<double>> gt(g.size(), 0.0);
905  MPI_Allreduce(&(g[0]), &(gt[0]), 2 * g.size(), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
906  g = gt;
907 }