Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge tag 'v3_9_90' into hypervisor
[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     int size, rank;
18 #if defined(TEST_NBC_ROUTINES)
19     MPI_Request request;
20     int one = 1, two = 2, isum, sum;
21 #endif
22     MPI_Init(&argc,&argv);
23     MPI_Comm_size(MPI_COMM_WORLD, &size);
24     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
25     assert(size == 2);
26 #if defined(TEST_NBC_ROUTINES)
27     MPI_Iallreduce(&one,&isum,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD,&request);
28     MPI_Allreduce(&two,&sum,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
29     MPI_Wait(&request,MPI_STATUS_IGNORE);
30
31     assert(isum == 2);
32     assert(sum == 4);
33     if (rank == 0)
34         printf(" No errors\n");
35 #endif
36
37     MPI_Finalize();
38     return 0;
39 }
40