Guest User

Untitled

a guest
Jan 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. int rank, size, tag, rc, i; MPI_Status status; char message[20]; rc = MPI_Init(&argc, &argv); rc = MPI_Comm_size(MPI_COMM_WORLD, &size); rc = MPI_Comm_rank(MPI_COMM_WORLD, &rank); tag=7;
  2. if (rank==0) { strcpy(message, "Hello, world"); for (int i=1;i<size;++i)
  3. rc = MPI_SEND(message, 13, MPI_CHAR, i, tag, MPI_COMM_WORLD);
  4. } else
  5. rc = MPI_RECV(message, 13, MPI_CHAR, 0, tag, MPI_COMM_WORLD, &status);
  6. std::cout<<"node "<<rank<<": "<<message<<std::endl; rc = MPI_Finalize();
Add Comment
Please, Sign In to add comment