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 / isendself.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 "mpi.h"
8 #include "mpitest.h"
9
10 int main( int argc, char *argv[] )
11 {
12     int a[10], b[10], i;
13     MPI_Status status;
14     MPI_Request request;
15     int rank, count;
16     int errs = 0;
17     
18
19     MTest_Init( &argc, &argv );
20
21     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
22     
23     for (i=0; i<10; i++) a[i] = i+1;
24
25     status.MPI_ERROR = 0;
26     MPI_Isend( a, 0, MPI_INT, rank, 0, MPI_COMM_WORLD, &request );
27     MPI_Recv( b, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD,
28               &status );
29     MPI_Get_count( &status, MPI_INT, &count );
30     if (status.MPI_SOURCE != rank ||
31         status.MPI_TAG != 0 ||
32         status.MPI_ERROR != 0 ||
33         count != 0) {
34         errs++;
35         printf ("1 status = %d %d %d %d\n", status.MPI_SOURCE, status.MPI_TAG,
36                 status.MPI_ERROR, count );
37     }
38     /* printf( "b[0] = %d\n", b[0] );*/
39     MPI_Wait( &request, &status );
40
41     MPI_Isend( 0, 0, MPI_INT, rank, 0, MPI_COMM_WORLD, &request );
42     MPI_Recv( 0, 0, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD,
43               &status );
44     MPI_Get_count( &status, MPI_INT, &count );
45     if (status.MPI_SOURCE != rank ||
46         status.MPI_TAG != 0 ||
47         status.MPI_ERROR != 0 ||
48         count != 0) {
49         errs++;
50         printf ("2 status = %d %d %d %d\n", status.MPI_SOURCE, status.MPI_TAG,
51                 status.MPI_ERROR, count );
52     }
53     MPI_Wait( &request, &status );
54
55     MTest_Finalize( errs );
56     MPI_Finalize();
57     return 0;
58 }