Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<mpi.h>
  4.  
  5. main(int argc, char **argv)
  6. {
  7.     MPI_Init(&argc, &argv);
  8.     MPI_Comm newcomm;
  9.     int dims [] = {3, 3},
  10.         periodic [] = {0, 0},
  11.         reorder = 0;
  12.     int rank;
  13.     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  14.     MPI_Cart_create(MPI_COMM_WORLD, 2, dims, periodic, reorder, &newcomm);
  15.     int coords[2];
  16.         MPI_Cart_coords(newcomm, rank, 2, coords);
  17. //      printf("%d: (%d, %d)\n", rank, coords[0], coords[1]);
  18.     int source, destination;
  19.     MPI_Cart_shift(newcomm, 0, 1, &source, &destination);
  20.     printf("%d, %d, %d\n", source, rank, destination); 
  21.  
  22.     MPI_Finalize();
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement