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_BOR 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 short sinbuf[3], soutbuf[3];
31 unsigned short usinbuf[3], usoutbuf[3];
32 long linbuf[3], loutbuf[3];
33 unsigned long ulinbuf[3], uloutbuf[3];
34 unsigned uinbuf[3], uoutbuf[3];
35 int iinbuf[3], ioutbuf[3];
38 MTest_Init(&argc, &argv);
40 comm = MPI_COMM_WORLD;
41 /* Set errors return so that we can provide better information
42 * should a routine reject one of the operand/datatype pairs */
43 MPI_Errhandler_set(comm, MPI_ERRORS_RETURN);
45 MPI_Comm_rank(comm, &rank);
46 MPI_Comm_size(comm, &size);
48 #ifndef USE_STRICT_MPI
50 MTestPrintfMsg(10, "Reduce of MPI_CHAR\n");
53 cinbuf[2] = (rank > 0) ? 0x3c : 0xc3;
58 rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_BOR, 0, comm);
60 MTestPrintErrorMsg("MPI_BOR and MPI_CHAR", rc);
65 if (coutbuf[0] != (char) 0xff) {
67 fprintf(stderr, "char BOR(1) test failed\n");
71 fprintf(stderr, "char BOR(0) test failed\n");
73 if (coutbuf[2] != (char) 0xff && size > 1) {
75 fprintf(stderr, "char BOR(>) test failed\n");
79 #endif /* USE_STRICT_MPI */
82 MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n");
85 scinbuf[2] = (rank > 0) ? 0x3c : 0xc3;
90 rc = MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_BOR, 0, comm);
92 MTestPrintErrorMsg("MPI_BOR and MPI_SIGNED_CHAR", rc);
97 if (scoutbuf[0] != (signed char) 0xff) {
99 fprintf(stderr, "signed char BOR(1) test failed\n");
103 fprintf(stderr, "signed char BOR(0) test failed\n");
105 if (scoutbuf[2] != (signed char) 0xff && size > 1) {
107 fprintf(stderr, "signed char BOR(>) test failed\n");
113 MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n");
116 ucinbuf[2] = (rank > 0) ? 0x3c : 0xc3;
121 rc = MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_BOR, 0, comm);
123 MTestPrintErrorMsg("MPI_BOR and MPI_UNSIGNED_CHAR", rc);
128 if (ucoutbuf[0] != 0xff) {
130 fprintf(stderr, "unsigned char BOR(1) test failed\n");
134 fprintf(stderr, "unsigned char BOR(0) test failed\n");
136 if (ucoutbuf[2] != 0xff && size > 1) {
138 fprintf(stderr, "unsigned char BOR(>) test failed\n");
144 MTestPrintfMsg(10, "Reduce of MPI_BYTE\n");
147 cinbuf[2] = (rank > 0) ? 0x3c : 0xc3;
152 rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_BYTE, MPI_BOR, 0, comm);
154 MTestPrintErrorMsg("MPI_BOR and MPI_BYTE", rc);
159 if (coutbuf[0] != (char) 0xff) {
161 fprintf(stderr, "byte BOR(1) test failed\n");
165 fprintf(stderr, "byte BOR(0) test failed\n");
167 if (coutbuf[2] != (char) 0xff && size > 1) {
169 fprintf(stderr, "byte BOR(>) test failed\n");
175 MTestPrintfMsg(10, "Reduce of MPI_SHORT\n");
178 sinbuf[2] = (rank > 0) ? 0x3c3c : 0xc3c3;
183 rc = MPI_Reduce(sinbuf, soutbuf, 3, MPI_SHORT, MPI_BOR, 0, comm);
185 MTestPrintErrorMsg("MPI_BOR and MPI_SHORT", rc);
190 if (soutbuf[0] != (short) 0xffff) {
192 fprintf(stderr, "short BOR(1) test failed\n");
196 fprintf(stderr, "short BOR(0) test failed\n");
198 if (soutbuf[2] != (short) 0xffff && size > 1) {
200 fprintf(stderr, "short BOR(>) test failed\n");
206 MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_SHORT\n");
209 usinbuf[2] = (rank > 0) ? 0x3c3c : 0xc3c3;
214 rc = MPI_Reduce(usinbuf, usoutbuf, 3, MPI_UNSIGNED_SHORT, MPI_BOR, 0, comm);
216 MTestPrintErrorMsg("MPI_BOR and MPI_UNSIGNED_SHORT", rc);
221 if (usoutbuf[0] != 0xffff) {
223 fprintf(stderr, "short BOR(1) test failed\n");
227 fprintf(stderr, "short BOR(0) test failed\n");
229 if (usoutbuf[2] != 0xffff && size > 1) {
231 fprintf(stderr, "short BOR(>) test failed\n");
237 MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED\n");
238 uinbuf[0] = 0xffffffff;
240 uinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
245 rc = MPI_Reduce(uinbuf, uoutbuf, 3, MPI_UNSIGNED, MPI_BOR, 0, comm);
247 MTestPrintErrorMsg("MPI_BOR and MPI_UNSIGNED", rc);
252 if (uoutbuf[0] != 0xffffffff) {
254 fprintf(stderr, "unsigned BOR(1) test failed\n");
258 fprintf(stderr, "unsigned BOR(0) test failed\n");
260 if (uoutbuf[2] != 0xffffffff && size > 1) {
262 fprintf(stderr, "unsigned BOR(>) test failed\n");
268 MTestPrintfMsg(10, "Reduce of MPI_INT\n");
269 iinbuf[0] = 0xffffffff;
271 iinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
276 rc = MPI_Reduce(iinbuf, ioutbuf, 3, MPI_INT, MPI_BOR, 0, comm);
278 MTestPrintErrorMsg("MPI_BOR and MPI_INT", rc);
283 if (ioutbuf[0] != 0xffffffff) {
285 fprintf(stderr, "int BOR(1) test failed\n");
289 fprintf(stderr, "int BOR(0) test failed\n");
291 if (ioutbuf[2] != 0xffffffff && size > 1) {
293 fprintf(stderr, "int BOR(>) test failed\n");
299 MTestPrintfMsg(10, "Reduce of MPI_LONG\n");
300 linbuf[0] = 0xffffffff;
302 linbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
307 rc = MPI_Reduce(linbuf, loutbuf, 3, MPI_LONG, MPI_BOR, 0, comm);
309 MTestPrintErrorMsg("MPI_BOR and MPI_LONG", rc);
314 if (loutbuf[0] != 0xffffffff) {
316 fprintf(stderr, "long BOR(1) test failed\n");
320 fprintf(stderr, "long BOR(0) test failed\n");
322 if (loutbuf[2] != 0xffffffff && size > 1) {
324 fprintf(stderr, "long BOR(>) test failed\n");
330 MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_LONG\n");
331 ulinbuf[0] = 0xffffffff;
333 ulinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
338 rc = MPI_Reduce(ulinbuf, uloutbuf, 3, MPI_UNSIGNED_LONG, MPI_BOR, 0, comm);
340 MTestPrintErrorMsg("MPI_BOR and MPI_UNSIGNED_LONG", rc);
345 if (uloutbuf[0] != 0xffffffff) {
347 fprintf(stderr, "unsigned long BOR(1) test failed\n");
351 fprintf(stderr, "unsigned long BOR(0) test failed\n");
353 if (uloutbuf[2] != 0xffffffff && size > 1) {
355 fprintf(stderr, "unsigned long BOR(>) test failed\n");
360 #ifdef HAVE_LONG_LONG
362 long long llinbuf[3], lloutbuf[3];
364 llinbuf[0] = 0xffffffff;
366 llinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
371 if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
372 MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n");
373 rc = MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_BOR, 0, comm);
375 MTestPrintErrorMsg("MPI_BOR and MPI_LONG_LONG", rc);
380 if (lloutbuf[0] != 0xffffffff) {
382 fprintf(stderr, "long long BOR(1) test failed\n");
386 fprintf(stderr, "long long BOR(0) test failed\n");
388 if (lloutbuf[2] != 0xffffffff && size > 1) {
390 fprintf(stderr, "long long BOR(>) test failed\n");
398 MPI_Errhandler_set(comm, MPI_ERRORS_ARE_FATAL);
399 MTest_Finalize(errs);