Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add fortran tests from mpich-tests, enforce completion of mpich-tests suite with...
[simgrid.git] / teshsuite / smpi / mpich-test / pt2pt / waitany.c
1 /*
2  * This code tests waitany; in one version of MPICH, it uncovered some
3  * problems with the ADI Test calls.
4  */
5 /* #define i_ntotin 256  */ /* ok    */
6 /* #define i_ntotin 257  */ /* fails */
7 #define i_ntotin 25600  
8
9 #include <stdio.h>
10 #include "mpi.h"
11
12 #if defined(NEEDS_STDLIB_PROTOTYPES)
13 #include "protofix.h"
14 #endif
15
16 #define DAR 32  /* ``Data: ARray''  */
17
18
19 int main( int argc, char **argv )
20  {
21   int locId ;
22   int data [i_ntotin] ;
23
24   MPI_Init(&argc, &argv) ;
25   MPI_Comm_rank(MPI_COMM_WORLD, &locId) ;
26
27   if(locId == 0) {
28
29     /* The server... */
30
31     MPI_Status status[2] ;
32     MPI_Request events [2] ;
33
34     int eventId ;
35
36     int dstId = 1 ;
37
38     int i ;
39
40     for(i = 0 ; i < i_ntotin ; i++)
41       data [i] = i + 1 ;
42
43     events [0] = MPI_REQUEST_NULL ;
44     events [1] = MPI_REQUEST_NULL ;
45
46     MPI_Isend(data, i_ntotin, MPI_INT, dstId, DAR,
47               MPI_COMM_WORLD, events + 1) ;
48         /* enable send of data */
49
50     /*_begin_trace_code  */
51     /* printf("locId = %d: MPI_Isend(%x, %d, %x, %d, %d, %x, %x)\n",
52       locId, data, i_ntotin, MPI_INT, dstId, DAR, MPI_COMM_WORLD, events [1]); 
53       */
54     /*_end_trace_code  */
55
56     /*_begin_trace_code  */
57     /* printf("locId = %d: MPI_Waitany(%d, [%x, %x], %x %x)...",
58       locId, 2, events [0], events [1], &eventId, &status) ; */
59     /*_end_trace_code  */
60
61     MPI_Waitany(2, events, &eventId, status) ;
62
63     /*_begin_trace_code  */
64     printf("done.  eventId = %d\n", eventId) ;
65     /*_end_trace_code  */
66   }
67
68   if(locId == 1) {
69
70     /* The Client...  */
71
72     MPI_Status status ;
73
74     int srcId = MPI_ANY_SOURCE ;
75
76     /*_begin_trace_code  */
77     /*
78     printf("locId = %d: MPI_Recv(%x, %d, %x, %d, %d, %x, %x)...",
79       locId, data, i_ntotin, MPI_INT, srcId, DAR, MPI_COMM_WORLD, &status) ;
80       */
81     /*_end_trace_code  */
82
83     MPI_Recv(data, i_ntotin, MPI_INT, srcId, DAR,
84              MPI_COMM_WORLD, &status) ;
85
86     /*_begin_trace_code  */
87     /*printf("done.\n") ;*/
88     /*_end_trace_code  */
89
90     /*
91     printf("locId = %d: data [0] = %d, data [%d] = %d\n",
92       locId, data [0], i_ntotin - 1, data [i_ntotin - 1]) ;
93        */
94   }
95
96   MPI_Barrier( MPI_COMM_WORLD );
97   if (locId == 0)
98       printf( "Test complete\n" );
99   MPI_Finalize() ;
100   return 0;
101 }
102
103
104