2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-26 06:48:04 +02:00

Misc; E-Mail von Moritz

This commit is contained in:
Martin Thoma 2014-04-05 18:18:47 +02:00
parent 9c0864f122
commit 0508de3f6a
14 changed files with 122 additions and 16 deletions

View file

@ -1,18 +1,24 @@
void my_bcast(void* data, int count, MPI_Datatype type,
void my_bcast(void* data, int count,
MPI_Datatype type,
int root, MPI_Comm comm) {
int my_rank;
int my_rank, comm_size;
MPI_Comm_rank(comm, &my_rank);
int comm_size;
MPI_Comm_size(comm, &comm_size);
if (my_rank == root) {
// If we are the root process, send our data to every one
// If we are the root process, send our
// data to every one
for (int i = 0; i < comm_size; i++) {
if (i != my_rank) {
MPI_Send(data, count, type, i, 0, comm);
MPI_Send(data, count,
type, i, 0, comm);
}
}
} else {
// If we are a receiver process, receive the data from root
MPI_Recv(data, count, type, root, 0, comm, MPI_STATUS_IGNORE);
// If we are a receiver process,
// receive the data from root
MPI_Recv(data, count, type, root, 0,
comm, MPI_STATUS_IGNORE);
}
}