Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132937 views
License: OTHER
1
#include "mpi.h"
2
#define ROOT 0
3
4
int numprocs, myid, bufsize;
5
int *sendbuf, *recvbuf;
6
7
...
8
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
9
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
10
...
11
... sendbuf allocieren, belegen ...
12
... bufsize belegen ...
13
if (myid==ROOT) {
14
...
15
recvbuf=malloc(bufsize*sizeof(int));
16
}
17
MPI_Gather(sendbuf, bufsize, MPI_INT, recvbuf, bufsize,
18
MPI_INT, ROOT, MPI_COMM_WORLD);
19
...
20