Docsity

Parallel computing notes, Lecture notes of Parallel Computing and Programming

Partial preview of the text

Download Parallel computing notes and more Lecture notes Parallel Computing and Programming in PDF only on Docsity!

Module 3 – Principles of

Parallel Algorithm Design

Parallel Computing

1

Objectives

  • To identify the suitable problem for parallel solutions
  • To differentiates the decomposition techniques in parallel computing
  • To differentiates the mapping techniques in parallel computing
  • To differentiates the parallel algorithm design models

2

First step :Understand the Problem and the

Program

  • Undoubtedly, the first step in developing parallel software is to first understand the problem that you wish

to solve in parallel. If you are starting with a serial program, this necessitates understanding the existing

code also.

  • Before spending time in an attempt to develop a parallel solution for a problem, determine whether or not

the problem is one that can actually be parallelized.

  • Example of an easy to parallelize problem:
  • This problem is able to be solved in parallel. Each of the molecular conformations is independently

determinable. The calculation of the minimum energy conformation is also a parallelizable problem.

  • Example of a problem with little-to-no parallelism:
  • The calculation of the F(n) value uses those of both F(n-1) and F(n-2), which must be computed first.

4

Calculation of the Fibonacci series
by use of the formula:
F(n) = F(n-1) + F(n-2)
Calculate the potential energy for each of
several thousand independent
conformations of a molecule. When done,
find the minimum energy conformation.

Identify Potential Areas to Parallel

  • Identify the program's hotspots:
    • Know where most of the real work is being done. The majority of scientific and technical programs usually

accomplish most of their work in a few places.

  • Profilers and performance analysis tools can help here
  • Focus on parallelizing the hotspots and ignore those sections of the program that account for little CPU usage.
  • Identify bottlenecks in the program:
  • Are there areas that are disproportionately slow, or cause parallelizable work to halt or be deferred? For

example, I/O is usually something that slows a program down.

  • May be possible to restructure the program or use a different algorithm to reduce or eliminate unnecessary

slow areas

  • Identify inhibitors to parallelism
    • One common class of inhibitor is data dependence, as demonstrated by the Fibonacci sequence above.
  • Investigate other algorithms if possible
    • This may be the single most important consideration when designing a parallel application.
    • Take advantage of optimized third party parallel software and highly optimized math libraries available from

leading vendors (IBM's ESSL, Intel's MKL, AMD's AMCL, etc.).

5

Decomposing Problems to Tasks

  • Divide work into tasks that can be executed concurrently
  • Many different decompositions possible for any computation
  • Tasks may be same, different, or even indeterminate sizes
  • Tasks may be independent or have non-trivial order
  • Conceptualize tasks and ordering as task dependency directed graph

7

node = task

edge = control dependence

Graphs for Task Decomposition

  • A decomposition can be illustrated in the form of a directed graph

with nodes corresponding to tasks and edges indicating that the

result of one task is required for processing the next. Such a graph is

called a task dependency graph.

  • The graph of tasks (nodes) and their interactions/data exchange

(edges) is referred to as a task interaction graph.

  • Note that task interaction graphs represent data dependencies,

whereas task dependency graphs represent control dependencies.

8

Example: Multiplying a *Dense Matrix with a

Vector

Computation of each element of output vector y is independent of other elements. Based on this, a dense

matrix-vector product can be decomposed into n tasks. The figure highlights the portion of the matrix and

vector accessed by Task 1.

Observations: While tasks share data (namely, the vector b ), they do not have any control

dependencies - i.e., no task needs to wait for the (partial) completion of any other. All tasks are of

the same size in terms of number of operations. Is this the maximum number of tasks we could

decompose this problem into?

* Dense matrix – if all or most of

the elements are nonzero

10

Example: Database Query Processing

  • Consider the execution of the query:

MODEL = ``CIVIC'' AND YEAR = 2001 AND

(COLOR = GREEN'' OR COLOR =WHITE)

on the following database:

ID# Model Year Color Dealer Price

4523 Civic 2002 Blue MN $18,

3476 Corolla 1999 White IL $15,

7623 Camry 2001 Green NY $21,

9834 Prius 2001 Green CA $18,

6734 Civic 2001 White OR $17,

5342 Altima 2001 Green FL $19,

3845 Maxima 2001 Blue NY $22,

8354 Accord 2000 Green VT $18,

4395 Civic 2001 Red CA $17,

7352 Civic 2002 Red WA $18,

  • The execution of the query can be divided into subtasks in various ways.

Example: Database Query Processing

  • Alternate task decomposition for query

MODEL = "CIVIC" AND YEAR = 2001 AND (COLOR = "GREEN" OR COLOR = "WHITE")

Different decompositions may yield different parallelism and different amounts of work

13

ID# Model Year Color Dealer Price

4523 Civic 2002 Blue MN $18,

3476 Corolla 1999 White IL $15,

7623 Camry 2001 Green NY $21,

9834 Prius 2001 Green CA $18,

6734 Civic 2001 White OR $17,

5342 Altima 2001 Green FL $19,

3845 Maxima 2001 Blue NY $22,

8354 Accord 2000 Green VT $18,

4395 Civic 2001 Red CA $17,

7352 Civic 2002 Red WA $18,

ID# Model

4523

6734

4395

7352

Civic

Civic

Civic

Civic

ID# Year

7623

9834

6734

5342

3845

4395

2001

2001

2001

2001

2001

2001

ID# Color

3476

6734

White

White

ID# Color

7623

9834

5342

8354

Green

Green

Green

Green

ID# Color

3476

6734

7623

9834

5342

8354

White

White

Green

Green

Green

Green

ID# Year Color

7623

9834

6734

5342

2001

2001

2001

2001

Green

Green

White

Green

ID# Model Year Color

6734 Civic 2001 White

Granularity of Task Decompositions

  • Granularity = task size
    • The number of tasks into which a

problem is decomposed determines

its granularity.

  • Fine-grain = decompose to large

number of tasks

  • Coarse-grain = decompose to small

number of tasks

  • Granularity examples for dense

matrix-vector multiply

  • fine-grain: each task represents an

individual element in y

  • coarser-grain: each task computes 3

elements in y

14

Degrees of concurrency

  • Maximum degree of concurrency
    • the maximum number of tasks that can be executed in parallel
  • Average degree of concurrency
    • the average number of tasks that can be executed in parallel
    • more useful measure

16

Critical Path Length

  • A directed path in the task dependency graph represents a sequence

of tasks that must be processed one after the other.

  • The longest such path determines the shortest time in which the

program can be executed in parallel.

  • The length of the longest path in a task dependency graph is called

the critical path length.

17

Critical Path Length

Decomposition → Task Dependency Graph

  • Start node: Task 1, Task 2, Task 3, Task 4
  • Finish node: Task 7
  • Critical path: Task 1, Task 5, Task 8 and Task 2, Task 5, Task 8
  • Critical path length: 10+10+8 = 28
    • Average degree of concurrency = (10+10+10+10+10+6+8)/

= 64/28 = 2.

  • Maximum degree of concurrency = 4 (Task 1, Task 2, Task 3,

Task 4)

19

Task 1
Task 2
Task 3
Task 4
Task 6
Task 5

Task 7 8

MODEL = "CIVIC" AND YEAR = 2001 AND

(COLOR = "GREEN" OR COLOR = "WHITE")

Critical Path Length

Decomposition → Task Dependency Graph

  • Start node: Task 1, Task 2, Task 3, Task 4
  • Finish node: Task 7
  • Critical path: Task 3, Task 5, Task 6, Task 7 and Task 3, Task 5, Task 6, Task 7
  • Critical path length: 10+6+12+8 = 36
    • Average degree of concurrency = (10+10+10+10+6+12+8)/36 = 66/36 =
  • Maximum degree of concurrency = 4 (Task 1, Task 2, Task 3, Task 4)

20

Task 1
Task 2
Task 3
Task 4
Task 5
Task 6
Task 7

MODEL = "CIVIC" AND YEAR = 2001 AND

(COLOR = "GREEN" OR COLOR = "WHITE")