Parallel Programming in OpenMP

The previous chapters in this book have concentrated on explaining the OpenMP programming language. By now, you should be proficient in writing parallel programs using the different constructs available in the language. This chapter takes a moment to step back and ask why we would want to write a parallel program. Writing a program in OpenMP does not offer esthetic advantages over writing serial programs. It does not provide algorithmic capabilities that are not already available in straight Fortran, C, or C++. The reason to program in OpenMP is performance. We want to utilize the power of multiple processors to solve problems more quickly.
Some problems lend themselves naturally to a programming style that will run efficiently on multiple processors. Assuming access to a good compiler and sufficiently large data sets, it is difficult, for example, to program a matrix multiply routine that will not run well in parallel. On the other hand, other problems are easy to code in ways that will run even slower in parallel than the original serial code. Modern machines are quite complicated, and parallel programming adds an extra dimension of complexity to coding.
In this chapter, we attempt to give an overview of factors that affect parallel performance in general and also an overview of modern machine characteristics that affect parallelism. The variety of parallel machines developed over the years is quite large. The performance characteristics of a vector machine such as the SGI Cray T90 is very different from the performance...