#include #include #include #include "mpi.h" int main(int argc, char** argv) { int meu_rank, tag=0; int a = 3, b = 2, soma, mult; MPI_Status status; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &meu_rank); if (meu_rank == 0) { MPI_Recv(&soma, 1, MPI_INT, 1, tag, MPI_COMM_WORLD, &status); MPI_Recv(&mult, 1, MPI_INT, 2, tag, MPI_COMM_WORLD, &status); printf("A soma e %d\n", soma); printf("A multiplicacao e %d\n", mult); } else if (meu_rank == 1) { soma = a + b; MPI_Send(&soma, 1, MPI_INT, 0, tag, MPI_COMM_WORLD); } else { mult = a * b; MPI_Send(&mult, 1, MPI_INT, 0, tag, MPI_COMM_WORLD); } MPI_Finalize( ); }