1 /* Copyright (c) 2009, 2010. 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[])
29 MPI_Init(&argc, &argv);
30 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
31 MPI_Comm_size(MPI_COMM_WORLD, &size);
33 recv_counts = (int *) xbt_malloc(size * sizeof(int));
34 recv_disps = (int *) xbt_malloc(size * sizeof(int));
37 for (i = 0; i < size; i++) {
38 recv_counts[i] = i + 1;
39 recv_disps[i] = recv_sb_size;
40 recv_sb_size += i + 1;
43 sb = (int *) xbt_malloc(recv_counts[rank] * sizeof(int));
44 rb = (int *) xbt_malloc(recv_sb_size * sizeof(int));
46 for (i = 0; i < recv_counts[rank]; ++i)
47 sb[i] = recv_disps[rank] + i;
48 for (i = 0; i < recv_sb_size; ++i)
51 printf("[%d] sndbuf=[", rank);
52 for (i = 0; i < recv_counts[rank]; i++)
56 status = MPI_Allgatherv(sb, recv_counts[rank], MPI_INT, rb, recv_counts, recv_disps, MPI_INT, MPI_COMM_WORLD);
58 printf("[%d] rcvbuf=[", rank);
59 for (i = 0; i < recv_sb_size; i++)
65 if (status != MPI_SUCCESS) {
66 printf("allgatherv returned %d\n", status);
73 return (EXIT_SUCCESS);