/** * This program illustrates MPI_Alltoallv. * online source: http://mpi.deino.net/mpi_functions/MPI_Alltoallv.html */ #include "mpi.h" #include #include /* This program tests MPI_Alltoallv by having processor i send different amounts of data to each processor. The first test sends i items to processor i from all processors. */ int main( int argc, char **argv ) { MPI_Comm comm; int *sbuf, *rbuf; int rank, size; int *sendcounts, *recvcounts, *rdispls, *sdispls; int i, j, *p; MPI_Init( &argc, &argv ); comm = MPI_COMM_WORLD; /* Create the buffer */ MPI_Comm_size(comm, &size ); MPI_Comm_rank(comm, &rank ); sbuf = (int *)malloc( size * size * sizeof(int) ); rbuf = (int *)malloc( size * size * sizeof(int) ); if (!sbuf || !rbuf) { printf("Could not allocated buffers!\n"); MPI_Abort( comm, 1 ); } /* Load up the buffers */ for (i=0; i