1 /* Copyright (c) 2009, 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. */
10 int main(int argc, char **argv)
17 MPI_Init(&argc, &argv);
18 MPI_Comm_size(MPI_COMM_WORLD, &size);
19 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
21 values = (int *) xbt_malloc(count * sizeof(int));
23 for (i = 0; i < count; i++)
24 values[i] = (0 == rank) ? 17 : 3;
26 status = MPI_Bcast(values, count, MPI_INT, 0, MPI_COMM_WORLD);
29 for (i = 0; i < count; i++)
30 if (values[i]==17) good++;
31 printf("[%d] number of values equals to 17: %d\n", rank, good);
33 MPI_Barrier(MPI_COMM_WORLD);
37 values = (int *) xbt_malloc(count * sizeof(int));
39 for (i = 0; i < count; i++)
40 values[i] = (size -1 == rank) ? 17 : 3;
42 status = MPI_Bcast(values, count, MPI_INT, size-1, MPI_COMM_WORLD);
45 for (i = 0; i < count; i++)
46 if (values[i]==17) good++;
47 printf("[%d] number of values equals to 17: %d\n", rank, good);
53 if (status != MPI_SUCCESS) {
54 printf("bcast returned %d\n", status);