Systems Unpacked · · 4 min read

How does a GPU work—and why isn't it always faster than a CPU?

A GPU is a processor designed to make progress on many pieces of work at once. That makes it useful for graphics, scientific computing, and many AI operations. But parallel capacity only helps when your program can supply enough suitable work—and move the data needed to do it.

The useful question is not “Which processor is faster?” It is “What work must finish, what can happen independently, and where are the bytes?”

Start with eight numbers

Suppose we want to double every number in an array:

text
input:  [1, 2, 3, 4, 5, 6, 7, 8]
output: [2, 4, 6, 8, 10, 12, 14, 16]

Each output depends only on the corresponding input. Computing output 7 does not require output 6. We can divide the array into independent pieces.

Now change the task: each result depends on the previous result. The simple assignment “one worker per item” no longer solves the problem by itself. Some algorithms can be reorganized, but the dependencies must be respected.

That difference—available parallelism—is more useful than comparing advertised core counts.

CPUs and GPUs make different tradeoffs

Modern CPUs also execute work in parallel, through multiple cores, vector instructions, and overlapping independent instructions. They are especially useful for general-purpose code with complex control flow and work where quickly completing a chain of dependent operations matters.

GPUs devote substantial resources to running many threads and sustaining throughput. When some work cannot proceed, other ready work can help keep execution resources occupied. This does not make an individual memory request instantaneous.

These are design tendencies, not a rule that CPUs are sequential and GPUs are parallel. “GPU core” and “CPU core” also describe different structures; their counts are not interchangeable. NVIDIA introduction (opens in a new tab)

CPU tendency

A few workers, each finishing dependent chains quickly

Each row: one step depends on the previous step.

GPU tendency

Many threads, each taking one independent element

Useful only if enough independent work exists and the bytes have arrived.

Conceptual illustration of work distribution, not a hardware schematic. Block counts are arbitrary and do not represent core counts.

What a GPU actually receives

With CUDA, the program launches a kernel: a function executed by a collection of GPU threads. A thread can calculate an index and process the corresponding array element. Threads are organized into blocks, and blocks into a grid.

On NVIDIA GPUs, threads execute in groups called warps. A CUDA warp contains 32 threads. This is an NVIDIA-specific detail, not a universal definition of a GPU. Threads taking different branches can reduce execution efficiency; memory-access patterns matter too. The programming model is more precise than imagining thousands of entirely independent CPU cores. CUDA programming model (opens in a new tab)

The bytes have to arrive

For a discrete GPU, data may need to move from host memory to device memory before computation, then return afterward. Some workloads keep data on the GPU across many operations; some platforms share physical memory. The cost depends on the actual system and access pattern.

For a simple workflow with no overlap, compare:

text
GPU path = transfer in + launch/setup + computation + transfer out
CPU path = computation on data already available to the CPU

This is an accounting model, not a benchmark. Real pipelines can overlap work and transfers, so adding every duration is not always correct. CUDA best practices (opens in a new tab)

Try a deliberately invented example

Assume the CPU takes 6 ms. Suppose the GPU computation takes 1 ms, but moving data in takes 4 ms, setup takes 1 ms, and moving the result back takes 2 ms.

The GPU workflow totals 8 ms. Its computation is faster, but the result arrives later.

Now suppose ten independent operations reuse the same device-resident data. For this simplified scenario, assume one 4 ms transfer in, ten repetitions of 1 ms setup plus 1 ms computation, and one 2 ms transfer out. The total is 26 ms, versus 60 ms for ten 6 ms CPU operations.

These numbers are invented to expose the tradeoff. They are not measurements, and real times do not necessarily scale this way. Reuse changes the arithmetic; it does not guarantee a speedup.

Why this matters for AI

Many AI workloads contain large tensor operations that can expose substantial parallel work. But an AI service also performs preparation, schedules requests, manages memory, and delivers results. A fast kernel tells you only about one part of that path.

The same reasoning applies outside AI: image processing, numerical simulation, and even the little array above. Ask whether the work can be divided, whether there is enough of it, and whether data movement costs more than the computation saves.

What to measure next

Measure the complete operation your user waits for. Separate preparation, transfers, device execution, and waiting where possible. Use the same inputs and verify the output. Compare cold startup with repeated execution explicitly, and record the hardware and software used.

A GPU is powerful when the workload fits. Understanding that fit is the first step toward explaining performance rather than guessing at it.

Continue with how programs execute, explore memory and data movement, or try the interactive request queueing demo.