SHARE
TWEET

Untitled

Bernard0x01 Apr 18th, 2019 (edited) 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top