Dimensioning in MPI Scattering

93 views Asked by At

So I am working on a simple matrix multiplication code using MPI. One of the problems I am facing is in scattering one of the matrices to all the processors. I am assuming that the dimension of my matrix might not be divisible by the number of processors.

Also I have used a variable col_id which calculates the number of columns alloted to each processor by using the mod function. For example if we have 9 columns and 6 processors, the first 3 processors will have a col_id value of 2 while other three processors will have a col_id value of 1.

So I used a basic scattering operation.

call MPI_Scatter(b, dim2*col_id, MPI_Integer, b1, dim2*col_id, MPI_Integer, 0, MPI_COMM_WORLD, ierr)

col_id will be different for different processors. Are we allowed to use this variable to specify dimensions in MPI_scatter?

1

There are 1 answers

0
Zulan On

The function MPI_Scatterv is made for exactly that purpose. Instead of a sendcount you specify sendcounts - an integer array of the size of the communicator.