Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
renamed DO_ONCE to SMPI_DO_ONCE.
[simgrid.git] / src / smpi / sample / bcast.c
1 #include <stdio.h>
2 #include <mpi.h>
3
4 int main (int argc, char **argv) {
5   int size, rank;
6   int value = 3;
7   MPI_Init(&argc, &argv);
8   MPI_Comm_size(MPI_COMM_WORLD, &size);
9   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
10   if (0 == rank) {
11     value = 17;
12   }
13   printf("node %d has value %d\n", rank, value);
14   MPI_Bcast(&value, 1, MPI_INT, 0, MPI_COMM_WORLD);
15   printf("node %d has value %d\n", rank, value);
16   MPI_Finalize();
17   return 0;
18 }