20 lines
401 B
C
20 lines
401 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();
|
||
|
}
|
||
|
// Add the broadcast directive below:
|
||
|
|
||
|
printf("rank %d, random: %d\n", rank, random);
|
||
|
MPI_Finalize();
|
||
|
}
|