mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-25 22:38:04 +02:00
First- und Follow hinzugefügt
This commit is contained in:
parent
f5b2145486
commit
fac84dbab3
5 changed files with 97 additions and 1 deletions
|
@ -0,0 +1,18 @@
|
|||
void my_bcast(void* data, int count, MPI_Datatype type,
|
||||
int root, MPI_Comm comm) {
|
||||
int my_rank;
|
||||
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
|
||||
for (int i = 0; i < comm_size; i++) {
|
||||
if (i != my_rank) {
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue