46 #ifndef _PEXSI_MPI_HPP_
47 #define _PEXSI_MPI_HPP_
64 std::vector<Int>& localVec,
65 std::vector<Int>& allVec,
75 std::vector<T>& localVec,
76 std::vector<T>& allVec,
80 PushCallStack(
"mpi::Allgatherv");
83 MPI_Comm_rank( comm, &mpirank );
84 MPI_Comm_size( comm, &mpisize );
86 Int localSize = localVec.size()*
sizeof(T);
87 std::vector<Int> localSizeVec( mpisize );
88 std::vector<Int> localSizeDispls( mpisize );
89 MPI_Allgather( &localSize, 1, MPI_INT, &localSizeVec[0], 1, MPI_INT, comm );
90 localSizeDispls[0] = 0;
91 for( Int ip = 1; ip < mpisize; ip++ ){
92 localSizeDispls[ip] = (localSizeDispls[ip-1] + localSizeVec[ip-1])*
sizeof(T);
94 Int totalSize = (localSizeDispls[mpisize-1] + localSizeVec[mpisize-1])*
sizeof(T);
97 allVec.resize( totalSize/
sizeof(T) );
99 MPI_Allgatherv( &localVec[0], localSize, MPI_BYTE, &allVec[0],
100 &localSizeVec[0], &localSizeDispls[0], MPI_BYTE, comm );
129 void Send( std::stringstream& sstm, Int dest, Int tagSize, Int tagContent,
132 void Recv ( std::stringstream& sstm, Int src, Int tagSize, Int tagContent,
133 MPI_Comm comm, MPI_Status& statSize, MPI_Status& statContent );
135 void Recv ( std::stringstream& sstm, Int src, Int tagSize, Int tagContent,
143 Wait ( MPI_Request& req );
146 Waitall ( std::vector<MPI_Request>& reqs, std::vector<MPI_Status>& stats );
149 Waitall ( std::vector<MPI_Request>& reqs );
156 Reduce ( Real* sendbuf, Real* recvbuf, Int count, MPI_Op op, Int root, MPI_Comm comm );
159 Reduce ( Complex* sendbuf, Complex* recvbuf, Int count, MPI_Op op, Int root, MPI_Comm comm );
164 Ireduce ( Real* sendbuf, Real* recvbuf, Int count, MPI_Op op, Int root, MPI_Comm comm, MPI_Request & request );
167 Ireduce ( Complex* sendbuf, Complex* recvbuf, Int count, MPI_Op op, Int root, MPI_Comm comm, MPI_Request & request );
171 Allreduce ( Int* sendbuf, Int* recvbuf, Int count, MPI_Op op, MPI_Comm comm );
174 Allreduce ( Real* sendbuf, Real* recvbuf, Int count, MPI_Op op, MPI_Comm comm );
177 Allreduce ( Complex* sendbuf, Complex* recvbuf, Int count, MPI_Op op, MPI_Comm comm );
184 Alltoallv ( Int *bufSend, Int *sizeSend, Int *displsSend,
185 Int *bufRecv, Int *sizeRecv,
186 Int *displsRecv, MPI_Comm comm );
189 Alltoallv ( Real *bufSend, Int *sizeSend, Int *displsSend,
190 Real *bufRecv, Int *sizeRecv,
191 Int *displsRecv, MPI_Comm comm );
194 Alltoallv ( Complex *bufSend, Int *sizeSend, Int *displsSend,
195 Complex *bufRecv, Int *sizeRecv,
196 Int *displsRecv, MPI_Comm comm );
205 #endif // _PEXSI_MPI_HPP_