Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add mpich3 test suite, to replace older one.
[simgrid.git] / teshsuite / smpi / mpich-test / coll / shortint.c
1 #include "mpi.h"
2 #include <stdio.h>
3 typedef struct { short a; int b } s1;
4
5 main( int argc, char **argv )
6 {
7 s1 s[10], sout[10];
8 int i, rank;
9 MPI_Status status;
10
11 MPI_Init( &argc, &argv );
12 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
13 for (i=0; i<10; i++) {
14     s[i].a = rank + i;
15     s[i].b = rank;
16     sout[i].a = -1;
17     sout[i].b = -1;
18     }
19 /* MPI_Allreduce( s, sout, 10, MPI_SHORT_INT, MPI_MINLOC, MPI_COMM_WORLD ); */
20 /* if (rank == 1) 
21     for (i=0; i<10; i++) 
22         sout[i] = s[i];
23  */
24 MPI_Reduce( s, sout, 10, MPI_SHORT_INT, MPI_MINLOC, 1, MPI_COMM_WORLD );
25 if (rank == 1)
26 for (i=0; i<10; i++) {
27     printf( "[%d] (%x,%x)\n", rank, (int)sout[i].a, sout[i].b );
28     }
29 if (rank == 1) 
30     MPI_Send( sout, 10, MPI_SHORT_INT, 0, 0, MPI_COMM_WORLD );
31 else if (rank == 0)
32     MPI_Recv( sout, 10, MPI_SHORT_INT, 1, 0, MPI_COMM_WORLD, &status );
33 /* MPI_Bcast( sout, 10, MPI_SHORT_INT, 1, MPI_COMM_WORLD ); */
34 for (i=0; i<10; i++) {
35     printf( "[%d] (%x,%x)\n", rank, (int)sout[i].a, sout[i].b );
36     }
37 MPI_Finalize();
38 return 0;
39 }