MPI_SCATTER Fortran Matrices by Rows

What is the best way to split a Fortran 90 matrix into its rows rather than columns? That is, suppose I have a (4.50) matrix, and I want MPI_SCATTER to have 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, it's simple because arrays are string, but in Fortran 90 they are columns.

I am trying to avoid using TRANSPOSE to switch before scattering (i.e. doubling memory usage), and I suppose there should be a way in MPI to do this. Will it be MPI_TYPE_VECTOR? MPI_TYPE_CREATE_SUBARRAY?

Similarly, what if I have a 3d array b (4,50,3) and I need two scattered block arrays (2,50,3) distributed as above?

+4
source share
2 answers

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

+1
source

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

I looked at the MPI link, and there was no explicit argument for this, but if you go to Example 5.12, they show how to send strided int with MPI_Scatterv and MPI_Gatherv .

0
source

Source: https://habr.com/ru/post/1304811/


All Articles