19 lines
409 B
C
19 lines
409 B
C
#include <stdio.h>
|
|
#include <mpi.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int rank;
|
|
MPI_Init(&argc, &argv);
|
|
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|
int random;
|
|
if (rank == 0) {
|
|
srand(2);
|
|
random = rand();
|
|
}
|
|
MPI_Bcast(&random, 1, MPI_INT, 0, MPI_COMM_WORLD);
|
|
printf("rank %d, random: %d\n", rank, random);
|
|
MPI_Finalize();
|
|
}
|