15.1 Overview
Algorithm design is a crucial part of
the development process for parallel programs. In many cases, the
best serial algorithm can be easily parallelized, while in other
cases a fundamentally different algorithm will be needed. In this
chapter, we'll focus on parallelizing a serial
algorithm. Keep in mind that this may not provide the best solution
to your problem. There are a number of very detailed books on
parallel algorithm design, parallel programming in general, and on
MPI programming in particular. Most have extensive examples. Whenever
possible, you should look for an existing, optimized solution rather
than trying to develop your own. This is particularly true when faced
with a problem that requires an algorithm that is fundamentally
different from the serial algorithm you might use.
Don't reinvent the wheel.
The optimal algorithm will depend on the underlying architecture that
is used. For parallel programming, most algorithms will be optimized
for either a shared memory architecture-a scheme where global
memory is shared among all processes-or a message passing
architecture. If you are looking at existing algorithms, be sure to
take this into account.
Since this is a book about clusters, we will be looking at parallel
program design from the perspective of message passing. This
isn't always the best approach for every problem,
but it is the most common for use with a cluster.
Parallel algorithms are more
complicated than serial algorithms. While a serial algorithm is just
a sequence of steps, a parallel algorithm must also specify which
steps can be executed in parallel and provide adequate control
mechanisms to describe the concurrency.
The process of parallel algorithm design can be broken into several
steps. First, we must identify the portions of the code that can, at
least potentially, be executed safely in parallel. Next, we must
devise a plan for mapping those parallel portions into individual
processes (or onto individual processors). After that, we need to
address the distribution of data as well as the collection and
consolidation of results. This step also includes addressing any
synchronization issues that might arise, which must be done so that
we can, finally, synchronize the execution of the processes.
|