When the datatype contains gaps in the beginning or in the end, one might need to modify the extent of the datatype.
Starting from skeleton.c or skeleton.F90, create a vector datatype for sending a column (C) or row (Fortran) of a matrix.
-
Verify that the datatype works by communicating a single column/row.
-
Try to send multiple columns / rows. What happens? Can you explain why?
-
Create a new datatype with resized extent, so that communicating multiple columns / rows succeeds.
-
Generalize the code to multiple processes and scatter columns / rows with
MPI_Scatter
collective. Define a new array for the receive buffer and print it out on all ranks.