source: CIVL/examples/mpi/collective/matTrans.c

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 884 bytes
Line 
1/**
2 * online source: http://static.msi.umn.edu/tutorial/scicomp/general/MPI/workshop_MPI/src/alltoall/main.html
3 */
4#include <stdio.h>
5#include "mpi.h"
6
7int main( int argc, char **argv )
8{
9 int send[4], recv[4];
10 int rank, size, k;
11
12 MPI_Init( &argc, &argv );
13 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
14 MPI_Comm_size( MPI_COMM_WORLD, &size );
15
16 if (size != 4) {
17 printf("Error!:# of processors must be equal to 4\n");
18 printf("Programm aborting....\n");
19 MPI_Abort(MPI_COMM_WORLD, 1);
20 }
21 for (k=0;k<size;k++) send[k] = (k+1) + rank*size;
22
23 printf("%d : send = %d %d %d %d\n", rank, send[0], send[1], send[2], send[3]);
24
25 MPI_Alltoall(send, 1, MPI_INT, recv, 1, MPI_INT, MPI_COMM_WORLD);
26
27 printf("%d : recv = %d %d %d %d\n", rank, recv[0], recv[1], recv[2], recv[3]);
28
29 MPI_Finalize();
30 return 0;
31}
Note: See TracBrowser for help on using the repository browser.