1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2003 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
8 #include "mpitestconf.h"
13 static char MTEST_Descrip[] = "Test MPI_MAX operations on optional datatypes dupported by MPICH";
17 * This test looks at the handling of char and types that are not required
18 * integers (e.g., long long). MPICH allows
19 * these as well. A strict MPI test should not include this test.
21 int main(int argc, char *argv[])
26 char cinbuf[3], coutbuf[3];
27 signed char scinbuf[3], scoutbuf[3];
28 unsigned char ucinbuf[3], ucoutbuf[3];
30 MTest_Init(&argc, &argv);
32 comm = MPI_COMM_WORLD;
34 MPI_Comm_rank(comm, &rank);
35 MPI_Comm_size(comm, &size);
37 #ifndef USE_STRICT_MPI
39 MTestPrintfMsg(10, "Reduce of MPI_CHAR\n");
47 MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_MAX, 0, comm);
49 if (coutbuf[0] != 1) {
51 fprintf(stderr, "char MAX(1) test failed\n");
53 if (coutbuf[1] != 0) {
55 fprintf(stderr, "char MAX(0) test failed\n");
57 if (size < 128 && coutbuf[2] != size - 1) {
59 fprintf(stderr, "char MAX(>) test failed\n");
62 #endif /* USE_STRICT_MPI */
65 MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n");
73 MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_MAX, 0, comm);
75 if (scoutbuf[0] != 1) {
77 fprintf(stderr, "signed char MAX(1) test failed\n");
79 if (scoutbuf[1] != 0) {
81 fprintf(stderr, "signed char MAX(0) test failed\n");
83 if (size < 128 && scoutbuf[2] != size - 1) {
85 fprintf(stderr, "signed char MAX(>) test failed\n");
90 MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n");
98 MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_MAX, 0, comm);
100 if (ucoutbuf[0] != 1) {
102 fprintf(stderr, "unsigned char MAX(1) test failed\n");
106 fprintf(stderr, "unsigned char MAX(0) test failed\n");
108 if (size < 256 && ucoutbuf[2] != size - 1) {
110 fprintf(stderr, "unsigned char MAX(>) test failed\n");
114 #ifdef HAVE_LONG_DOUBLE
116 long double ldinbuf[3], ldoutbuf[3];
118 MTEST_VG_MEM_INIT(ldinbuf, 3* sizeof(ldinbuf[0]));
126 if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
127 MTestPrintfMsg(10, "Reduce of MPI_LONG_DOUBLE\n");
128 MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_MAX, 0, comm);
130 if (ldoutbuf[0] != 1) {
132 fprintf(stderr, "long double MAX(1) test failed\n");
134 if (ldoutbuf[1] != 0.0) {
136 fprintf(stderr, "long double MAX(0) test failed\n");
138 if (ldoutbuf[2] != size - 1) {
140 fprintf(stderr, "long double MAX(>) test failed\n");
145 #endif /* HAVE_LONG_DOUBLE */
147 #ifdef HAVE_LONG_LONG
149 long long llinbuf[3], lloutbuf[3];
158 if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
159 MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n");
160 MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_MAX, 0, comm);
162 if (lloutbuf[0] != 1) {
164 fprintf(stderr, "long long MAX(1) test failed\n");
166 if (lloutbuf[1] != 0) {
168 fprintf(stderr, "long long MAX(0) test failed\n");
170 if (lloutbuf[2] != size - 1) {
172 fprintf(stderr, "long long MAX(>) test failed\n");
177 #endif /* HAVE_LONG_LONG */
179 MTest_Finalize(errs);