Parallel Programming Models (High level)

Parallelism

Average num. units that can be performed in parallel per unit time.

Parallelism constraints:

  1. Data/control dependencies
  2. Runtime environment
    1. e.g. Memory contention: when multiple cores issue memory request to the same block at the same time.

Thus

\[\text{Work} = \text{tasks} + \text{dependencies}\]

memory too busy, difficult to answer and transfer data

Data parallelism

Partition data used amongst the processing units, which carries out similar ops on its chunk of data

Loop parallelism

OpenMP

SPMD:

Task parallelism

totally different tasks sare executed in parallel

Partition work into tasks: Topological sort

Decompose so that no need for a sequential algo

Task Dependency Graph (a DAG)

TAs grading qns 1 to 5:

if processor handle same chunk of data: data parallelism

mapping: map to which cores?

Overheads

Data Parallel

Message passing

Parallel Programaming Models

Fine/Coarse grain

Foster’s Desing Methodology

  1. Partitioning
    1. Data/Computation centric $\Leftrightarrow$ Data/Task parallelism
  2. Comms
  3. Agglomeration
  4. Mapping

Partitioning:

Communication:

Agglomeration: Combining tasks into larger tasks

Mapping: 2 diverging goals

Automatic parallelization:

Functional Programming:

Models of Coordination

Program Parallelization

#pragma omp parallel for shared (a, b, result)
  private (i, j, k)

for (i = 0; i < size; i++)
  for (j = 0; j < size; j++)
    for (k = 0; k < size; k++)

Parallel Programming Patterns

OpenMP

Start with a parallelizable algorithm (SPMD model)

Then annotate the code with parallelization and syncrhonization directives (pragma)