Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add mpich3 test suite, to replace older one.
[simgrid.git] / teshsuite / smpi / mpich3-test / comm / ic1.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
7 /*
8  * A simple test of the intercomm create routine, with a communication test
9  */
10 #include "mpi.h"
11 #include <stdio.h>
12 #include "mpitest.h"
13
14 int main( int argc, char *argv[] )
15 {
16     MPI_Comm intercomm;
17     int      remote_rank, rank, size, errs = 0;
18
19     MTest_Init( &argc, &argv );
20
21
22
23     MPI_Comm_size( MPI_COMM_WORLD, &size );
24     if (size < 2) {
25         printf( "Size must be at least 2\n" );
26         MPI_Abort( MPI_COMM_WORLD, 0 );
27     }
28
29     MPI_Comm_rank( MPI_COMM_WORLD, &rank );
30
31     /* Make an intercomm of the first two elements of comm_world */
32     if (rank < 2) {
33         int lrank = rank, rrank = -1;
34         MPI_Status status;
35
36         remote_rank = 1 - rank;
37         MPI_Intercomm_create( MPI_COMM_SELF, 0,
38                               MPI_COMM_WORLD, remote_rank, 27, 
39                               &intercomm );
40
41         /* Now, communicate between them */
42         MPI_Sendrecv( &lrank, 1, MPI_INT, 0, 13, 
43                       &rrank, 1, MPI_INT, 0, 13, intercomm, &status );
44
45         if (rrank != remote_rank) {
46             errs++;
47             printf( "%d Expected %d but received %d\n", 
48                     rank, remote_rank, rrank );
49         }
50
51         MPI_Comm_free( &intercomm );
52     }
53     
54     /* The next test should create an intercomm with groups of different
55        sizes FIXME */
56
57     MTest_Finalize( errs );
58     MPI_Finalize();
59     
60     return 0;
61 }