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
115 { long double ldinbuf[3], ldoutbuf[3];
124 if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
125 MTestPrintfMsg( 10, "Reduce of MPI_LONG_DOUBLE\n" );
126 MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_MAX, 0, comm );
128 if (ldoutbuf[0] != 1) {
130 fprintf( stderr, "long double MAX(1) test failed\n" );
132 if (ldoutbuf[1] != 0.0) {
134 fprintf( stderr, "long double MAX(0) test failed\n" );
136 if (ldoutbuf[2] != size - 1) {
138 fprintf( stderr, "long double MAX(>) test failed\n" );
143 #endif /* HAVE_LONG_DOUBLE */
145 #ifdef HAVE_LONG_LONG
147 long long llinbuf[3], lloutbuf[3];
156 if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
157 MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" );
158 MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_MAX, 0, comm );
160 if (lloutbuf[0] != 1) {
162 fprintf( stderr, "long long MAX(1) test failed\n" );
164 if (lloutbuf[1] != 0) {
166 fprintf( stderr, "long long MAX(0) test failed\n" );
168 if (lloutbuf[2] != size - 1) {
170 fprintf( stderr, "long long MAX(>) test failed\n" );
175 #endif /* HAVE_LONG_LONG */
177 MTest_Finalize( errs );