Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change include order for smpi tests/examples to avoid conflicts
[simgrid.git] / teshsuite / smpi / mpich3-test / pt2pt / waittestnull.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2005 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6 #include <stdio.h>
7 #include "mpi.h"
8 #include "mpitest.h"
9
10 /* 
11  * This program checks that the various MPI_Test and MPI_Wait routines 
12  * allow both null requests and in the multiple completion cases, empty
13  * lists of requests.
14  */
15
16 int main(int argc, char **argv)
17 {
18     int errs = 0;
19     MPI_Status status, *status_array = 0;
20     int count = 0, flag, idx, rc, errlen, *indices=0, outcnt;
21     MPI_Request *reqs = 0;
22     char errmsg[MPI_MAX_ERROR_STRING];
23
24     MTest_Init(&argc, &argv);
25
26     MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
27
28     rc = MPI_Testall( count, reqs, &flag, status_array );
29     if (rc != MPI_SUCCESS) {
30         MPI_Error_string( rc, errmsg, &errlen );
31         printf( "MPI_Testall returned failure: %s\n", errmsg );
32         errs ++;
33     }
34     else if (!flag) {
35         printf( "MPI_Testall( 0, ... ) did not return a true flag\n") ;
36         errs++;
37     }
38
39     rc = MPI_Waitall( count, reqs, status_array );
40     if (rc != MPI_SUCCESS) {
41         MPI_Error_string( rc, errmsg, &errlen );
42         printf( "MPI_Waitall returned failure: %s\n", errmsg );
43         errs ++;
44     }
45
46     rc = MPI_Testany( count, reqs, &idx, &flag, &status );
47     if (rc != MPI_SUCCESS) {
48         MPI_Error_string( rc, errmsg, &errlen );
49         printf( "MPI_Testany returned failure: %s\n", errmsg );
50         errs ++;
51     }
52     else if (!flag) {
53         printf( "MPI_Testany( 0, ... ) did not return a true flag\n") ;
54         errs++;
55     }
56
57     rc = MPI_Waitany( count, reqs, &idx, &status );
58     if (rc != MPI_SUCCESS) {
59         MPI_Error_string( rc, errmsg, &errlen );
60         printf( "MPI_Waitany returned failure: %s\n", errmsg );
61         errs ++;
62     }
63
64     rc = MPI_Testsome( count, reqs, &outcnt, indices, status_array );
65     if (rc != MPI_SUCCESS) {
66         MPI_Error_string( rc, errmsg, &errlen );
67         printf( "MPI_Testsome returned failure: %s\n", errmsg );
68         errs ++;
69     }
70
71     rc = MPI_Waitsome( count, reqs, &outcnt, indices, status_array );
72     if (rc != MPI_SUCCESS) {
73         MPI_Error_string( rc, errmsg, &errlen );
74         printf( "MPI_Waitsome returned failure: %s\n", errmsg );
75         errs ++;
76     }
77     
78     MTest_Finalize( errs );
79     MPI_Finalize();
80     return 0;
81 }