1 /* Copyright (c) 2009-2010, 2013-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[])
21 MPI_Init(&argc, &argv);
22 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
23 MPI_Comm_size(MPI_COMM_WORLD, &size);
26 int* sb = (int *) xbt_malloc(count * sizeof(int));
27 int* rb = (int *) xbt_malloc(count * size * sizeof(int));
29 for (int i = 0; i < count; ++i)
30 sb[i] = rank * count + i;
31 for (int i = 0; i < count * size; ++i)
34 printf("[%d] sndbuf=[", rank);
35 for (int i = 0; i < count; i++)
39 status = MPI_Gather(sb, count, MPI_INT, rb, count, MPI_INT, root, MPI_COMM_WORLD);
42 printf("[%d] rcvbuf=[", rank);
43 for (int i = 0; i < count * size; i++)
47 if (status != MPI_SUCCESS) {
48 printf("allgather returned %d\n", status);
54 MPI_Barrier(MPI_COMM_WORLD);
56 return (EXIT_SUCCESS);