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);
30 sb = (int *) xbt_malloc(size * sizeof(int));
31 rb = (int *) xbt_malloc(size * sizeof(int));
33 for (i = 0; i < size; ++i) {
34 sb[i] = rank*size + i;
37 printf("[%d] sndbuf=[", rank);
38 for (i = 0; i < size; i++)
43 status = MPI_Reduce(sb, rb, size, MPI_INT, MPI_SUM, root, MPI_COMM_WORLD);
44 MPI_Barrier(MPI_COMM_WORLD);
47 printf("[%d] rcvbuf=[", rank);
48 for (i = 0; i < size; i++)
51 if (status != MPI_SUCCESS) {
52 printf("all_to_all returned %d\n", status);
58 printf("[%d] second sndbuf=[", rank);
59 for (i = 0; i < 1; i++)
64 status = MPI_Reduce(sb, rb, 1, MPI_INT, MPI_PROD, root, MPI_COMM_WORLD);
65 MPI_Barrier(MPI_COMM_WORLD);
68 printf("[%d] rcvbuf=[", rank);
69 for (i = 0; i < 1; i++)
72 if (status != MPI_SUCCESS) {
73 printf("all_to_all returned %d\n", status);
80 return (EXIT_SUCCESS);