# include # include # include using namespace std; # include "mpi.h" int main ( int argc, char *argv[] ); //****************************************************************************80 int main ( int argc, char *argv[] ) //****************************************************************************80 // // Purpose: // // MAIN is the main program for HELLO. // // Discussion: // // HELLO is a simple MPI test program. // // Each process prints out a "Hello, world!" message. // // The master process also prints out a short message. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 28 October 2008 // // Author: // // John Burkardt // // Reference: // // William Gropp, Ewing Lusk, Anthony Skjellum, // Using MPI: Portable Parallel Programming with the // Message-Passing Interface, // Second Edition, // MIT Press, 1999, // ISBN: 0262571323, // LC: QA76.642.G76. // { int id; int p; double wtime; // // Initialize MPI. // MPI::Init ( argc, argv ); // // Get the number of processes. // p = MPI::COMM_WORLD.Get_size ( ); // // Get the individual process ID. // id = MPI::COMM_WORLD.Get_rank ( ); // // Process 0 prints an introductory message. // if ( id == 0 ) { wtime = MPI_Wtime ( ); cout << "\n"; cout << "HELLO_WORLD - Master process:\n"; cout << " C++ version\n"; cout << " An MPI example program.\n"; cout << "\n"; cout << " The number of processes is " << p << "\n"; cout << "\n"; } // // Every process prints a hello. // cout << " Process " << id << " says 'Hello, world!'\n"; // // Process 0 says goodbye. // if ( id == 0 ) { cout << "\n"; cout << "HELLO_WORLD - Master process:\n"; cout << " Normal end of execution: 'Goodbye, world!'\n"; wtime = MPI_Wtime ( ) - wtime; cout << "\n"; cout << " Elapsed wall clock time = " << wtime << " seconds.\n"; } // // Shut down MPI. // MPI::Finalize ( ); return 0; }