CArl
Code Arlequin / C++ implementation
mpi_carl_tools.h
Go to the documentation of this file.
1 /*
2  * mpi_carl_tools.h
3  *
4  * Created on: Feb 22, 2016
5  * Author: Thiago Milanetto Schlittler
6  */
7 
8 #ifndef COMMON_LIBMESH_CODE_MPI_CARL_TOOLS_H_
9 #define COMMON_LIBMESH_CODE_MPI_CARL_TOOLS_H_
10 
11 #include "carl_headers.h"
12 
13 namespace carl
14 {
15 
17  std::unordered_map<int,int>& index_map,
18  const libMesh::Parallel::Communicator& CommComm,
19  int origin_rank = 0);
20 
21 template <typename T>
22 inline void MPI_reduce_vector(std::vector<T> & r, int root, const libMesh::Parallel::Communicator& Comm)
23 {
24  if (Comm.size() > 1 && !r.empty())
25  {
26  libmesh_assert(Comm.verify(r.size()));
27 
28  std::vector<T> temp(r);
29  MPI_Reduce(&temp[0], &r[0], libMesh::cast_int<int>(r.size()),
30  libMesh::Parallel::StandardType<T>(&temp[0]), MPI_SUM, root,
31  Comm.get());
32  }
33  }
34 }
35 #endif /* COMMON_LIBMESH_CODE_MPI_CARL_TOOLS_H_ */
void broadcast_index_unordered_map(std::unordered_map< int, int > &index_map, const libMesh::Parallel::Communicator &CommComm, int origin_rank=0)
void MPI_reduce_vector(std::vector< T > &r, int root, const libMesh::Parallel::Communicator &Comm)