Foundations
How a computer holds data
Bytes, addresses, and values
Every variable, string and array is bytes in numbered boxes. Addresses are the box numbers you hand to the CPU or GPU.
Why the cache line matters
Hardware fetches a fixed block around your address. Using the whole block is free speed; using one byte per fetch wastes the rest.
The latency ladder
If you remember one scale, remember this one. Work on registers is free; waiting on the network is the whole problem.
How work is organised
CPU versus GPU
A CPU is built to finish one complicated task fast. A GPU is built to run the same simple task on thousands of data points at once.
Processes versus threads
Separate memory is safe but slow to share. Shared memory is fast to share and easy to corrupt.
What a warp is
The GPU issues work to groups of 32 threads. They run in step, which is fast until their paths differ.
Grid, block, thread
You describe work as a three-level shape. The hardware turns that description into warps on SMs.
Blocking threads versus async tasks
A blocked thread holds a stack and does nothing. An async task gives the thread back while it waits for the device.
The call stack
Each call pushes a frame with its locals; the return pops it. Deep recursion runs out of frames.
How a program becomes instructions
From source to something runnable
A compiler reads text, builds a structure, checks it, simplifies it, and finally picks machine instructions.
Stack and heap
Small values live on the stack with the function. Big or variable-size values live on the heap behind a pointer.
Pointers and references
Both say where a value lives. A reference carries a guarantee the compiler enforces; a raw pointer does not.
How threads share data safely
What a lock does
One writer, everyone else waits. Simple, correct, and the usual source of both deadlocks and slowdowns.
Why atomics exist
Two threads doing read-modify-write on one variable lose an update. Atomics make the whole step indivisible.
How machines talk
Client and server
Two programs on different machines talk in messages. Nothing is shared, so anything can be late, lost, or duplicated.
Where a network call lives
You send a message; four layers wrap it. Knowing which layer failed decides whether you fix code or fix the network.
How machines agree
Replication, and the problem it creates
Copying data is easy. Keeping copies agreeing while machines fail is the hard part.
What consensus means
A group decides one value, and all of them agree on it, even when some crash or the network loses messages.
The append-only log
A list you only add to. Given the same log, every machine builds the same state.
Quorums
Any two majorities share a member. That single fact lets a system survive a minority of failures without losing writes.
The maths that decides speed
Shapes in one matrix multiply
Three letters carry the whole data flow. Most ML systems bugs are a shape mismatch, and most speed comes from reusing K.
Arithmetic intensity
One number tells you what a kernel is waiting on: the ratio of maths done to bytes moved.