Advertisement
Guest User

simple mpi program

a guest
May 29th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <mpi.h>
  2. #include <stdio.h>
  3. #include <unistd.h>
  4.  
  5. int main(int argc, char** argv)
  6. {
  7.     int rank, size;
  8.     MPI_Init(&argc, &argv);
  9.  
  10.     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  11.     MPI_Comm_size(MPI_COMM_WORLD, &size);
  12.  
  13.     if (rank == 0) {
  14.         MPI_Request req;
  15.         MPI_Issend(NULL, 0, MPI_INT, 1, 0, MPI_COMM_WORLD, &req);
  16.         sleep(1);
  17.         MPI_Cancel(&req);
  18.         MPI_Wait(&req, MPI_STATUS_IGNORE);
  19.     }
  20.  
  21.     MPI_Finalize();
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement