1 /* Copyright (c) 2009-2018. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
13 int main(int argc, char *argv[])
19 MPI_Init(&argc, &argv);
20 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
21 MPI_Comm_size(MPI_COMM_WORLD, &size);
24 int* sb = (int *) xbt_malloc(count * sizeof(int));
25 int* rb = (int *) xbt_malloc(count * size * sizeof(int));
27 for (int i = 0; i < count; ++i)
28 sb[i] = rank * count + i;
29 for (int i = 0; i < count * size; ++i)
32 printf("[%d] sndbuf=[", rank);
33 for (int i = 0; i < count; i++)
37 status = MPI_Allgather(sb, count, MPI_INT, rb, count, MPI_INT, MPI_COMM_WORLD);
39 printf("[%d] rcvbuf=[", rank);
40 for (int i = 0; i < count * size; i++)
44 if (rank == 0 && status != MPI_SUCCESS) {
45 printf("allgather returned %d\n", status);
51 return (EXIT_SUCCESS);