Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
f06b492ceab9a16dbd79bcac2063057f5e4c3274
[simgrid.git] / teshsuite / smpi / mpich3-test / coll / iallred.c
1 #include <stdio.h>
2 #include <assert.h>
3 #include "mpi.h"
4 #include "mpitest.h"
5
6 /* Since MPICH is currently the only NBC implementation in existence, just use
7  * this quick-and-dirty #ifdef to decide whether to test the nonblocking
8  * collectives.  Eventually we can add a configure option or configure test, or
9  * the MPI-3 standard will be released and these can be gated on a MPI_VERSION
10  * check */
11 #if !defined(USE_STRICT_MPI) && defined(MPICH)
12 #define TEST_NBC_ROUTINES 1
13 #endif
14
15 int main(int argc, char *argv[])
16 {
17     MPI_Request request;
18     int size, rank;
19     int one = 1, two = 2, isum, sum;
20     MPI_Init(&argc,&argv);
21     MPI_Comm_size(MPI_COMM_WORLD, &size);
22     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
23     assert(size == 2);
24 #if defined(TEST_NBC_ROUTINES)
25     MPI_Iallreduce(&one,&isum,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD,&request);
26     MPI_Allreduce(&two,&sum,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
27     MPI_Wait(&request,MPI_STATUS_IGNORE);
28
29     assert(isum == 2);
30     assert(sum == 4);
31     if (rank == 0)
32         printf(" No errors\n");
33 #endif
34
35     MPI_Finalize();
36     return 0;
37 }
38