pborawski

mpi funkcje send recv

Dec 10th, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include <mpi.h>
  2. #include <stdio.h>
  3. #include <math.h>
  4.  
  5. int main( int argc, char *argv[] )
  6. {
  7.     int id,from,to,tag,numproc;
  8.     double data;
  9.    
  10.     MPI_Init(&argc,&argv);
  11.     MPI_Status status;
  12.     MPI_Comm_rank(MPI_COMM_WORLD, &id);
  13.    
  14.     if( id == 0 )
  15.     {
  16.         to = 3; tag = 2012; data = 10.12;
  17.         MPI_Send(&data, 1, MPI_DOUBLE, to, tag, MPI_COMM_WORLD);
  18.     }
  19.     else if (id == 3)
  20.     {
  21.         from = 0; tag = 2012;
  22.         MPI_Recv(&data,1,MPI_DOUBLE,from,tag,MPI_COMM_WORLD,&status);
  23.         printf("Proces %d odebral %f\n", id,data);
  24.     }
  25.     else {}
  26.     MPI_Finalize();
  27.    
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment