36 const std::unordered_map<CepsUInt,CepsUInt>& orig,
37 std::unordered_map<CepsUInt,CepsUInt>& dest
48 keysOrig .reserve(orig.size());
49 valuesOrig.reserve(orig.size());
50 for (
auto &[key, value] : orig)
52 keysOrig .push_back(key);
53 valuesOrig.push_back(value);
56 int origSize = (int)orig.size();
61 for (
CepsUInt i = 1U; i < gridSize + 1; i++)
62 displs[i] = displs[i-1] + localSizes[i-1];
67 keysDest .resize(displs[gridSize]);
68 valuesDest.resize(displs[gridSize]);
70 int res1 = MPI_Allgatherv(keysOrig.data(),orig.size(),
CEPS_MPI_UINT,
71 keysDest.data(),localSizes.data(),displs.data(),
76 int res2 = MPI_Allgatherv(valuesOrig.data(),orig.size(),
CEPS_MPI_UINT,
77 valuesDest.data(),localSizes.data(),displs.data(),
83 for (
CepsUInt i=0U; i<keysDest.size(); ++i)
84 dest[keysDest[i]] = valuesDest[i];
92 sendRecvWithMatrix(
const Eigen::Matrix<CepsUInt, Eigen::Dynamic, Eigen::Dynamic> &commMat,
102 "given comm Matrix has wrong shape " << commMat.rows() <<
" " << commMat.cols()
105 std::map<CepsUInt, CepsUInt> connectivity;
112 sBuffers[i].resize(ns);
114 sBuffers[i][j].resize(sendBuffers[j].size());
117 for (
CepsUInt k=0;k<sendBuffers[j].size();k++)
119 sBuffers[0][j][k] = sendBuffers[j][k].h1;
120 sBuffers[1][j][k] = sendBuffers[j][k].h2;
121 sBuffers[2][j][k] = sendBuffers[j][k].h3;
127 rBuffers[dim].resize(gridSize);
132 for (
CepsUInt sndr=0u; sndr<gridSize; sndr++)
133 for (
CepsUInt rcvr=0u; rcvr<gridSize; rcvr++)
135 CepsInt tag = dim+3*(sndr*gridSize+rcvr);
136 CepsInt dataSize = commMat(sndr,rcvr);
138 MPI_Isend(sBuffers[dim][rcvr].data(),dataSize,
CEPS_MPI_SHASH,rcvr,tag,comm,&request);
141 rBuffers[dim][sndr].resize(dataSize);
142 MPI_Recv(rBuffers[dim][sndr].data(),dataSize,
CEPS_MPI_SHASH,sndr,tag,comm,&status);
182 recvBuffers.resize(rs);
185 CepsUInt rss = rBuffers[0][j].size();
186 recvBuffers[j].resize(rss);
189 recvBuffers[j][k].h1 = rBuffers[0][j][k];
190 recvBuffers[j][k].h2 = rBuffers[1][j][k];
191 recvBuffers[j][k].h3 = rBuffers[2][j][k];
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
std::vector< _Type, _Alloc > CepsVector
C++ vector.
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
CepsArray< _Type, 3U > CepsArray3
C++ array, 3 elements.
int32_t CepsInt
Need 32 bit integer.
CepsUInt getRank()
Returns current processor rank.
void sendRecvWithMatrix(const Eigen::Matrix< CepsUInt, Eigen::Dynamic, Eigen::Dynamic > &commMat, CepsVector< CepsVector< T >> &sendBuffers, CepsVector< CepsVector< T >> &recvBuffers)
Pair to pair communication (using matrix)
MPI_Comm getCommunicator()
Get the communicator.
CepsUInt getGridSize()
Returns the number of process on the computing grid.
int allGatherv(const CepsVector< T > &localTab, int localSize, CepsVector< T > &globalTab, CepsBool masterOnly=false)
Gather all the local orig vector in the global dest vector.