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
205 { long double ldinbuf[3], ldoutbuf[3];
209 ldinbuf[2] = (rank > 0);
214 if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
215 MTestPrintfMsg( 10, "Reduce of MPI_LONG_DOUBLE\n" );
216 err = MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_LOR, 0, comm );
219 MTestPrintErrorMsg( "MPI_LOR and MPI_LONG_DOUBLE", err );
225 fprintf( stderr, "long double OR(1) test failed\n" );
229 fprintf( stderr, "long double OR(0) test failed\n" );
231 if (!ldoutbuf[2] && size > 1) {
233 fprintf( stderr, "long double OR(>) test failed\n" );
239 #endif /* HAVE_LONG_DOUBLE */
240 #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 err = MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_LOR, 0, comm );
258 MTestPrintErrorMsg( "MPI_LOR and MPI_LONG_LONG", err );
264 fprintf( stderr, "long long OR(1) test failed\n" );
268 fprintf( stderr, "long long OR(0) test failed\n" );
270 if (!lloutbuf[2] && size > 1) {
272 fprintf( stderr, "long long OR(>) test failed\n" );
280 MPI_Errhandler_set( comm, MPI_ERRORS_ARE_FATAL );
281 MTest_Finalize( errs );