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_MIN 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" );
42 cinbuf[2] = (rank & 0x7f);
47 MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_MIN, 0, comm );
49 if (coutbuf[0] != 1) {
51 fprintf( stderr, "char MIN(1) test failed\n" );
53 if (coutbuf[1] != 0) {
55 fprintf( stderr, "char MIN(0) test failed\n" );
57 if (coutbuf[2] != 0) {
59 fprintf( stderr, "char MIN(>) test failed\n" );
62 #endif /* USE_STRICT_MPI */
65 MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" );
68 scinbuf[2] = (rank & 0x7f);
73 MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_MIN, 0, comm );
75 if (scoutbuf[0] != 1) {
77 fprintf( stderr, "signed char MIN(1) test failed\n" );
79 if (scoutbuf[1] != 0) {
81 fprintf( stderr, "signed char MIN(0) test failed\n" );
83 if (scoutbuf[2] != 0) {
85 fprintf( stderr, "signed char MIN(>) test failed\n" );
90 MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" );
93 ucinbuf[2] = (rank & 0x7f);
98 MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_MIN, 0, comm );
100 if (ucoutbuf[0] != 1) {
102 fprintf( stderr, "unsigned char MIN(1) test failed\n" );
106 fprintf( stderr, "unsigned char MIN(0) test failed\n" );
108 if (ucoutbuf[2] != 0) {
110 fprintf( stderr, "unsigned char MIN(>) 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_MIN, 0, comm );
128 if (ldoutbuf[0] != 1) {
130 fprintf( stderr, "long double MIN(1) test failed\n" );
132 if (ldoutbuf[1] != 0.0) {
134 fprintf( stderr, "long double MIN(0) test failed\n" );
136 if (ldoutbuf[2] != 0.0) {
138 fprintf( stderr, "long double MIN(>) 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_MIN, 0, comm );
160 if (lloutbuf[0] != 1) {
162 fprintf( stderr, "long long MIN(1) test failed\n" );
164 if (lloutbuf[1] != 0) {
166 fprintf( stderr, "long long MIN(0) test failed\n" );
168 if (lloutbuf[2] != 0) {
170 fprintf( stderr, "long long MIN(>) test failed\n" );
175 #endif /* HAVE_LONG_LONG */
177 MTest_Finalize( errs );