Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
9275ef17075ee7fb3328e2a1394e789180f30dfc
[simgrid.git] / teshsuite / smpi / mpich3-test / datatype / longdouble.c
1 /* -*- Mode: C; 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 #include <stdlib.h>
8 #include <stdio.h>
9 #include "mpi.h"
10 #include "mpitest.h"
11
12 /* Some MPI implementations should not support MPI_LONG_DOUBLE because it has
13  * different representations/sizes among several concurrently supported
14  * compilers.  For example, a 16-byte GCC implementation and an 8-byte Cray
15  * compiler implementation.
16  *
17  * This test ensures that simplistic build logic/configuration did not result in
18  * a defined, yet incorrectly sized, MPI predefined datatype for long double and
19  * long double _Complex.  See tt#1671 for more info.
20  *
21  * Based on a test suggested by Jim Hoekstra @ Iowa State University. */
22
23 int main(int argc, char *argv[])
24 {
25     int rank, size, type_size;
26     int errs = 0;
27
28     MPI_Init(&argc, &argv);
29
30     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
31     MPI_Comm_size(MPI_COMM_WORLD, &size);
32
33     if (rank == 0) {
34 #ifdef HAVE_LONG_DOUBLE
35         if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
36             MPI_Type_size(MPI_LONG_DOUBLE, &type_size);
37             if (type_size != sizeof(long double)) {
38                 printf("type_size != sizeof(long double) : (%d != %zd)\n",
39                        type_size, sizeof(long double));
40                 ++errs;
41             }
42         }
43 #endif
44 #if defined(HAVE_LONG_DOUBLE__COMPLEX) && defined(USE_LONG_DOUBLE_COMPLEX)
45         if (MPI_C_LONG_DOUBLE_COMPLEX != MPI_DATATYPE_NULL) {
46             MPI_Type_size(MPI_C_LONG_DOUBLE_COMPLEX, &type_size);
47             if (type_size != sizeof(long double _Complex)) {
48                 printf("type_size != sizeof(long double _Complex) : (%d != %zd)\n",
49                        type_size, sizeof(long double _Complex));
50                 ++errs;
51             }
52         }
53 #endif
54         if (errs) {
55             printf("found %d errors\n", errs);
56         }
57         else {
58             printf(" No errors\n");
59         }
60     }
61
62     MPI_Finalize();
63     return 0;
64 }