1 /* Copyright (c) 2009-2010, 2013-2014. 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. */
14 #define EXIT_SUCCESS 0
15 #define EXIT_FAILURE 1
18 int main(int argc, char *argv[])
26 MPI_Init(&argc, &argv);
27 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
28 MPI_Comm_size(MPI_COMM_WORLD, &size);
31 int* sb = (int *) xbt_malloc(count * sizeof(int));
32 int* rb = (int *) xbt_malloc(count * size * sizeof(int));
34 for (int i = 0; i < count; ++i)
35 sb[i] = rank * count + i;
36 for (int i = 0; i < count * size; ++i)
39 printf("[%d] sndbuf=[", rank);
40 for (int i = 0; i < count; i++)
44 status = MPI_Gather(sb, count, MPI_INT, rb, count, MPI_INT, root, MPI_COMM_WORLD);
47 printf("[%d] rcvbuf=[", rank);
48 for (int i = 0; i < count * size; i++)
52 if (status != MPI_SUCCESS) {
53 printf("allgather returned %d\n", status);
59 MPI_Barrier(MPI_COMM_WORLD);
61 return (EXIT_SUCCESS);