22 lines
536 B
C
22 lines
536 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);
|
|
if (rank == 0) {
|
|
srand(2);
|
|
int random = rand();
|
|
MPI_Send(&random, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
|
|
printf("rank 0 random: %d \t", random);
|
|
} else if (rank == 1) {
|
|
int random;
|
|
// Recieve data from rank 0 here:
|
|
printf("rank 1, random: %d", random);
|
|
}
|
|
MPI_Finalize();
|
|
}
|