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. Use IN_PLACE. This is
14 the trivial version based on the allgather test (allgatherv but with
15 constant data sizes) */
17 int main(int argc, char **argv)
21 int count, minsize = 2;
24 int *displs, *recvcounts;
26 MTest_Init(&argc, &argv);
28 while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
29 if (comm == MPI_COMM_NULL)
31 /* Determine the sender and receiver */
32 MPI_Comm_rank(comm, &rank);
33 MPI_Comm_size(comm, &size);
35 displs = (int *) malloc(size * sizeof(int));
36 recvcounts = (int *) malloc(size * sizeof(int));
38 for (count = 1; count < 9000; count = count * 2) {
39 vecout = (double *) malloc(size * count * sizeof(double));
41 for (i = 0; i < count; i++) {
42 vecout[rank * count + i] = rank * count + i;
44 for (i = 0; i < size; i++) {
45 recvcounts[i] = count;
46 displs[i] = i * count;
48 MPI_Allgatherv(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL,
49 vecout, recvcounts, displs, MPI_DOUBLE, comm);
50 for (i = 0; i < count * size; i++) {
54 fprintf(stderr, "vecout[%d]=%d\n", i, (int) vecout[i]);