Skip to main content Accessibility help
×
Hostname: page-component-cd9895bd7-fscjk Total loading time: 0 Render date: 2024-12-23T05:22:03.263Z Has data issue: false hasContentIssue false

B - MPI Basics

Published online by Cambridge University Press:  05 October 2013

George Em Karniadakis
Affiliation:
Brown University, Rhode Island
Robert M. Kirby II
Affiliation:
University of Utah
Get access

Summary

COMPILATION GUIDE

For the purposes of this compilation example, we will assume that we are using the GNU g++ compiler to compile a C++ program we have written contained within the file myprog.cpp. We will also assume that the machine on which you are trying to compile is a parallel machine with some version of MPI installed. You will need to contact your system administrator to find out the exact version of MPI that is available and the paths on your local architecture. In the following examples, the argument following the “-o” flag designates the file name to be used for the output. If no “-o” option is specified, most compilers default to using the name “a.out.” We now present several different programming scenarios:

  1. • No user-defined libraries or user-defined header files are needed, and no special system libraries (such as those associated with math.h) are needed other than the MPI libraries:

  2. g++ -o myprog myprog.cpp -lmpi

  3. • No user-defined libraries or user-defined header files are needed, but the special system library corresponding to math.h is needed along with the MPI libraries:

  4. g++ -o myprog myprog.cpp -lmath -lmpi

  5. • User-defined libraries, user-defined header files, and the special system library corresponding to math.h are needed along with the MPI libraries:

  6. g++ -o myprog myprog.cpp -I/users/kirby/includes -L/users/ kirby/libs -lSCmathlib -lmath -lmpi

The string following the flag designates the location of the user-defined header files to be included. The string following the “-L” flag designates the location of the user-defined libraries to be included. The string “-lSCmathlib” links the program with the user-defined library we created, and the string “-lmath” links the program with the system math library corresponding to math.h. The string “-lmpi” links the MPI libraries.

Type
Chapter
Information
Parallel Scientific Computing in C++ and MPI
A Seamless Approach to Parallel Algorithms and their Implementation
, pp. 581 - 606
Publisher: Cambridge University Press
Print publication year: 2003

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure [email protected] is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • MPI Basics
  • George Em Karniadakis, Brown University, Rhode Island, Robert M. Kirby II, University of Utah
  • Book: Parallel Scientific Computing in C++ and MPI
  • Online publication: 05 October 2013
  • Chapter DOI: https://doi.org/10.1017/CBO9780511812583.013
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • MPI Basics
  • George Em Karniadakis, Brown University, Rhode Island, Robert M. Kirby II, University of Utah
  • Book: Parallel Scientific Computing in C++ and MPI
  • Online publication: 05 October 2013
  • Chapter DOI: https://doi.org/10.1017/CBO9780511812583.013
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • MPI Basics
  • George Em Karniadakis, Brown University, Rhode Island, Robert M. Kirby II, University of Utah
  • Book: Parallel Scientific Computing in C++ and MPI
  • Online publication: 05 October 2013
  • Chapter DOI: https://doi.org/10.1017/CBO9780511812583.013
Available formats
×