Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
same thing, forgot some
[simgrid.git] / teshsuite / smpi / mpich3-test / pt2pt / waitany-null.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2001 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include "mpitestconf.h"
9 #ifdef HAVE_STRING_H
10 #include <string.h>
11 #endif
12 #include "mpi.h"
13
14 static int verbose = 0;
15
16 int parse_args(int argc, char **argv);
17
18 int main(int argc, char *argv[])
19 {
20     int i, err, errs = 0, rank, toterrs;
21
22     int         index;
23     MPI_Request requests[10];
24     MPI_Status  statuses[10];
25
26     MPI_Init(&argc, &argv);
27     parse_args(argc, argv);
28
29     for (i=0; i < 10; i++) {
30         requests[i] = MPI_REQUEST_NULL;
31     }
32
33     /* begin testing */
34     /* To improve reporting of problems about operations, we
35        change the error handler to errors return */
36     MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
37
38     err = MPI_Waitany(10, requests, &index, statuses);
39
40     if (err != MPI_SUCCESS) {
41         errs++;
42         fprintf(stderr, "MPI_Waitany did not return MPI_SUCCESS\n");
43     }
44
45     if (index != MPI_UNDEFINED) {
46         errs++;
47         fprintf(stderr, "MPI_Waitany did not set index to MPI_UNDEFINED\n");
48     }
49
50     /* end testing */
51     
52     MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL );
53     MPI_Comm_rank( MPI_COMM_WORLD, & rank );
54     MPI_Allreduce( &errs, &toterrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
55     if (rank == 0) {
56         if (toterrs) {
57             fprintf(stderr, " Found %d errors\n", toterrs);
58         }
59         else {
60             printf(" No Errors\n");
61         }
62     }
63     MPI_Finalize();
64     return 0;
65 }
66
67 int parse_args(int argc, char **argv)
68 {
69     /*
70     int ret;
71
72     while ((ret = getopt(argc, argv, "v")) >= 0)
73     {
74         switch (ret) {
75             case 'v':
76                 verbose = 1;
77                 break;
78         }
79     }
80     */
81     if (argc > 1 && strcmp(argv[1], "-v") == 0)
82         verbose = 1;
83     return 0;
84 }