# MPI Programming Exemplars

Initial Publication Date: September 20, 2017

## Summary

Four examples of using MPI to build distributed programming solutions to classical problems:

- Estimating Pi using a Monte Carlo method
- Estimating an integral using the trapezoidal rule
- Odd - Even transposition sort
- Merge sort

## Learning Goals

- To study example problem solutions that use message passing.
- To study example problems that employ the reduction pattern.
- To see examples of how to time MPI programs and determine their speedup and efficiency compared to sequential solution.

## Context for Use

Any one or all of these examples could be used after students have learned basic message passing patterns and have a brief familiarity with MPI programming. Students can run these examples and use a spreadsheet (linked below) to determine the speedup and efficiency of these programs for varying numbers of processes and problem sizes.

## Description and Teaching Materials

The descriptions of the problems and links to the code are in this web page:

We suggest having students copy this Google spreadsheet and fill in the times the get with different problems sizes and numbers of processors.

As an alternative, you could use a paper version of this Google doc to have students fill in their times and draw the speedup and efficiency curves.

## Teaching Notes and Tips

Any one of these works as an interesting example. The sorts ore more complex that the monte carlo and integration examples.

Comment? Start the discussion about

*MPI Programming Exemplars*