Download Multiprocessor Programming - Parallel Processing Architectures - Lecture Slides and more Slides Parallel Computing and Programming in PDF only on Docsity!
Multiprocessor Programming
Ref: Book by Ian Foster
- Partitioning. The computation that is to be performed and the data
operated on by this computation are decomposed into small tasks.
Practical issues such as the number of processors in the target
computer are ignored, and attention is focused on recognizing
opportunities for parallel execution.
- Communication. The communication required to coordinate task
execution is determined, and appropriate communication structures
and algorithms are defined.
- Agglomeration. The task and communication structures defined in the
first two stages of a design are evaluated with respect to performance
requirements and implementation costs. If necessary, tasks are
combined into larger tasks to improve performance or to reduce
development costs.
- Mapping. Each task is assigned to a processor in a manner that
attempts to satisfy the competing goals of maximizing processor
utilization and minimizing communication costs. Mapping can be
specified statically or determined at runtime by load-balancing
algorithms.
Program Design Methodology
Domain Decomposition
- In the domain decomposition approach to problem partitioning, we seek first to decompose the data associated with a problem. If possible, we divide these data into small pieces of approximately equal size. Next, we partition the computation that is to be performed, typically by associating each operation with the data on which it operates. This partitioning yields a number of tasks, each comprising some data and a set of operations on that data. An operation may require data from several tasks. In this case, communication is required to move data between tasks. This requirement is addressed in the next phase of the design process.
- The data that are decomposed may be the input to the program, the output computed by the program, or intermediate values maintained by the program. Different partitions may be possible, based on different data structures. Good rules of thumb are to focus first on the largest data structure or on the data structure that is accessed most frequently. Different phases of the computation may operate on different data structures or demand different decompositions for the same data structures. In this case, we treat each phase separately and then determine how the decompositions and parallel algorithms developed for each phase fit together. The issues that arise in this situation are discussed in Chapter 4.
- Figure 2.2 illustrates domain decomposition in a simple problem involving a three- dimensional grid. (This grid could represent the state of the atmosphere in a weather model, or a three-dimensional space in an image-processing problem.) Computation is performed repeatedly on each grid point. Decompositions in the x , y , and/or z dimensions are possible. In the early stages of a design, we favor the most aggressive decomposition possible, which in this case defines one task for each grid point. Each task maintains as its state the various values associated with its grid point and is responsible for the computation required to update that state.
Domain Decomposition
- Figure 2.2: Domain decompositions for a problem involving a three-dimensional
grid. One-, two-, and three-dimensional decompositions are possible; in each
case, data associated with a single task are shaded. A three-dimensional
decomposition offers the greatest flexibility and is adopted in the early stages of
a design.
- Figure 2.3: Functional decomposition in a computer model of
climate. Each model component can be thought of as a separate
task, to be parallelized by domain decomposition. Arrows
represent exchanges of data between components during
computation: the atmosphere model generates wind velocity
data that are used by the ocean model, the ocean model
generates sea surface temperature data that are used by the
atmosphere model, and so on.
Communication
- The tasks generated by a partition are intended to execute concurrently but
cannot, in general, execute independently. The computation to be performed in
one task will typically require data associated with another task. Data must then
be transferred between tasks so as to allow computation to proceed. This
information flow is specified in the communication phase of a design.
- In the following discussion, we use a variety of examples to show how
communication requirements are identified and how channel structures and
communication operations are introduced to satisfy these requirements. For
clarity in exposition, we categorize communication patterns along four loosely
orthogonal axes: local/global, structured/unstructured, static/dynamic, and
synchronous/asynchronous.
- In local communication, each task communicates with a small set of other tasks (its ``neighbors''); in contrast, global communication requires each task to communicate with many tasks.
- In structured communication, a task and its neighbors form a regular structure, such as a tree or grid; in contrast, unstructured communication networks may be arbitrary graphs.
- In static communication, the identity of communication partners does not change over time; in contrast, the identity of communication partners in dynamic communication structures may be determined by data computed at runtime and may be highly variable.
- In synchronous communication, producers and consumers execute in a coordinated fashion, with producer/consumer pairs cooperating in data transfer operations; in contrast, asynchronous communication may require that a consumer obtain data without the cooperation of the producer.
Global Communication
- A global communication operation is one in which many tasks must participate. When such operations are implemented, it may not be sufficient simply to identify individual producer/consumer pairs. Such an approach may result in too many communications or may restrict opportunities for concurrent execution. For example, consider the problem of performing a parallel reduction operation, that is, an operation that reduces N values distributed over N tasks using a commutative associative operator such as addition:
Figure 2.6: A centralized summation algorithm that uses a central manager task (S) to sum N numbers distributed among N tasks. Here, N=8 , and each of the 8 channels is labeled with the number of the step in which they are used.
Distributing Communication and Computation
- We first consider the problem of distributing the computation and communication
associated with the summation. We can distribute the summation of the N numbers by making each task i , 0<i<N-1 , compute the sum:
Figure 2.7: A summation algorithm that connects N tasks in an array in order to sum N numbers distributed among these tasks. Each channel is labeled with the number of the step in which it is used and the value that is communicated on it.
Unstructured and Dynamic Communication
- Figure 2.9: Example of a problem requiring unstructured communication. In this finite element mesh generated for an assembly part, each vertex is a grid point. An edge connecting two vertices represents a data dependency that will require communication if the vertices are located in different tasks. Notice that different vertices have varying numbers of neighbors. (Image courtesy of M. S. Shephard.)
Asynchronous Communication
- Figure 2.10: Using separate ``data tasks'' to service read and write requests on a
distributed data structure. In this figure, four computation tasks (C) generate
read and write requests to eight data items distributed among four data tasks
(D). Solid lines represent requests; dashed lines represent replies. One compute
task and one data task could be placed on each of four processors so as to
distribute computation and data equitably.
Increasing Granularity
- In the partitioning phase of the design process, our efforts are focused on
defining as many tasks as possible. This is a useful discipline because it forces us
to consider a wide range of opportunities for parallel execution. We note,
however, that defining a large number of fine-grained tasks does not necessarily
produce an efficient parallel algorithm.
- One critical issue influencing parallel performance is communication costs. On
most parallel computers, we have to stop computing in order to send and
receive messages. Because we typically would rather be computing, we can
improve performance by reducing the amount of time spent communicating.
Clearly, this performance improvement can be achieved by sending less data.
Perhaps less obviously, it can also be achieved by using fewer messages, even if
we send the same amount of data. This is because each communication incurs
not only a cost proportional to the amount of data transferred but also a fixed
startup cost.
Figure 2.12: Effect of increased granularity on communication costs in a two-dimensional finite difference problem with a five-point stencil. The figure shows fine- and coarse-grained two-dimensional partitions of this problem. In each case, a single task is exploded to show its outgoing messages (dark shading) and incoming messages (light shading). In (a), a computation on an 8x8 grid is partitioned into 64 tasks, each responsible for a single point, while in (b) the same computation is partitioned into 2x2=4 tasks, each responsible for 16 points. In (a), 64x4=256 communications are required, 4 per task; these transfer a total of 256 data values. In (b), only 4x4=16 communications are required, and only 16x4=64 data values are transferred.
Mapping Example
- Figure 2.16: Mapping in a grid problem in which each task performs the
same amount of computation and communicates only with its four
neighbors. The heavy dashed lines delineate processor boundaries. The
grid and associated computation is partitioned to give each processor
the same amount of computation and to minimize off-processor
communication.
Load-Balancing Algorithms
- A wide variety of both general-purpose and application-specific
load-balancing techniques have been proposed for use in
parallel algorithms based on domain decomposition techniques.
We review several representative approaches here (the chapter
notes provide references to other methods), namely recursive
bisection methods, local algorithms, probabilistic methods, and
cyclic mappings. These techniques are all intended to
agglomerate fine-grained tasks defined in an initial partition to
yield one coarse-grained task per processor. Alternatively, we
can think of them as partitioning our computational domain to
yield one sub-domain for each processor. For this reason, they
are often referred to as partitioning algorithms.