/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ /* * (C) 2003 by Argonne National Laboratory. * See COPYRIGHT in top-level directory. */ #include "mpi.h" #include "mpitestconf.h" #ifdef HAVE_IOSTREAM // Not all C++ compilers have iostream instead of iostream.h #include #ifdef HAVE_NAMESPACE_STD // Those that do often need the std namespace; otherwise, a bare "cout" // is likely to fail to compile using namespace std; #endif #else #include #endif #include "mpitestcxx.h" #include static char MTEST_Descrip[] = "Test MPI_Allreduce with non-commutative user-defined operations"; /* We make the error count global so that we can easily control the output of error information (in particular, limiting it after the first 10 errors */ int errs = 0; /* This implements a simple matrix-matrix multiply. This is an associative but not commutative operation. The matrix size is set in matSize; the number of matrices is the count argument. The matrix is stored in C order, so that c(i,j) is cin[j+i*matSize] */ #define MAXCOL 256 static int matSize = 0; /* Must be < MAXCOL */ static int max_offset = 0; void uop( const void *cinPtr, void *coutPtr, int count, const MPI::Datatype &dtype ) { const int *cin = (const int *)cinPtr; int *cout = (int *)coutPtr; int i, j, k, nmat; int tempcol[MAXCOL]; int offset1, offset2; int matsize2 = matSize*matSize; for (nmat = 0; nmat < count; nmat++) { for (j=0; j