user2389323
user2389323

Reputation: 779

Using MPI Scatter for 2d array

I am trying to use MPI_Scatter to transmit a set of rows of matrix[5000][2000] across 16 processes (Trying to achieve a matrix multiplication). but 5000 is not divisible by 16. So if every process receives equal amount of rows, last few rows will be lost. ( 312 * 16 + 8 = 5000 )

Can anyone tell me how to scatter this [5000] rows properly among the processes using MPI_Scatter?

Thank you

Upvotes: 1

Views: 769

Answers (1)

user2389323
user2389323

Reputation: 779

I found the answer I was looking for. MPI provides functions for this purpose. a version of gather and scatter.

MPI_Scatterv http://www.mpich.org/static/docs/v3.1/www3/MPI_Scatterv.html

MPI_Gatherv http://www.mpich.org/static/docs/v3.1/www3/MPI_Gatherv.html

Upvotes: 1

Related Questions