Click here to go to the TACC Home Page
Preface

This document is a primer for those who wish to learn the basics of using the Message-Passing Interface (MPI) library through simple examples of C code. It covers the basics of message-passing in a parallel application but does not deal with the more fundamental concept of educing the parallelism within a problem. A complete description of MPI can be found in "MPI: A Message-Passing Interface Standard" and "MPI-2: Extensions to the Message-Passing Interface" from the Argonne National Laboratory. The complete descriptions of the proposed MPI standard are available as compressed Postscript files that you can download from the ANL site using your browser and print on a Postscript printer.

   Message-Passing Interface

Certain words in this document are defined and used with only one meaning. Be advised: the use and definition may vary in other sources. For instance, the word "buffer" in the MPI standard can refer to the data the user manipulates [e.g. double a[10]; ... call MPI_Send(a...)] or to a copy of the data that MPI_Send uses to store (buffer) the data before returning control back to the calling program. In this document, only the latter definition is used. Furthermore, the word "blocking" in the standard is used generically in the description of the operation of the MPI_Send function, yet it also means that a call waits for some condition to occur before returning. This condition might be any one of:

  • freedom to write in a data location, or
  • the posting of a corresponding receive for a sent message, or
  • the completion of another subroutine (such as a receive).

Some people might be inclined to believe that blocking should refer to a more symmetric meaning: that a paired send/receive has completed. To minimize confusion, use of the word "block" is avoided and the more descriptive phrase "wait for an impending action or condition" is used here.

In the examples, generally all variables that begin with characters i-n are ints, all others are usually doubles.

Exception: character and logical variables begin with ch and lo, respectively. I do this to keep the C examples in this text similar to the Fortran examples in the Fortran Introduction to MPI

MPI constants and data types are declared in the mpif.h header file. To make the syntax examples complete a description table immediately follows the syntax. The data type of each parameter is included in the description. Function arguments labeled [OUT] return a value in the variable while those labeled [IN] must have an input value specified for them.

It is best to read this introduction to MPI from start to finish. Each section builds on information from the previous section, and guides you through a logical progression of information needed to use MPI. Work as you read by opening a window to a system that has MPI installed and use CPR (Copy, Paste, Run) on the examples to see how each one works.