/* This program demonstrate the use of MPI_Type_indexed. Sending the lower triangular portion of a matrix to all processes. */ /**** Note that even though the blocks are uniformly spaced in memory we couldn't use MPI_Type_vector because the block lengths are different for each row. *****/ /* Compile : mpicc -o type_vector type_indexed.c */ /* Run : mpirun -np 2 type_indexed */ #include "mpi.h" #include #define SIZE 4 int main(int argc,char *argv[]) { int pid, np, tag=1, i,j; double a[SIZE][SIZE] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0}; double b[SIZE][SIZE]; int blocklength[SIZE]; int displacement[SIZE]; MPI_Status stat; MPI_Datatype index_t; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD, &pid); MPI_Comm_size(MPI_COMM_WORLD, &np); for (i=0;i