#include #include "mpi.h" using namespace std; /* int MPI_Send(const void *buf , int count, MPI_Datatype datatype, int dest , int tag, MPI_Comm comm) MPI_Send(this_process_number, 1 , MPI_INT , 0 , 1 , MPI_COMM_WORLD); int MPI_Recv( void *buf , int count, MPI_Datatype datatype, int source , int tag, MPI_Comm comm , MPI_Status *status) MPI_Recv(this_process_number, 1 , MPI_INT , i , 1 , MPI_COMM_WORLD, status) */ int main() { int error_number; int this_process_number; int number_of_processes; MPI_Status *status; void * buf; int i; MPI_Init(NULL,NULL); MPI_Comm_size(MPI_COMM_WORLD, &number_of_processes); MPI_Comm_rank(MPI_COMM_WORLD, &this_process_number); if (this_process_number==0) { cout << " Hello from process " << this_process_number << " of " << number_of_processes << " processes." << endl; for( i = 1 ; i < number_of_processes ;i++) { buf = &this_process_number ; MPI_Recv(buf, 1, MPI_INT, i, 1, MPI_COMM_WORLD, status); cout << " Hello from process " << this_process_number << " of " << number_of_processes << " processes." << endl; } } else { buf=&this_process_number; MPI_Send(buf, 1, MPI_INT, 0, 1, MPI_COMM_WORLD); } MPI_Finalize(); return(0); }