Docsity

Concurrency Decomposition - Parallel Computing - Lecture Slides, Slides of Parallel Computing and Programming

Partial preview of the text

Download Concurrency Decomposition - Parallel Computing - Lecture Slides and more Slides Parallel Computing and Programming in PDF only on Docsity!

Principles of Parallel

Algorithm Design:

Concurrency and Decomposition

2

Parallel Algorithm

Recipe to solve a problem on multiple processors

Typical steps for constructing a parallel algorithm

—identify what pieces of work can be performed concurrently —partition concurrent work onto independent processors —distribute a program’s input, output, and intermediate data —coordinate accesses to shared data: avoid conflicts —ensure proper order of work using synchronization

Why “typical”? Some of the steps may be omitted.

—if data is in shared memory, distributing it may be unnecessary —if using message passing, there may not be shared data —the mapping of work to processors can be done statically by the programmer or dynamically by the runtime

4

Decomposing Work for Parallel Execution

  • 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 DAG —node = task —edge = control dependence T T T T T T T T T T T T T T T T T

5

Example: Dense Matrix-Vector Multiplication

  • Computing each element of output vector y is independent
  • Easy to decompose dense matrix-vector product into tasks —one per element in y
  • Observations —task size is uniform —no control dependences between tasks —tasks share b A b y 2 n Task 1 2 n 1

7

Example: Database Query Processing

  • Task: compute set of elements that satisfy a predicate — task result = table of entries that satisfy the predicate
  • Edge: output of one task serves as input to the next MODEL = CIVIC'' AND YEAR = 2001 AND (COLOR =GREEN'' OR COLOR = ``WHITE)

8

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

10

Degree of Concurrency

  • Definition: number of tasks that can execute in parallel
  • May change during program execution
  • Metrics — maximum degree of concurrency - largest # concurrent tasks at any point in the execution — average degree of concurrency - average number of tasks that can be processed in parallel
  • Degree of concurrency vs. task granularity —inverse relationship

11

Example: Dense Matrix-Vector Multiplication

  • Computing each element of output vector y is independent
  • Easy to decompose dense matrix-vector product into tasks —one per element in y
  • Observations —task size is uniform —no control dependences between tasks —tasks share b

Question: Is n the maximum number of tasks possible?

A b y 2 n Task 1 2 n 1

13

Critical Path Length

Examples: database query task dependency graphs Questions: What are the tasks on the critical path for each dependency graph? What is the shortest parallel execution time for each decomposition? How many processors are needed to achieve the minimum time? What is the maximum degree of concurrency? What is the average parallelism?

14

Critical Path Length

Example: dependency graph for dense-matrix vector product

Questions: What does a task dependency graph look like for DMVP? What is the shortest parallel execution time for the graph? How many processors are needed to achieve the minimum time? What is the maximum degree of concurrency? What is the average parallelism? A b y 2 n Task 1 2 n 1

16

Task Interaction Graphs

  • Tasks generally exchange data with others —example: dense matrix-vector multiply - if vector b is not replicated in all tasks, tasks will have to communicate elements of b
  • Task interaction graph —node = task —edge = interaction or data exchange
  • Task interaction graphs vs. task dependency graphs — task interaction graphs represent data dependences — task dependency graphs represent control dependences

17

Task Interaction Graph Example

Sparse matrix-vector multiplication

  • Computation of each result element = independent task
  • Only non-zero elements of sparse matrix^ A^ participate
  • If, b is partitioned among tasks^ … —structure of the task interaction graph = graph of the matrix A (i.e. the graph for which A represents the adjacency structure)

19

Processes and Mapping

  • Generally —# of tasks > # processing elements available —parallel algorithm must map tasks to processes
  • Why processes rather than processors? —aggregate tasks into processes - process = processing or computing agent that performs work - assign collection of tasks and associated data to a process —operating system maps processes to physical processors - some operating systems allow one to specify a binding between processes and processors

20

Processes and Mapping

  • Mapping tasks to processes is critical for parallel performance
  • On what basis should one choose mappings? —using task dependency graphs - schedule independent tasks on separate processes minimum idling optimal load balance —using task interaction graphs - want processes to have minimum interaction with one another minimum communication