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_LOR operations on optional datatypes dupported by MPICH";
17 * This test looks at the handling of logical and for types that are not
18 * integers or are not required 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];
29 float finbuf[3], foutbuf[3];
30 double dinbuf[3], doutbuf[3];
32 MTest_Init(&argc, &argv);
34 comm = MPI_COMM_WORLD;
36 MPI_Comm_rank(comm, &rank);
37 MPI_Comm_size(comm, &size);
39 /* Some MPI implementations do not implement all of the required
40 * (datatype,operations) combinations, and further, they do not
41 * always provide clear and specific error messages. By catching
42 * the error, we can provide a higher quality, more specific message.
44 MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
46 #ifndef USE_STRICT_MPI
48 MTestPrintfMsg(10, "Reduce of MPI_CHAR\n");
51 cinbuf[2] = (rank > 0);
56 err = MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_LOR, 0, comm);
59 MTestPrintErrorMsg("MPI_LOR and MPI_CHAR", err);
65 fprintf(stderr, "char OR(1) test failed\n");
69 fprintf(stderr, "char OR(0) test failed\n");
71 if (!coutbuf[2] && size > 1) {
73 fprintf(stderr, "char OR(>) test failed\n");
77 #endif /* USE_STRICT_MPI */
80 MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n");
83 scinbuf[2] = (rank > 0);
88 err = MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_LOR, 0, comm);
91 MTestPrintErrorMsg("MPI_LOR and MPI_SIGNED_CHAR", err);
97 fprintf(stderr, "signed char OR(1) test failed\n");
101 fprintf(stderr, "signed char OR(0) test failed\n");
103 if (!scoutbuf[2] && size > 1) {
105 fprintf(stderr, "signed char OR(>) test failed\n");
111 MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n");
114 ucinbuf[2] = (rank > 0);
119 err = MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_LOR, 0, comm);
122 MTestPrintErrorMsg("MPI_LOR and MPI_UNSIGNED_CHAR", err);
128 fprintf(stderr, "unsigned char OR(1) test failed\n");
132 fprintf(stderr, "unsigned char OR(0) test failed\n");
134 if (!ucoutbuf[2] && size > 1) {
136 fprintf(stderr, "unsigned char OR(>) test failed\n");
141 #ifndef USE_STRICT_MPI
143 MTestPrintfMsg(10, "Reduce of MPI_FLOAT\n");
146 finbuf[2] = (rank > 0);
151 err = MPI_Reduce(finbuf, foutbuf, 3, MPI_FLOAT, MPI_LOR, 0, comm);
154 MTestPrintErrorMsg("MPI_LOR and MPI_FLOAT", err);
160 fprintf(stderr, "float OR(1) test failed\n");
164 fprintf(stderr, "float OR(0) test failed\n");
166 if (!foutbuf[2] && size > 1) {
168 fprintf(stderr, "float OR(>) test failed\n");
174 MTestPrintfMsg(10, "Reduce of MPI_DOUBLE\n");
177 dinbuf[2] = (rank > 0);
182 err = MPI_Reduce(dinbuf, doutbuf, 3, MPI_DOUBLE, MPI_LOR, 0, comm);
185 MTestPrintErrorMsg("MPI_LOR and MPI_DOUBLE", err);
191 fprintf(stderr, "double OR(1) test failed\n");
195 fprintf(stderr, "double OR(0) test failed\n");
197 if (!doutbuf[2] && size > 1) {
199 fprintf(stderr, "double OR(>) test failed\n");
204 #ifdef HAVE_LONG_DOUBLE
206 long double ldinbuf[3], ldoutbuf[3];
208 MTEST_VG_MEM_INIT(ldinbuf, 3* sizeof(ldinbuf[0]));
211 ldinbuf[2] = (rank > 0);
216 if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
217 MTestPrintfMsg(10, "Reduce of MPI_LONG_DOUBLE\n");
218 err = MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_LOR, 0, comm);
221 MTestPrintErrorMsg("MPI_LOR and MPI_LONG_DOUBLE", err);
227 fprintf(stderr, "long double OR(1) test failed\n");
231 fprintf(stderr, "long double OR(0) test failed\n");
233 if (!ldoutbuf[2] && size > 1) {
235 fprintf(stderr, "long double OR(>) test failed\n");
241 #endif /* HAVE_LONG_DOUBLE */
242 #endif /* USE_STRICT_MPI */
244 #ifdef HAVE_LONG_LONG
246 long long llinbuf[3], lloutbuf[3];
250 llinbuf[2] = (rank > 0);
255 if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
256 MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n");
257 err = MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_LOR, 0, comm);
260 MTestPrintErrorMsg("MPI_LOR and MPI_LONG_LONG", err);
266 fprintf(stderr, "long long OR(1) test failed\n");
270 fprintf(stderr, "long long OR(0) test failed\n");
272 if (!lloutbuf[2] && size > 1) {
274 fprintf(stderr, "long long OR(>) test failed\n");
282 MPI_Errhandler_set(comm, MPI_ERRORS_ARE_FATAL);
283 MTest_Finalize(errs);