Message-Passing Interface
1 #include
2 int main(int argc, char *argv[])
3 { int rank, size, buf[20];
4 MPI_Init(&argc, &argv);
5 MPI_Comm_rank(MPI_COMM_WORLD, &rank); // Process ID
6 MPI_Comm_size(MPI_COMM_WORLD, &size); // Total procs
7
8 if (rank == 1 ) MPI_Recv(buf, 20, MPI_INT, 0 , ...);
9 if (rank == 0 ) MPI_Send(buf, 20, MPI_INT, 1 , ...);
10
11 MPI_Finalize();
12 return EXIT_SUCCESS;
13 }
Nicholas Ng (
[email protected])
Safer Parallel Programming with Types