1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2003 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
13 static char MTEST_Descrip[] = "Test MPI_Allreduce with count greater than the number of processes";
16 /* We make the error count global so that we can easily control the output
17 of error information (in particular, limiting it after the first 10
21 int main( int argc, char *argv[] )
25 int count, *bufin, *bufout, size, i, minsize=1;
27 MTest_Init( &argc, &argv );
29 while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
30 if (comm == MPI_COMM_NULL) {
33 MPI_Comm_size( comm, &size );
35 bufin = (int *)malloc( count * sizeof(int) );
36 bufout = (int *)malloc( count * sizeof(int) );
37 if (!bufin || !bufout) {
38 fprintf( stderr, "Unable to allocated space for buffers (%d)\n",
40 MPI_Abort( MPI_COMM_WORLD, 1 );
43 for (i=0; i<count; i++) {
49 MPI_Allreduce( bufin, bufout, count, dtype, MPI_SUM, comm );
51 for (i=0; i<count; i++) {
52 if (bufout[i] != i * size) {
53 fprintf( stderr, "Expected bufout[%d] = %d but found %d\n",
54 i, i * size, bufout[i] );
60 MTestFreeComm( &comm );
63 MTest_Finalize( errs );