Advertisement
Nikitka_36

count of mb/s

Nov 27th, 2014
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <mpi.h>
  2. #include <stdio.h>
  3.  
  4. int main(int argc, char** argv)
  5. {
  6.     int size, rank, a = 5, b = 1;
  7.     MPI_Status status;
  8.  
  9.     MPI_Init(&argc, &argv);
  10.    
  11.     MPI_Comm_size(MPI_COMM_WORLD, &size);
  12.     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  13.     for (int i = 0; i < 50; i++)
  14.     {
  15.     if(rank == i)
  16.     {
  17.         MPI_Send(&a, 1, MPI_INT, i+1, 123, MPI_COMM_WORLD);
  18.         MPI_Recv(&b, 1, MPI_INT, i+1, 123, MPI_COMM_WORLD, &status);
  19.     }  
  20.     if(rank == i+1)
  21.     {
  22.         MPI_Recv(&b, 1, MPI_INT, i, 123, MPI_COMM_WORLD, &status);
  23.         MPI_Send(&b, 1, MPI_INT, i, 123, MPI_COMM_WORLD);
  24.         printf("%d\n", b); 
  25.     }
  26.     }
  27.    
  28.    
  29.     //printf("%d\n%d\n", size, rank);
  30.     MPI_Finalize();
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement