Repository navigation
Computer Architecture 08 multicore
Relevant source files
The following references were used as context for generating this wiki page:
- Wikipedia: Multi-core processor
- Wikipedia: Amdahl's law
- Wikipedia: Non-uniform memory access
- Wikipedia: Flynn's taxonomy
- Book: Hennessy and Patterson, Computer Architecture: A Quantitative Approach, chapter 5
A multicore processor puts several complete cores on one chip. Each core runs its own stream of instructions, so a program that splits its work into threads can finish sooner. Multicore became the main way to get more performance once clock speeds stopped rising (Overview). This page explains how the cores are connected, how much speedup to expect, and what slows multicore programs down.
Numbers and chip layouts on this page are illustrative.
This page covers why chips went multicore, Flynn's classification, shared-memory organisation (private and shared caches, interconnect), heterogeneous big.LITTLE designs, Amdahl's and Gustafson's laws, NUMA, and the costs of synchronisation. Keeping the cores' caches consistent is on Caches and Coherence; the order in which they see each other's writes is on Memory and Ordering.
| Office | Multicore chip |
|---|---|
| One worker, one desk | One core with its L1 cache |
| Hiring more workers | Adding cores |
| A shared filing cabinet | Shared L3 cache and main memory |
| Workers must agree who edits which file | Coherence and locks |
| A task only one person can do (signing the final report) | The serial part of a program |
| More workers than the hallway can handle | Memory bandwidth limits |
Ten workers can finish a big pile of independent forms ten times faster. They can't make one person's signature faster, and they slow down if they all queue at the same cabinet.
flowchart TD
A["Need more performance"] --> B{"Raise clock?"}
B -->|"Power grows steeply with frequency and voltage"| X["Too hot"]
A --> C{"Wider single core?"}
C -->|"ILP wall: little extra gain"| Y["Diminishing returns"]
A --> D["Put 2, 4, 8... cores on the chip<br/>each at a sensible clock"]
D --> E["More total throughput<br/>if software uses threads"]
Two cores at moderate frequency usually give more total work per watt than one core pushed to a very high frequency, but only if the software runs in parallel.
Flynn's 1966 classification counts instruction streams and data streams:
| Single data | Multiple data | |
|---|---|---|
| Single instruction | SISD: a classic single core | SIMD: vector units, GPUs (SIMD and GPUs) |
| Multiple instruction | MISD: rare | MIMD: multicore, clusters (this page) |
Sources: Wikipedia: Flynn's taxonomy
flowchart TB
subgraph Chip["Multicore chip (illustrative)"]
direction TB
subgraph C0["Core 0"]
P0["Pipeline"] --- L10["L1 I + L1 D"]
L10 --- L20["Private L2"]
end
subgraph C1["Core 1"]
P1["Pipeline"] --- L11["L1 I + L1 D"]
L11 --- L21["Private L2"]
end
subgraph C2["Core 2"]
P2["Pipeline"] --- L12["L1 I + L1 D"]
L12 --- L22["Private L2"]
end
L20 --- IC["Interconnect<br/>(coherent: ring, mesh or crossbar)"]
L21 --- IC
L22 --- IC
IC --- L3["Shared L3 / system level cache"]
end
L3 --- MC["Memory controller"] --- DRAM["DRAM"]
| Part | Shared or private | Role |
|---|---|---|
| Pipeline, registers | Private | Runs one thread (or more, see Multithreading) |
| L1, often L2 | Private | Fast, close data |
| L3 / system level cache | Shared | Catches data used by several cores; reduces DRAM traffic |
| Interconnect | Shared | Carries requests and coherence messages between caches |
| Memory controller, DRAM | Shared | Total bandwidth is split among all cores |
All cores see one shared address space: this is shared-memory multiprocessing (SMP). Threads communicate simply by reading and writing memory, and the hardware keeps caches coherent.
Sources: Wikipedia: Multi-core processor
Phones and laptops often mix core types on one chip. Arm calls this big.LITTLE, and later DynamIQ, which allows mixed core types in one cluster.
| Core type | Design | Used for |
|---|---|---|
| Big (performance) | Wide, out-of-order, large caches, high clock | Bursts: launching an app, a game frame |
| Little (efficiency) | Narrow, often in-order, small | Background work, email sync, music |
flowchart LR
T["Thread becomes runnable"] --> S{"Scheduler: how demanding?"}
S -->|"Light / background"| L["Little core<br/>low power"]
S -->|"Heavy / interactive"| B["Big core<br/>high performance"]
L -->|"load grows"| B
B -->|"load drops"| L
All cores implement the same architecture, so the operating system can move a thread between them at any time.
If a fraction p of a program can run in parallel on N cores and the rest (1 − p) is serial:
Speedup(N) = 1 / ((1 − p) + p / N)
| Parallel fraction p | 2 cores | 4 cores | 8 cores | 64 cores | Limit (∞ cores) |
|---|---|---|---|---|---|
| 50% | 1.33 | 1.60 | 1.78 | 1.97 | 2 |
| 90% | 1.82 | 3.08 | 4.71 | 8.77 | 10 |
| 95% | 1.90 | 3.48 | 5.93 | 15.4 | 20 |
| 99% | 1.98 | 3.88 | 7.48 | 39.3 | 100 |
The serial part sets a hard ceiling: with 10% serial work, no number of cores can give more than 10×.
flowchart LR
subgraph One["1 core: 100 units"]
S1["serial 10"] --> P1["parallel 90"]
end
subgraph Four["4 cores: 32.5 units (3.08x)"]
S2["serial 10"] --> P2["parallel 90 / 4 = 22.5"]
end
Gustafson's law gives the more hopeful view: with more cores people usually solve bigger problems, and the parallel part grows while the serial part stays the same, so scaled speedup ≈ (1 − p) + p × N.
Sources: Wikipedia: Amdahl's law
| Cost | Cause | See |
|---|---|---|
| Serial sections | Code only one thread can run | Amdahl's law above |
| Locks and contention | Threads waiting for each other | Below |
| Coherence traffic | Shared data bouncing between caches; false sharing | Caches and Coherence |
| Memory bandwidth | All cores share the memory controllers | |
| Load imbalance | One thread gets more work and the others wait for it | |
| Barriers and atomics | Ordering instructions stall the pipeline | Memory and Ordering |
A lock (mutex) lets only one thread at a time into a critical section. It is built on atomic read-modify-write instructions such as Arm CAS or LDXR/STXR.
sequenceDiagram
participant T0 as Thread 0
participant L as Lock
participant T1 as Thread 1
T0->>L: acquire (atomic CAS 0 -> 1)
L-->>T0: success
T1->>L: acquire
L-->>T1: busy, wait / spin
T0->>T0: critical section
T0->>L: release (store-release 0)
T1->>L: acquire again
L-->>T1: success
A heavily used lock turns parallel code back into serial code, which shows up as a lower effective p in Amdahl's law.
Large servers have several chips (sockets), each with its own memory. A core reaches its own socket's memory faster than another socket's.
flowchart LR
subgraph S0["Socket 0"]
CA["Cores 0-31"] --- MA["Local memory A"]
end
subgraph S1["Socket 1"]
CB["Cores 32-63"] --- MB["Local memory B"]
end
CA <-->|"slower remote access"| MB
CB <-->|"slower remote access"| MA
This is non-uniform memory access (NUMA). Operating systems try to place a thread's memory on the same socket as the thread ("first touch" allocation).
Sources: Wikipedia: Non-uniform memory access
- Multicore puts several full cores on a chip with private L1/L2, a shared L3 and a coherent interconnect.
- Amdahl's law: the serial fraction limits speedup, however many cores you add.
- Locks, coherence traffic, shared bandwidth and NUMA distance are the main costs; big.LITTLE trades performance for efficiency per thread.
- Computer Architecture Overview
- Fundamentals: CPU, Memory and Instructions
- Pipelining
- Branches and Remedies
- Instruction-Level Parallelism
- Memory and Ordering
- Caches and Coherence
- Multicore
- Multithreading in Hardware
- SIMD and GPUs
- Glossary and Summary
- Hexagon Overview and Processor Properties
- ISA Fundamentals: Packets, Slots and Threads
- Registers
- Instruction Encoding and Mnemonics
- Data, Memory and Control Instructions
- Floating Point, HVX and Alignment
- Caches, MMU and Glossary
- Operating Systems Overview
- Processes
- Threads
- CPU Scheduling
- Synchronization
- Deadlock
- Memory Management
- Virtual Memory
- Files, Storage and I/O
- Kernel and System Calls
- Interview Q&A and Glossary
- C++ for LLVM Development: Overview
- C++ Basics
- Classes and RAII
- Ownership and Move Semantics
- Templates and Lambdas
- LLVM Data Structures (ADT)
- LLVM-Style RTTI: isa, cast, dyn_cast
- Errors, Output and Assertions
- Iterators and Ranges
- Building, Debugging and Exercises
- LLVM IR Overview
- Structure: Modules, Functions, Blocks and Values
- Type System
- Arithmetic, Bitwise and Cast Instructions
- Compare and Select
- Memory: alloca, load, store and getelementptr
- Control Flow: br, switch, ret and call
- SSA and Phi
- Control Flow Graph and Loops
- Dominance, Dominator Tree and Dominance Frontier
- Data-flow Analysis
- Writing an IR Pass
- Common Passes
- Exercises, Tooling and Glossary
- SelectionDAG Overview
- Pipeline, Phases and Traversal Orders
- Core Data Structures
- DAG Construction
- DAG Combiner
- Legalization
- Type Legalization
- Operation and Vector Legalization
- Instruction Selection
- TableGen Pattern Language
- Matcher Interpreter and Folding
- AArch64 Instruction Selection
- Scheduling and MIR Emission
- PHI Node Resolution
- AArch64 Walkthroughs
- Arithmetic and Data Movement
- Memory Instructions
- Control Flow and Calls
- End-to-End Example
- Tooling, Debugging and Extending
- Selector Comparison and Glossary
- Assignments: Build the Toy Backend
- Stage 1: Build Setup
- Stage 2: Target Registration
- Stage 3: TableGen Skeleton
- Stage 4: MC Layer for Assembly Output
- Stage 5: TargetMachine and Subtarget
- Stage 6: TargetLowering, Arguments and Returns
- Stage 7: Instruction Selection and the First Function
- Stage 8: Registers, Copies and Spills
- Stage 9: Frame Lowering
- Stage 10: Memory, Globals and Control Flow
- Stage 11: Calls
- Stage 12: Scheduling Model
- Stage 13: Object Files
- Stage 14: Capstone, a Complete Toy Backend
- Target Bring-up Overview
- Directory Layout, CMake and Registration
- The Target .td File
- TargetMachine and Subtarget
- TargetLowering Setup
- Calling Conventions
- Instructions and Instruction Selection
- Registers and Allocation Hooks
- Frame Lowering
- AsmPrinter and the MC Layer
- Scheduling
- A Minimal Toy Target
- Bring-up Checklist and AArch64 File Map
- Tooling and Glossary
- Calling Conventions Overview
- The CallingConv.td Language
- CCState and CCValAssign
- LowerFormalArguments
- LowerCall
- LowerReturn and CanLowerReturn
- Varargs, byval, sret and swifterror
- Tail Calls and Sibling Calls
- Custom Backend Guide and Checklist
- AArch64 Walkthroughs
- Tooling and Glossary
- Frame Lowering Overview
- MachineFrameInfo
- TargetFrameLowering Hooks
- The PEI Pass
- Callee-Saved Registers and Stack Layout
- Frame Index Elimination and the Register Scavenger
- Shrink Wrapping
- CFI and Unwind Information
- Custom Backend Guide and Checklist
- AArch64 Walkthroughs
- Tooling and Glossary
- MC Layer Overview
- Core Data Structures
- Streamers
- Assembler and Layout
- Fixups and Relocations
- Writing an MC Layer for a Custom Backend
- MCAsmInfo and the Instruction Printer
- Code Emitter
- AsmBackend and Object Writer
- Assembly Parser and Disassembler
- Bring-up Checklist and Common Failures
- Tooling and Glossary
- Register Allocation Overview
- The Register Allocation Pipeline
- Registers, Virtual Registers and Register Classes
- Liveness: Slot Indexes and Live Intervals
- Preparing Code for Allocation
- PHI Elimination and Two-Address Lowering
- Register Coalescer
- Allocation Framework
- The Register Allocators
- Fast Register Allocator
- Basic Register Allocator
- Greedy Register Allocator
- PBQP Register Allocator
- Spilling and Splitting
- Spill Weights and Copy Hints
- The Inline Spiller
- Live Range Splitting
- Rewriting and Post-RA Passes
- Writing Register Allocation Support for a Custom Backend
- Register Definitions in TableGen
- TargetRegisterInfo Hooks
- TargetInstrInfo Hooks
- Pass Pipeline Hooks
- Bring-up Checklist and Common Failures
- AArch64 Walkthroughs
- Tooling and Debugging
- Glossary and Where Do I Look