Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
reduce some tests duration as comm_create takes longer now (comms)
[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     volatile int trigger;
19
20     MTest_Init(&argc, &argv);
21
22     trigger = 1;
23 /*    while (trigger) ; */
24
25     MPI_Comm_size(MPI_COMM_WORLD, &size);
26     if (size < 2) {
27         printf("Size must be at least 2\n");
28         MPI_Abort(MPI_COMM_WORLD, 0);
29     }
30
31     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
32
33     /* Make an intercomm of the first two elements of comm_world */
34     if (rank < 2) {
35         int lrank = rank, rrank = -1;
36         MPI_Status status;
37
38         remote_rank = 1 - rank;
39         MPI_Intercomm_create(MPI_COMM_SELF, 0, MPI_COMM_WORLD, remote_rank, 27, &intercomm);
40
41         /* Now, communicate between them */
42         MPI_Sendrecv(&lrank, 1, MPI_INT, 0, 13, &rrank, 1, MPI_INT, 0, 13, intercomm, &status);
43
44         if (rrank != remote_rank) {
45             errs++;
46             printf("%d Expected %d but received %d\n", rank, remote_rank, rrank);
47         }
48
49         MPI_Comm_free(&intercomm);
50     }
51
52     /* The next test should create an intercomm with groups of different
53      * sizes FIXME */
54
55     MTest_Finalize(errs);
56     MPI_Finalize();
57
58     return 0;
59 }