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.
13 static char MTEST_Descrip[] = "A simple test of Reduce with all choices of root process";
16 int main(int argc, char *argv[])
20 int *sendbuf, *recvbuf, i;
21 int minsize = 2, count;
24 MTest_Init(&argc, &argv);
26 while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
27 if (comm == MPI_COMM_NULL)
29 /* Determine the sender and receiver */
30 MPI_Comm_rank(comm, &rank);
31 MPI_Comm_size(comm, &size);
33 for (count = 1; count < 130000; count = count * 2) {
34 sendbuf = (int *) malloc(count * sizeof(int));
35 recvbuf = (int *) malloc(count * sizeof(int));
36 for (root = 0; root < size; root++) {
37 for (i = 0; i < count; i++)
39 for (i = 0; i < count; i++)
41 MPI_Reduce(sendbuf, recvbuf, count, MPI_INT, MPI_SUM, root, comm);
43 for (i = 0; i < count; i++) {
44 if (recvbuf[i] != i * size) {