Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / teshsuite / smpi / mpich3-test / datatype / cxx-types.c
1 /* -*- Mode: c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2012 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6
7 /* This test checks for the existence of four new C++ named predefined datatypes
8  * that should be accessible from C (and Fortran, not tested here). */
9
10 #include <limits.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <mpi.h>
14
15 /* assert-like macro that bumps the err count and emits a message */
16 #define check(x_)                                                                 \
17     do {                                                                          \
18         if (!(x_)) {                                                              \
19             ++errs;                                                               \
20             if (errs < 10) {                                                      \
21                 fprintf(stderr, "check failed: (%s), line %d\n", #x_, __LINE__); \
22             }                                                                     \
23         }                                                                         \
24     } while (0)
25
26 int main(int argc, char *argv[])
27 {
28     int errs = 0;
29     int wrank, wsize;
30     int size;
31
32     MPI_Init(&argc, &argv);
33     MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
34     MPI_Comm_size(MPI_COMM_WORLD, &wsize);
35
36     /* perhaps the MPI library has no CXX support, in which case let's assume
37      * that these constants exist and were set to MPI_DATATYPE_NULL (standard
38      * MPICH behavior). */
39 #define check_type(type_)                 \
40     do {                                  \
41         size = -1;                        \
42         if (type_ != MPI_DATATYPE_NULL) { \
43             MPI_Type_size(type_, &size);  \
44             check(size > 0);              \
45         }                                 \
46     } while (0)
47
48     check_type(MPI_CXX_BOOL);
49     check_type(MPI_CXX_FLOAT_COMPLEX);
50     check_type(MPI_CXX_DOUBLE_COMPLEX);
51     check_type(MPI_CXX_LONG_DOUBLE_COMPLEX);
52
53     MPI_Reduce((wrank == 0 ? MPI_IN_PLACE : &errs), &errs, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
54     if (wrank == 0) {
55         if (errs) {
56             printf("found %d errors\n", errs);
57         }
58         else {
59             printf(" No errors\n");
60         }
61     }
62
63     MPI_Finalize();
64
65     return 0;
66 }