33 #ifndef __H__PCL_multi_group_communicator_impl
34 #define __H__PCL_multi_group_communicator_impl
63 vector<T> receivedVals;
84 receivedVals.resize (numRecvs * countPerGroup);
87 std::vector<MPI_Request> sendRequests(numSends);
88 std::vector<MPI_Request> recvRequests(numRecvs);
99 for(
size_t i = 1; i <
s; ++i){
100 MPI_Irecv(&receivedVals.front() + recvCount * countPerGroup,
101 (
int) countPerGroup * sizeof (T),
106 &recvRequests[recvCount]);
112 MPI_Isend(
const_cast<T*
>(sendBuf) + imem * countPerGroup,
113 (
int) countPerGroup *
sizeof (T),
118 &sendRequests[sendCount]);
124 "sendCount != sendRequests.size()");
127 "recvCount != recvRequests.size()");
137 size_t recvHandled = 0;
145 const size_t targetBaseInd = imem * countPerGroup;
147 for(
size_t i = 0; i < countPerGroup; ++i)
148 recvBuf[targetBaseInd + i] = sendBuf[targetBaseInd + i];
151 for(
size_t iblock = 1; iblock <
s; ++iblock){
152 size_t srcBaseInd = recvHandled * countPerGroup;
154 for(
size_t i = 0; i < countPerGroup; ++i){
155 recvBuf[targetBaseInd + i] =
156 reducer (recvBuf[targetBaseInd + i],
157 receivedVals[srcBaseInd + i]);
168 const size_t numSendBack = numRecvs;
169 const size_t numRecvBack = numSends;
171 std::vector<MPI_Request> sendRequests(numSendBack);
172 std::vector<MPI_Request> recvRequests(numRecvBack);
174 size_t sendCount = 0;
175 size_t recvCount = 0;
181 if (
s == 1)
continue;
184 for(
size_t i = 1; i <
s; ++i){
185 MPI_Isend(recvBuf + imem * countPerGroup,
186 (
int) countPerGroup *
sizeof (T),
191 &sendRequests[sendCount]);
196 MPI_Irecv(recvBuf + imem * countPerGroup,
197 (
int) countPerGroup *
sizeof (T),
202 &recvRequests[recvCount]);
208 "sendCount != sendRequests.size()");
211 "recvCount != recvRequests.size()");
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
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::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
MPI_Comm get_mpi_communicator() const
returns the mpi-communicator, in case someone needs it
Definition: pcl_process_communicator.h:102
int get_proc_id(size_t index) const
returns the i-th process in the communicator
Definition: pcl_process_communicator.cpp:86
int get_local_proc_id(int globalProcID=pcl::ProcRank()) const
returns the proc-id relative to this communicator
Definition: pcl_process_communicator.cpp:95
Definition: pcl_reduce_traits.h:88
void Waitall(std::vector< MPI_Request > &requests, std::vector< MPI_Status > &statuses)
Definition: pcl_methods.h:136
MPI_Op ReduceOperation
Definition: pcl_methods.h:74
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition: error.h:61
Definition: parallel_grid_layout.h:46
Definition: smart_pointer.h:814