Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<mpi.h>
- main(int argc, char **argv)
- {
- MPI_Init(&argc, &argv);
- MPI_Comm newcomm;
- int dims [] = {3, 3},
- periodic [] = {0, 0},
- reorder = 0;
- int rank;
- MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- MPI_Cart_create(MPI_COMM_WORLD, 2, dims, periodic, reorder, &newcomm);
- int coords[2];
- MPI_Cart_coords(newcomm, rank, 2, coords);
- // printf("%d: (%d, %d)\n", rank, coords[0], coords[1]);
- int source, destination;
- MPI_Cart_shift(newcomm, 0, 1, &source, &destination);
- printf("%d, %d, %d\n", source, rank, destination);
- MPI_Finalize();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement