# include # include # include "mpi.h" using namespace std; int main ( int argc, char *argv[] ) { int my_id; int num_procs; MPI::Init ( argc, argv ); my_id = MPI::COMM_WORLD.Get_rank ( ); if ( my_id == 0 ) { num_procs = MPI::COMM_WORLD.Get_size ( ); cout << "\n"; cout << "HELLO_WORLD - Master process:\n"; cout << " A simple C++ program using MPI.\n"; cout << " The number of processes is " << num_procs << "\n"; } else { cout << " Process " << my_id << " says 'Hello, world!'\n"; } MPI::Finalize ( ); return 0; }