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.
11 #include "mpicolltest.h"
14 static char MTEST_Descrip[] = "Simple intercomm allgather test";
17 int main(int argc, char *argv[])
20 int *rbuf = 0, *sbuf = 0;
21 int leftGroup, i, count, rank, rsize;
23 MPI_Datatype datatype;
25 MTest_Init(&argc, &argv);
28 /* Get an intercommunicator */
29 while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
30 if (comm == MPI_COMM_NULL)
32 MPI_Comm_rank(comm, &rank);
33 MPI_Comm_remote_size(comm, &rsize);
35 /* To improve reporting of problems about operations, we
36 * change the error handler to errors return */
37 MPI_Errhandler_set(comm, MPI_ERRORS_RETURN);
39 for (count = 1; count < 65000; count = 2 * count) {
40 /* The left group will send rank to the right group;
41 * The right group will send -rank to the left group */
42 rbuf = (int *) malloc(count * rsize * sizeof(int));
43 sbuf = (int *) malloc(count * sizeof(int));
44 for (i = 0; i < count * rsize; i++)
47 for (i = 0; i < count; i++)
48 sbuf[i] = i + rank * count;
51 for (i = 0; i < count; i++)
52 sbuf[i] = -(i + rank * count);
54 err = MTest_Allgather(sbuf, count, datatype, rbuf, count, datatype, comm);
60 for (i = 0; i < count * rsize; i++) {
67 for (i = 0; i < count * rsize; i++) {
74 /* Use Allgather in a unidirectional way */
75 for (i = 0; i < count * rsize; i++)
78 err = MTest_Allgather(sbuf, 0, datatype, rbuf, count, datatype, comm);
83 for (i = 0; i < count * rsize; i++) {
90 err = MTest_Allgather(sbuf, count, datatype, rbuf, 0, datatype, comm);
95 for (i = 0; i < count * rsize; i++) {
104 MTestFreeComm(&comm);
107 MTest_Finalize(errs);