views:

244

answers:

2

What is the best way to scatter a Fortran 90 matrix by its rows rather than columns? That is, let's say I have a matrix a(4,50) and I want to MPI_SCATTER it onto two processes where each part is alocal(2,50), where rank 0 has rows 1 and 2, and rank 1 has 3 and 4. Now, in C, this is simple since arrays are row-major, but in Fortran 90 they are column-major.

I'm trying to avoid using TRANSPOSE to flip a before scattering (i.e, doubling the memory use), and I figure there must be a way in MPI to do this. Would it be MPI_TYPE_VECTOR? MPI_TYPE_CREATE_SUBARRAY?

Likewise, what if I have a 3d array b(4,50,3) and I want two scattered matrices of blocal(2,50,3) distributed as above?

A: 

Yes, MPI_TYPE_VECTOR and MPI_TYPE_CREATE_SUBARRAY are what you want. The former for your first problem, the latter for your second. Comment if you want me to write the calls for you !

High Performance Mark
I might like to know your technique since I can't seem to get either to work. The VECTOR one keeps sending junk and the SUBARRAY call doesn't seem to want to work with SCATTER. It scatters fine to rank 0, but not to rank 1. Do I need to broadcast my large array so everyone can see it when I do the SUBARRAY? If so, it'd be easier to BCAST and then just use array slices. Or, perhaps, I need to use SCATTERV with it?
Fortran
Sorry @Fortran, went walkabout. Did you get this sorted out ? If not, I'll try to answer tomorrow.
High Performance Mark
A: 

Didn't most of the MPI data transfer calls have a stride argument? Set it to the size of the data type times the height of the matrix and there you go...

I've taken a look to the MPI reference and there wasn't a explicit argument to that, but if you go to the example 5.12, they show how to send strided ints with MPI_Scatterv and MPI_Gatherv.

fortran