Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132944 views
License: OTHER
1
#include "mpi.h"
2
...
3
int signal, i, numprogs, me;
4
MPI_Status stat;
5
MPI_Comm_rank(MPI_COMM_WORLD, &me);
6
MPI_Comm_size(MPI_COMM_WORLD,
7
&numprocs);
8
if (me==ROOT) {
9
...
10
for (i=1; i<numprocs; i++) {
11
MPI_Send(&signal, 1, MPI_INT, i, 0, MPI_COMM_WORLD);
12
}
13
...
14
else {
15
MPI_Recv(&sig, 1, MPI_INT, ROOT, MPI_ANY_TAG,
16
MPI_COMM_WORLD, &stat);
17
...
18
}
19