Advertisement
Bernard0x01

Untitled

Apr 18th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. void my_bcast(void* data, int count, MPI_Datatype datatype, int root, MPI_Comm communicator) {
  2.   int world_rank;
  3.   MPI_Comm_rank(communicator, &world_rank);
  4.   int world_size;
  5.   MPI_Comm_size(communicator, &world_size);
  6.  
  7.   if (world_rank == root) {
  8.     int i;
  9.     for (i = 0; i < world_size; i++) {
  10.       if (i != world_rank) {
  11.         MPI_Send(data, count, datatype, i, 0, communicator);
  12.       }
  13.     }
  14.   } else {
  15.     MPI_Recv(data, count, datatype, root, 0, communicator,MPI_STATUS_IGNORE);
  16.   }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement