#include #include #include int main(int argc, char** argv) { // Initialize the MPI environment MPI_Init(&argc, &argv); // Find out rank, size int world_rank; MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); int world_size; MPI_Comm_size(MPI_COMM_WORLD, &world_size); // We are assuming at least 2 processes for this task if (world_size < 2) { fprintf(stderr, "World size must be greater than 1 for %s\n", argv[0]); MPI_Abort(MPI_COMM_WORLD, 1); } int number; if (world_rank == 0) { // If we are rank 0, set the number to 7 and send it to process 1 number = 7; MPI_Send(&number, 1, MPI_INT, 1, 0, MPI_COMM_WORLD); printf("Process 0 sent number %d to process 1\n", number); } else if (world_rank == 1) { // If we are rank 1, receive the number from process 0 MPI_Recv(&number, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); printf("Process 1 received number %d from process 0\n", number); } // Finalize the MPI environment MPI_Finalize(); }