X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1c080fdf88d3dc8cbf7413b1f8b3ce66d475070a..d47debaeffa6807956ee9cc7da90759efe49beda:/src/smpi/sample/bcast.c?ds=sidebyside diff --git a/src/smpi/sample/bcast.c b/src/smpi/sample/bcast.c new file mode 100644 index 0000000000..2d84c1371e --- /dev/null +++ b/src/smpi/sample/bcast.c @@ -0,0 +1,18 @@ +#include +#include + +int main (int argc, char **argv) { + int size, rank; + int value = 3; + MPI_Init(&argc, &argv); + MPI_Comm_size(MPI_COMM_WORLD, &size); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + if (0 == rank) { + value = 17; + } + printf("node %d has value %d\n", rank, value); + MPI_Bcast(&value, 1, MPI_INT, 0, MPI_COMM_WORLD); + printf("node %d has value %d\n", rank, value); + MPI_Finalize(); + return 0; +}