Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix signedness errors in format strings.
[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 != %zu)\n", type_size, sizeof(long double));
39                 ++errs;
40             }
41         }
42 #endif
43 #if defined(HAVE_LONG_DOUBLE__COMPLEX) && defined(USE_LONG_DOUBLE_COMPLEX)
44         if (MPI_C_LONG_DOUBLE_COMPLEX != MPI_DATATYPE_NULL) {
45             MPI_Type_size(MPI_C_LONG_DOUBLE_COMPLEX, &type_size);
46             if (type_size != sizeof(long double _Complex)) {
47                 printf("type_size != sizeof(long double _Complex) : (%d != %zu)\n", type_size,
48                        sizeof(long double _Complex));
49                 ++errs;
50             }
51         }
52 #endif
53         if (errs) {
54             printf("found %d errors\n", errs);
55         }
56         else {
57             printf(" No errors\n");
58         }
59     }
60
61     MPI_Finalize();
62     return 0;
63 }