Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (rank == 0) {
- src = null
- dest = rank + 1
- }
- if (rank == size - 1) {
- src = rank - 1
- dest = null
- } else {
- src = rank - 1
- dest = rank + 1
- }
- MPI_SendRecv(&sendbuf[offset], slen, dest..
- &recvbuf[offset], rlen, src);
- height = total_hight / ranks;
- std::vector<float> data(width * (height + 2));
- float* image = &data[width];
- float* ghost_north = &data[0]
- float* ghost_south = &data[width * (height + 1)]
- float* inner_north = image;
- float* inner_south = &image[width * (height - 1)]
- MPI_Scatter(root_image, width * height, MPI_FLOAT,
- image, width * height, MPI_FLOAT, ...);
- ...
- iterations {
- MPI_SendRecv(inner_north, width, MPI_FLOAT, north, tag,
- ghost_north, width, MPI_FLOAT, north, tag, ...)
- MPI_SendRecv(inner_south, width, MPI_FLOAT, south, tag,
- ghost_south, width, MPI_FLOAT, south, tag, ...)
- ... compute ...
- }
- MPI_Gather(image, width * height, MPI_FLOAT,
- root_image, width * height, MPI_FLOAT, ...);
Add Comment
Please, Sign In to add comment