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 /* Gather data from a vector to contiguous. */
15 int main(int argc, char **argv)
17 double *vecout, *invec;
19 int count, minsize = 2;
23 MTest_Init(&argc, &argv);
25 while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
26 if (comm == MPI_COMM_NULL)
28 /* Determine the sender and receiver */
29 MPI_Comm_rank(comm, &rank);
30 MPI_Comm_size(comm, &size);
32 for (count = 1; count < 9000; count = count * 2) {
33 invec = (double *) malloc(count * sizeof(double));
34 vecout = (double *) malloc(size * count * sizeof(double));
36 for (i = 0; i < count; i++) {
37 invec[i] = rank * count + i;
39 MPI_Allgather(invec, count, MPI_DOUBLE, vecout, count, MPI_DOUBLE, comm);
40 for (i = 0; i < count * size; i++) {
44 fprintf(stderr, "vecout[%d]=%d\n", i, (int) vecout[i]);
55 /* Do a zero byte gather */
56 MPI_Allgather(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, NULL, 0, MPI_BYTE, MPI_COMM_WORLD);