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_LAND 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[])
27 char cinbuf[3], coutbuf[3];
28 signed char scinbuf[3], scoutbuf[3];
29 unsigned char ucinbuf[3], ucoutbuf[3];
30 float finbuf[3], foutbuf[3];
31 double dinbuf[3], doutbuf[3];
33 MTest_Init(&argc, &argv);
35 comm = MPI_COMM_WORLD;
36 /* Set errors return so that we can provide better information
37 * should a routine reject one of the operand/datatype pairs */
38 MPI_Errhandler_set(comm, MPI_ERRORS_RETURN);
40 MPI_Comm_rank(comm, &rank);
41 MPI_Comm_size(comm, &size);
43 #ifndef USE_STRICT_MPI
45 MTestPrintfMsg(10, "Reduce of MPI_CHAR\n");
48 cinbuf[2] = (rank > 0);
53 rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_LAND, 0, comm);
55 MTestPrintErrorMsg("MPI_LAND and MPI_CHAR", rc);
62 fprintf(stderr, "char AND(1) test failed\n");
66 fprintf(stderr, "char AND(0) test failed\n");
68 if (coutbuf[2] && size > 1) {
70 fprintf(stderr, "char AND(>) test failed\n");
74 #endif /* USE_STRICT_MPI */
77 MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n");
80 scinbuf[2] = (rank > 0);
85 rc = MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_LAND, 0, comm);
87 MTestPrintErrorMsg("MPI_LAND and MPI_SIGNED_CHAR", rc);
94 fprintf(stderr, "signed char AND(1) test failed\n");
98 fprintf(stderr, "signed char AND(0) test failed\n");
100 if (scoutbuf[2] && size > 1) {
102 fprintf(stderr, "signed char AND(>) test failed\n");
108 MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n");
111 ucinbuf[2] = (rank > 0);
116 rc = MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_LAND, 0, comm);
118 MTestPrintErrorMsg("MPI_LAND and MPI_UNSIGNED_CHAR", rc);
125 fprintf(stderr, "unsigned char AND(1) test failed\n");
129 fprintf(stderr, "unsigned char AND(0) test failed\n");
131 if (ucoutbuf[2] && size > 1) {
133 fprintf(stderr, "unsigned char AND(>) test failed\n");
138 #ifndef USE_STRICT_MPI
140 MTestPrintfMsg(10, "Reduce of MPI_FLOAT\n");
143 finbuf[2] = (rank > 0);
148 rc = MPI_Reduce(finbuf, foutbuf, 3, MPI_FLOAT, MPI_LAND, 0, comm);
150 MTestPrintErrorMsg("MPI_LAND and MPI_FLOAT", rc);
157 fprintf(stderr, "float AND(1) test failed\n");
161 fprintf(stderr, "float AND(0) test failed\n");
163 if (foutbuf[2] && size > 1) {
165 fprintf(stderr, "float AND(>) test failed\n");
170 MTestPrintfMsg(10, "Reduce of MPI_DOUBLE\n");
174 dinbuf[2] = (rank > 0);
179 rc = MPI_Reduce(dinbuf, doutbuf, 3, MPI_DOUBLE, MPI_LAND, 0, comm);
181 MTestPrintErrorMsg("MPI_LAND and MPI_DOUBLE", rc);
188 fprintf(stderr, "double AND(1) test failed\n");
192 fprintf(stderr, "double AND(0) test failed\n");
194 if (doutbuf[2] && size > 1) {
196 fprintf(stderr, "double AND(>) test failed\n");
201 #ifdef HAVE_LONG_DOUBLE
203 long double ldinbuf[3], ldoutbuf[3];
205 MTEST_VG_MEM_INIT(ldinbuf, 3* sizeof(ldinbuf[0]));
208 ldinbuf[2] = (rank > 0);
213 if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
214 MTestPrintfMsg(10, "Reduce of MPI_LONG_DOUBLE\n");
215 rc = MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_LAND, 0, comm);
217 MTestPrintErrorMsg("MPI_LAND and MPI_LONG_DOUBLE", rc);
224 fprintf(stderr, "long double AND(1) test failed\n");
228 fprintf(stderr, "long double AND(0) test failed\n");
230 if (ldoutbuf[2] && size > 1) {
232 fprintf(stderr, "long double AND(>) test failed\n");
238 #endif /* HAVE_LONG_DOUBLE */
239 #endif /* USE_STRICT_MPI */
242 #ifdef HAVE_LONG_LONG
244 long long llinbuf[3], lloutbuf[3];
248 llinbuf[2] = (rank > 0);
253 if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
254 MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n");
255 rc = MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_LAND, 0, comm);
257 MTestPrintErrorMsg("MPI_LAND and MPI_LONG_LONG", rc);
264 fprintf(stderr, "long long AND(1) test failed\n");
268 fprintf(stderr, "long long AND(0) test failed\n");
270 if (lloutbuf[2] && size > 1) {
272 fprintf(stderr, "long long AND(>) test failed\n");
280 MPI_Errhandler_set(comm, MPI_ERRORS_ARE_FATAL);
281 MTest_Finalize(errs);