ug4
pcl_multi_group_communicator.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017: G-CSC, Goethe University Frankfurt
3  * Author: Sebastian Reiter
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #ifndef __H__pcl_multi_group_communicator
34 #define __H__pcl_multi_group_communicator
35 
36 #include <vector>
38 
39 
40 namespace pcl {
41 
43 
50 public:
52  MultiGroupCommunicator (const std::vector<bool>& participates,
54 
55  void reinit (const std::vector<bool>& participates);
56 
57  bool participates (size_t igrp) const;
58  size_t num_groups () const;
59 
60  size_t num_memberships () const;
61  size_t membership_group_index (size_t imem) const;
62 
64 
67  template<typename T>
68  void allreduce (const T *sendBuf, T *recvBuf,
69  size_t countPerGroup, ReduceOperation op) const;
70 
71 private:
73  std::vector<bool> m_participates;
74  std::vector<size_t> m_memberships;
75  std::vector<int> m_groupMembers;
76  std::vector<size_t> m_groupOffsets;
77  std::map<int, ug::BinaryBuffer> m_binBufs;
78 
79 };
80 
81 }// end of namespace
82 
83 
85 // include implementation
87 
88 
89 #endif //__H__pcl_multi_group_communicator
communicator for simultaneous data exchange between many small groups
Definition: pcl_multi_group_communicator.h:49
bool participates(size_t igrp) const
Definition: pcl_multi_group_communicator.cpp:138
std::vector< bool > m_participates
size: #groups
Definition: pcl_multi_group_communicator.h:73
MultiGroupCommunicator(ProcessCommunicator com=ProcessCommunicator())
Definition: pcl_multi_group_communicator.cpp:41
size_t membership_group_index(size_t imem) const
Definition: pcl_multi_group_communicator.cpp:158
std::vector< int > m_groupMembers
size: m_groupOffsets.back(). Consecutively holds proc-indices of each group in which the process part...
Definition: pcl_multi_group_communicator.h:75
size_t num_groups() const
Definition: pcl_multi_group_communicator.cpp:145
std::vector< size_t > m_memberships
size: #memberships. Holds indices to groups in which the process participates
Definition: pcl_multi_group_communicator.h:74
ProcessCommunicator m_com
Definition: pcl_multi_group_communicator.h:72
std::map< int, ug::BinaryBuffer > m_binBufs
used for sending/receiving data from/to processes
Definition: pcl_multi_group_communicator.h:77
std::vector< size_t > m_groupOffsets
size: #memberships+1. Offset of each group in m_groupMembers. The last entry always holds m_groupMemb...
Definition: pcl_multi_group_communicator.h:76
void allreduce(const T *sendBuf, T *recvBuf, size_t countPerGroup, ReduceOperation op) const
performs an allreduce between all groups
Definition: pcl_multi_group_communicator_impl.hpp:44
void reinit(const std::vector< bool > &participates)
Definition: pcl_multi_group_communicator.cpp:56
size_t num_memberships() const
Definition: pcl_multi_group_communicator.cpp:152
Definition: pcl_process_communicator.h:70
MPI_Op ReduceOperation
Definition: pcl_methods.h:74
Definition: parallel_grid_layout.h:46