Global MPI operations
|
#include <iostream>
#include <mpi.h>
#include <string>
#include <vector>
Functions | |
void | vddiv (std::vector< double > &x, std::vector< double > const &y, std::vector< double > const &z) |
Element-wise vector divison x_k = y_k/z_k. More... | |
void | vdaxpy (std::vector< double > &x, std::vector< double > const &y, double alpha, std::vector< double > const &z) |
Element-wise daxpy operation x(k) = y(k) + alpha*z(k). More... | |
void | Send_ProcD (const int to, std::vector< double > const &xin, MPI_Comm const &icomm) |
void | Recv_ProcD (const int from, std::vector< double > &xout, MPI_Comm const &icomm) |
void | ExchangeD (const int yourid, std::vector< double > const &xin, std::vector< double > &xout, MPI_Comm const &icomm) |
double | dscapr (std::vector< double > const &x, std::vector< double > const &y) |
Calculates the Euclidean inner product of two vectors. More... | |
double | L2_scapr (std::vector< double > const &x, std::vector< double > const &y) |
double | par_scalar (std::vector< double > const &x, std::vector< double > const &y, MPI_Comm const &icomm=MPI_COMM_WORLD) |
int | ReadIn (std::string const &ss=std::string(), MPI_Comm const &icomm=MPI_COMM_WORLD) |
template<class T > | |
void | DebugVector (std::vector< T > const &v, std::string const &ss=std::string(), MPI_Comm const &icomm=MPI_COMM_WORLD) |
bool | CompareVectors (std::vector< double > const &x, int n, double const y[], double const eps=0.0) |
Compares an STL vector with POD vector. More... | |
template<class T > | |
std::ostream & | operator<< (std::ostream &s, std::vector< T > const &v) |
void | ExchangeAll (std::vector< double > const &xin, std::vector< double > &yout, MPI_Comm const &icomm=MPI_COMM_WORLD) |
void | ExchangeAllInPlace (std::vector< double > &xin, MPI_Comm const &icomm=MPI_COMM_WORLD) |
bool CompareVectors | ( | std::vector< double > const & | x, |
int | n, | ||
double const | y[], | ||
double const | eps = 0.0 |
||
) |
Compares an STL vector with POD vector.
The accuracy criteria \( |x_k-y_k| < \varepsilon \left({1+0.5(|x_k|+|y_k|)}\right) \) follows the book by Stoyan/Baran, p.8.
[in] | x | STL vector |
[in] | n | length of POD vector |
[in] | y | POD vector |
[in] | eps | relative accuracy criteria (default := 0.0). |
void DebugVector | ( | std::vector< T > const & | v, |
std::string const & | ss = std::string() , |
||
MPI_Comm const & | icomm = MPI_COMM_WORLD |
||
) |
Print entries of a vector to standard output.
[in] | v | vector values |
[in] | ss | string containing the vector name |
[in] | icomm | communicator group for MPI |
double dscapr | ( | std::vector< double > const & | x, |
std::vector< double > const & | y | ||
) |
Calculates the Euclidean inner product of two vectors.
[in] | x | vector |
[in] | y | vector |
void ExchangeAll | ( | std::vector< double > const & | xin, |
std::vector< double > & | yout, | ||
MPI_Comm const & | icomm = MPI_COMM_WORLD |
||
) |
Exchanges equal size partions of vector xin
with all MPI processes. The received data are return in vector yout
.
[in] | xin | input vector |
[out] | yout | output vector |
[in] | icomm | MPI communicator |
void ExchangeAllInPlace | ( | std::vector< double > & | xin, |
MPI_Comm const & | icomm = MPI_COMM_WORLD |
||
) |
Exchanges equal size partions of vector xin
with all MPI processes. The received data are return in vector xin
.
[in,out] | xin | input/output vector |
[in] | icomm | MPI communicator |
void ExchangeD | ( | const int | yourid, |
std::vector< double > const & | xin, | ||
std::vector< double > & | xout, | ||
MPI_Comm const & | icomm | ||
) |
Exchanges vectors between my process and the process with rank yourid
.
[in] | yourid | rank of process in communicator icomm to send the message |
[in] | xin | my vector |
[in,out] | xout | vector (preallocated, size might change depending on data to receive) |
[in] | icomm | communicator to use |
|
inline |
std::ostream& operator<< | ( | std::ostream & | s, |
std::vector< T > const & | v | ||
) |
Output operator for vector
[in,out] | s | output stream, e.g. cout |
[in] | v | vector @return output stream |
double par_scalar | ( | std::vector< double > const & | x, |
std::vector< double > const & | y, | ||
MPI_Comm const & | icomm = MPI_COMM_WORLD |
||
) |
Parallel inner product
[in] | x | vector |
[in] | y | vector |
[in] | icomm | MPI communicator |
|
inline |
void Recv_ProcD | ( | const int | from, |
std::vector< double > & | xout, | ||
MPI_Comm const & | icomm | ||
) |
Receives data from process with rank from
into a double-vector xout
.
[in] | from | rank of process in communicator icomm to receive the message from |
[in,out] | xout | vector (preallocated, size might change depending on data to receive) |
[in] | icomm | communicator to use |
void Send_ProcD | ( | const int | to, |
std::vector< double > const & | xin, | ||
MPI_Comm const & | icomm | ||
) |
Sends data of double-vector xin
to the process with rank to
.
[in] | to | rank of process in communicator icomm to send the message |
[in] | xin | vector |
[in] | icomm | communicator to use |
void vdaxpy | ( | std::vector< double > & | x, |
std::vector< double > const & | y, | ||
double | alpha, | ||
std::vector< double > const & | z | ||
) |
Element-wise daxpy operation x(k) = y(k) + alpha*z(k).
[out] | x | target vector |
[in] | y | source vector |
[in] | alpha | scalar |
[in] | z | source vector |
void vddiv | ( | std::vector< double > & | x, |
std::vector< double > const & | y, | ||
std::vector< double > const & | z | ||
) |
Element-wise vector divison x_k = y_k/z_k.
[out] | x | target vector |
[in] | y | source vector |
[in] | z | source vector |