Edexcel International Advanced Level Computer Science, point 11.1.4
Definition
Parallel processing means carrying out several calculations at the same time, using more than one processing unit. (Pipelining, 11.1.3, overlaps stages of one instruction stream. Parallel processing uses several processors or cores working simultaneously.)
Function and why needed
- Single processors have hit limits in clock speed (heat and power), so performance is now gained by doing more at once.
- It makes large problems feasible (simulation, graphics, AI, big data).
- It lets a computer run many programs at once smoothly.
Computer architectures are classified by how many instruction streams and data streams they handle (Flynn's taxonomy). Two are needed here: MIMD and SIMD.
a. Multicore processors: MIMD
MIMD: multiple instruction, multiple data.
- A multicore processor has several independent processing cores on one chip. Each core has its own control unit, ALU and registers (and usually its own L1 and L2 cache), with a shared L3 cache and main memory (1.1.6).
- Each core can run a different instruction stream on different data at the same time.
Operation
- The operating system assigns processes and threads to cores (scheduling, 1.2.3).
- A single program can be written to use several cores by splitting its work into threads (for example one for the interface, one for calculation).
- Cores share data through memory, and must be synchronised to avoid race conditions and deadlock.
Benefits
- Several programs or threads really run at once, so the system stays responsive.
- Faster for work that can be split up.
- More power-efficient than one very fast core.
- Doesn't need higher clock speeds.
Drawbacks
- Only helps if the software is written to use several cores (parallel code is harder to write and test).
- Not all tasks can be split: the sequential part limits the gain (Amdahl's law: if 20% of a task must run in sequence, the speed-up can never exceed 5 times, however many cores).
- Overhead: splitting work, sharing data and synchronising.
- Cores compete for memory and cache bandwidth.
- Cost and heat rise with the number of cores.
b. Graphics processing units (GPUs): SIMD
SIMD: single instruction, multiple data.
- A GPU has hundreds or thousands of simple cores, designed to apply the same instruction to many data items at once.
- Ideal for graphics: the same calculation (colour, lighting, transform) is done for millions of pixels or vertices.
Operation
- A control unit sends one instruction to many processing elements.
- Each element applies it to its own data item.
- The CPU sends work to the GPU and collects the results.
Uses beyond graphics
- Machine learning (matrix calculations), scientific simulation, video encoding, cryptocurrency mining, image processing, data analysis.
Benefits
- Enormous throughput for repetitive work on large data sets.
- Very efficient for suitable problems (performance per watt).
Drawbacks
- Not suited to tasks with complex decisions or branching (each core is simple).
- Data must be moved between CPU memory and GPU memory, which takes time.
- Needs special programming (CUDA, OpenCL, shaders).
- High power use and cost for powerful GPUs.
MIMD and SIMD compared
| Multicore CPU (MIMD) | GPU (SIMD) | |
|---|---|---|
| Instructions | Many different at once | One at a time, applied to many data items |
| Cores | Few (2 to 64), powerful and flexible | Very many, simple |
| Best for | General tasks: running programs, decisions, operating systems | Large, uniform, repetitive data tasks |
| Example | Running a browser, a game engine and music together | Rendering a 3D scene, training a neural network |
Identifying parallel processing
You may need to complete a diagram of parallel processing:
- Several cores, each with its own instruction stream: MIMD.
- One instruction broadcast to many processing elements, each with its own data: SIMD.
- A shared memory/cache that all connect to.
Worked example
Task: a program takes 10 s to run on one core. 8 s of that can be split perfectly across cores, and 2 s must run in sequence. Find the run time on 4 cores, and the speed-up.
- Parallel part: s.
- Sequential part: s.
- Total: s.
- Speed-up times (not 4, because of the sequential part).
- With unlimited cores, the time can't go below 2 s, so the speed-up is at most .
Which architecture? Running different parts of a program on different cores is MIMD. Applying the same filter to every pixel of an image is SIMD, and is better done on a GPU.
Exam tip: define MIMD (different instructions on different data, multicore CPU) and SIMD (one instruction on many data items, GPU). Link each to a suitable task. Mention that parallel speed-up is limited by the part that can't be split. For a diagram, show several instruction streams (MIMD) or one instruction broadcast to many data items (SIMD).
Check yourself
What does MIMD stand for, and which hardware uses it?
Multiple instruction, multiple data. A multicore processor, where each core can run different instructions on different data.
What does SIMD stand for, and which hardware uses it?
Single instruction, multiple data. A GPU, which applies one instruction to many data items at once.
Why are GPUs well suited to graphics?
The same calculation must be done on millions of pixels or vertices, which is ideal for applying one instruction to many data items simultaneously.
Why does adding more cores not always make a program proportionally faster?
Some parts must run in sequence, and splitting and combining work has overhead, so the sequential part limits the speed-up.
Give one drawback of multicore processors
Software must be written to use several cores, which is harder; not all tasks can be split; and cores compete for memory bandwidth.