Guest User

Untitled

a guest
Nov 19th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. if (rank == 0) {
  2. src = null
  3. dest = rank + 1
  4. }
  5.  
  6. if (rank == size - 1) {
  7. src = rank - 1
  8. dest = null
  9. } else {
  10. src = rank - 1
  11. dest = rank + 1
  12. }
  13.  
  14. MPI_SendRecv(&sendbuf[offset], slen, dest..
  15. &recvbuf[offset], rlen, src);
  16.  
  17. height = total_hight / ranks;
  18. std::vector<float> data(width * (height + 2));
  19. float* image = &data[width];
  20. float* ghost_north = &data[0]
  21. float* ghost_south = &data[width * (height + 1)]
  22. float* inner_north = image;
  23. float* inner_south = &image[width * (height - 1)]
  24. MPI_Scatter(root_image, width * height, MPI_FLOAT,
  25. image, width * height, MPI_FLOAT, ...);
  26. ...
  27. iterations {
  28. MPI_SendRecv(inner_north, width, MPI_FLOAT, north, tag,
  29. ghost_north, width, MPI_FLOAT, north, tag, ...)
  30. MPI_SendRecv(inner_south, width, MPI_FLOAT, south, tag,
  31. ghost_south, width, MPI_FLOAT, south, tag, ...)
  32. ... compute ...
  33. }
  34. MPI_Gather(image, width * height, MPI_FLOAT,
  35. root_image, width * height, MPI_FLOAT, ...);
Add Comment
Please, Sign In to add comment