Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add mpich3 topo tests
[simgrid.git] / teshsuite / smpi / mpich3-test / comm / cmsplit_type.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2011 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6 #include "mpi.h"
7 /* USE_STRICT_MPI may be defined in mpitestconf.h */
8 #include "mpitestconf.h"
9 #include <stdio.h>
10 #include <stdlib.h>
11
12 /* FIXME: This test only checks that the MPI_Comm_split_type routine
13    doesn't fail.  It does not check for correct behavior */
14
15 int main(int argc, char *argv[])
16 {
17     int rank, size, verbose=0;
18     int wrank;
19     MPI_Comm comm;
20
21     MPI_Init(&argc, &argv);
22
23     if (getenv("MPITEST_VERBOSE"))
24         verbose = 1;
25
26     MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
27
28     /* Check to see if MPI_COMM_TYPE_SHARED works correctly */
29     MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &comm);
30     if (comm == MPI_COMM_NULL)
31         printf("Expected a non-null communicator, but got MPI_COMM_NULL\n");
32     else {
33         MPI_Comm_rank(comm, &rank);
34         MPI_Comm_size(comm, &size);
35         if (rank == 0 && verbose)
36             printf("Created subcommunicator of size %d\n", size);
37         MPI_Comm_free(&comm);
38     }
39
40     /* Check to see if MPI_UNDEFINED is respected */
41     MPI_Comm_split_type(MPI_COMM_WORLD, (wrank % 2 == 0) ? MPI_COMM_TYPE_SHARED : MPI_UNDEFINED,
42                         0, MPI_INFO_NULL, &comm);
43     if ((wrank % 2) && (comm != MPI_COMM_NULL))
44         printf("Expected MPI_COMM_NULL, but did not get one\n");
45     if (wrank % 2 == 0) {
46         if (comm == MPI_COMM_NULL)
47             printf("Expected a non-null communicator, but got MPI_COMM_NULL\n");
48         else {
49             MPI_Comm_rank(comm, &rank);
50             MPI_Comm_size(comm, &size);
51             if (rank == 0 && verbose)
52                 printf("Created subcommunicator of size %d\n", size);
53             MPI_Comm_free(&comm);
54         }
55     }
56
57     /* Use wrank because Comm_split_type may return more than one communicator
58        across the job, and if so, each will have a rank 0 entry.  Test 
59        output rules are for a single process to write the successful 
60        test (No Errors) output. */
61     if (wrank == 0)
62         printf(" No errors\n");
63
64     MPI_Finalize();
65
66     return 0;
67 }