I am trying to multiply two matrices in MPI but my both matrices are in vector form.
vector <vector <int> > Mat1;
Which in MxN order
vector <vector <int> > Mat2;
Which is NxL order
and the results is also in vector form
vector <vector <int> > Mat3;
which is MxL order.
I am using MPI_BCAST to broadcast the values as
MPI_Bcast(Mat2.data(), Mat2.size(), MPI_INT, 0, MPI_COMM_WORLD);
and using scatter and gather function to receive the data as
MPI_Scatterv(Mat1.data(), CNTS, SNTS, MPI_INT, MatPartS.data(), MatPartS.size(), MPI_INT, 0, MPI_COMM_WORLD);
for (int i = 0; i < myRowsSize; ++i)
{
for (int j = 0; j < L; ++j)
{
ResultMatPart[i][j]=0;
for (int k = 0; k < N; ++k)
{
ResultMatPart[i][j] += MatPartS[i][k] * Mat2[k][j];
}
}
}
MPI_Gatherv(ResultMatPart.data(), ResultMatPart.size(), MPI_INT, ResultMat.data(), RCNTS, SCNTS, MPI_INT, 0, MPI_COMM_WORLD);
Blockquote
I can compile the program but it crashes and doesn't produce any output.
The message it prints is :
Fatal error in PMPI_Scatterv: Message truncated, error stack:
PMPI_Scatterv(376).....: MPI_Scatterv(sbuf=0x108fe00, scnts=0x108fef0, displs=0x108ffc0, MPI_INT, rbuf=0x1090270, rcount=4, MPI_INT, root=0, MPI_COMM_WORLD) failed
MPIR_Scatterv_impl(187):
MPIR_Scatterv(106).....:
MPIR_Localcopy(340)....: Message truncated; 64 bytes received but buffer size is 16
Any help how to pass a multidimensional STL vector in MPI?
Thank you very much
S