Advertisement
neron476

mpi_Hello

Nov 13th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <mpi.h>
  3.  
  4. int main(int argc, char** argv)
  5. {
  6.  
  7. MPI_Init(&argc, &argv);
  8. int size, rank;
  9. MPI_Comm_size(MPI_COMM_WORLD, &size);
  10. MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  11. //printf("%d, %d ", size, rank);
  12. int a = 1, b = 666;
  13. MPI_Status status;
  14. if(rank == 0)
  15. {
  16. MPI_Send(&a, 1, MPI_INT, 1, 123, MPI_COMM_WORLD);
  17. }
  18. if(rank == 1)
  19. {
  20. MPI_Recv(&b, 1, MPI_INT, 0, 123, MPI_COMM_WORLD, &status);
  21. printf("%d ", b);
  22. }
  23. MPI_Finalize();
  24. }
  25. /////////////////////////mpicc main.c; mpirun - n2 a.put// gedit .bashrc
  26. // export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib64/openmpi/lib"
  27. // ssh имя компа
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement