/* proc 0 use MPI_Isend to send message, proc 1 use MPI_Irecv to receive message, use MPI_Wait to make sure the messages are sent or received */ #include // for input/output #include //for mpi routines #define BUFSIZE 2048 //The size of the messege being passed main(int argc, char** argv) { int rank; //the rank of this process int tag = 0; float *sendbuf, *recvbuf; MPI_Status status; //not important here MPI_Request request; //not important here sendbuf = (float *)malloc(sizeof(float)*BUFSIZE); recvbuf = (float *)malloc(sizeof(float)*BUFSIZE); MPI_Init(&argc, &argv); //Initializing mpi MPI_Comm_rank(MPI_COMM_WORLD, &rank); //Getting my rank if( rank == 0 ) { printf("Hello world! I am proc 0, sending to proc 1\n"); //send to the proc 1 MPI_Isend(sendbuf, BUFSIZE, MPI_FLOAT, 1, tag, MPI_COMM_WORLD, &request); MPI_Wait (&request, &status); } else if( rank == 1) { //recieve from the proc 0 MPI_Irecv(recvbuf, BUFSIZE, MPI_FLOAT, 0, tag, MPI_COMM_WORLD, &request); MPI_Wait (&request, &status); } printf("Proc %d finished!!\n", rank); MPI_Finalize(); free(sendbuf); free(recvbuf); return 0; }