Professional Documents
Culture Documents
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 1
@ 2004 Pearson Education Inc. All rights reserved.
Load balancing – used to distribute computations fairly across
processors in order to obtain the highest possible execution
speed.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 2
@ 2004 Pearson Education Inc. All rights reserved.
Load balancing
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 3
@ 2004 Pearson Education Inc. All rights reserved.
Static Load Balancing
Before the execution of any process. Some potential static load
balancing techniques:
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 5
@ 2004 Pearson Education Inc. All rights reserved.
Dynamic Load Balancing
All previous factors are taken into account by making the division
of load dependent upon the execution of the parts as they are
being executed.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 6
@ 2004 Pearson Education Inc. All rights reserved.
Processes and Processors
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 7
@ 2004 Pearson Education Inc. All rights reserved.
Dynamic Load Balancing
• Centralized
• Decentralized
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 8
@ 2004 Pearson Education Inc. All rights reserved.
Centralized dynamic load balancing
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 9
@ 2004 Pearson Education Inc. All rights reserved.
Centralized Dynamic Load Balancing
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 10
@ 2004 Pearson Education Inc. All rights reserved.
Centralized work pool
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 11
@ 2004 Pearson Education Inc. All rights reserved.
Termination
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 12
@ 2004 Pearson Education Inc. All rights reserved.
Decentralized Dynamic Load Balancing
Distributed Work Pool
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 13
@ 2004 Pearson Education Inc. All rights reserved.
Fully Distributed Work Pool
Processes to execute tasks from each other
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 14
@ 2004 Pearson Education Inc. All rights reserved.
Task Transfer Mechanisms
Receiver-Initiated Method
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 15
@ 2004 Pearson Education Inc. All rights reserved.
Sender-Initiated Method
Method has been shown to work well for light overall system
loads.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 16
@ 2004 Pearson Education Inc. All rights reserved.
Decentralized selection algorithm
requesting tasks between slaves
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 17
@ 2004 Pearson Education Inc. All rights reserved.
Process Selection
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 18
@ 2004 Pearson Education Inc. All rights reserved.
Load Balancing Using a Line Structure
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 19
@ 2004 Pearson Education Inc. All rights reserved.
Master process (P0) feeds queue with tasks at one end, and tasks
are shifted down queue.
When a process, Pi (1 <= i < n), detects a task at its input from
queue and process is idle, it takes task from queue.
Then tasks to left shuffle down queue so that space held by task is
filled. A new task is inserted into e left side end of queue.
Eventually, all processes have a task and queue filled with new
tasks. High- priority or larger tasks could be placed in queue first.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 20
@ 2004 Pearson Education Inc. All rights reserved.
Shifting Actions
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 21
@ 2004 Pearson Education Inc. All rights reserved.
Code Using Time Sharing Between
Communication and Computation
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 22
@ 2004 Pearson Education Inc. All rights reserved.
Process Pi (1 < i < n)
MPI
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 24
@ 2004 Pearson Education Inc. All rights reserved.
Load balancing using a
Tasks passed from node into one of the two nodes below it when
node buffer empty.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 25
@ 2004 Pearson Education Inc. All rights reserved.
Distributed Termination Detection Algorithms
Termination Conditions
At time t requires the following conditions to be satisfied:
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 26
@ 2004 Pearson Education Inc. All rights reserved.
One very general distributed termination
Algorithm
2. Active
Process that sent task to make a process enter the active state
becomes its “parent.”
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 27
@ 2004 Pearson Education Inc. All rights reserved.
When process receives a task, it immediately sends an
acknowledgment message, except if the process it receives the task
from is its parent process. Only sends an acknowledgment message
to its parent when it is ready to become inactive, i.e. when
• Its local termination condition exists (all tasks are completed, and
A process must become inactive before its parent process. When first
process becomes idle, the computation can terminate.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 28
@ 2004 Pearson Education Inc. All rights reserved.
Termination using message
acknowledgments
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 31
@ 2004 Pearson Education Inc. All rights reserved.
Process algorithm for local termination
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 32
@ 2004 Pearson Education Inc. All rights reserved.
Dual-Pass Ring Termination Algorithm
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 33
@ 2004 Pearson Education Inc. All rights reserved.
Algorithm is as follows, again starting at P0:
1.P0 becomes white when terminated and generates white token to P1.
2.Token passed through ring from one process to next when each
process has terminated, but color of token may be changed. If Pi
passes a task to Pj where j < i (i.e., before this process in the ring), it
becomes a black process; otherwise it is a white process. A black
process will color token black and pass it on. A white process will pass
on token in its original color (either black or white). After Pi passed on
a token, it becomes a white process. Pn-1 passes token to P0.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 35
@ 2004 Pearson Education Inc. All rights reserved.
Tree Algorithm
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 36
@ 2004 Pearson Education Inc. All rights reserved.
Fixed Energy Distributed Termination
Algorithm
• System starts with all energy being held by the root process.
• Root process passes out portions of energy with tasks to processes
making requests for tasks.
• If these processes receive requests for tasks, energy divided further
and passed to these processes.
• When a process becomes idle, it passes energy it holds back before
requesting a new task.
• A process will not hand back its energy until all energy it handed out
returned and combined to total energy held.
• When all energy returned to root and root becomes idle, all
processes must be idle and computation can terminate.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 37
@ 2004 Pearson Education Inc. All rights reserved.
Fixed Energy Distributed Termination
Algorithm
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 38
@ 2004 Pearson Education Inc. All rights reserved.
Load balancing/termination detection
Example
Shortest Path Problem
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 39
@ 2004 Pearson Education Inc. All rights reserved.
The interconnected nodes can be described by a graph.
The nodes are called vertices, and the links are called edges.
If the edges have implied directions (that is, an edge can only
be traversed in one direction, the graph is a directed graph.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 40
@ 2004 Pearson Education Inc. All rights reserved.
Graph could be used to find solution to many different problems;
eg:
1. Shortest distance between two towns or other points on a map,
where the weights represent distance
2. Quickest route to travel, where the weights represent time (the
quickest route may not be the shortest route if different modes
of travel are available; for example, flying to certain towns)
3. Least expensive way to travel by air, where the weights
represent the cost of the flights between cities (the vertices)
4. Best way to climb a mountain given a terrain map with contours
5. Best route through a computer network for minimum message
delay (the vertices represent computers, and the weights
represent the delay between two computers)
6. Most efficient manufacturing system, where the weights
represent hours of work
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 42
@ 2004 Pearson Education Inc. All rights reserved.
Graph of mountain climb
The effort in one direction may be different from the effort in the
opposite direction (downhill instead of uphill!). (directed graph)
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 43
@ 2004 Pearson Education Inc. All rights reserved.
Graph Representation
Two basic ways that a graph can be represented in a program:
Adjacency matrix used for dense graphs. Adjacency list used for
sparse graphs.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 44
@ 2004 Pearson Education Inc. All rights reserved.
Representing the graph
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 45
@ 2004 Pearson Education Inc. All rights reserved.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 46
@ 2004 Pearson Education Inc. All rights reserved.
Searching a Graph
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 47
@ 2004 Pearson Education Inc. All rights reserved.
Moore’s Algorithm
Find the distance to vertex j through vertex i and compare with the
current minimum distance to vertex j. Change the minimum
distance if the distance through vertex i is shorter. If di is the
current minimum distance from the source vertex to vertex i and
wi,j is the weight of the edge from vertex i to vertex j:
dj = min(dj, di + wi,j)
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 48
@ 2004 Pearson Education Inc. All rights reserved.
Moore’s Shortest-path Algorithm
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 49
@ 2004 Pearson Education Inc. All rights reserved.
Date Structures
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 50
@ 2004 Pearson Education Inc. All rights reserved.
Code
Suppose w[i][j] holds the weight of the edge from vertex i and
vertex j (infinity if no edge). The code could be of the form
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 51
@ 2004 Pearson Education Inc. All rights reserved.
Stages in Searching a Graph
Example
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 52
@ 2004 Pearson Education Inc. All rights reserved.
After examining A to
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 53
@ 2004 Pearson Education Inc. All rights reserved.
After examining B to F, E, D, and C::
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 54
@ 2004 Pearson Education Inc. All rights reserved.
After examining E to F
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 55
@ 2004 Pearson Education Inc. All rights reserved.
After examining D to E:
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 56
@ 2004 Pearson Education Inc. All rights reserved.
After examining C to D: No changes.
After examining E (again) to F :
Let next_vertex() return the next vertex from the vertex queue or
no_vertex if none.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 58
@ 2004 Pearson Education Inc. All rights reserved.
Parallel Implementations
Each slave takes vertices from vertex queue and returns new
vertices.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 59
@ 2004 Pearson Education Inc. All rights reserved.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 60
@ 2004 Pearson Education Inc. All rights reserved.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 61
@ 2004 Pearson Education Inc. All rights reserved.
Decentralized Work Pool
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 62
@ 2004 Pearson Education Inc. All rights reserved.
Search Algorithm
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 64
@ 2004 Pearson Education Inc. All rights reserved.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 65
@ 2004 Pearson Education Inc. All rights reserved.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 66
@ 2004 Pearson Education Inc. All rights reserved.
Mechanism necessary to repeat actions and terminate when all
processes idle - must cope with messages in transit.
Simplest solution
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. Allen, 67
@ 2004 Pearson Education Inc. All rights reserved.