No history yet

GPU Basics

The Difference Between a CPU and GPU

Your computer's Central Processing Unit (CPU) is a master of sequential tasks. It's designed with a few powerful cores that can tackle complex instructions one after another, very quickly. Think of it as a world-class chef who can expertly prepare a multi-course meal, focusing on each dish with precision before moving to the next.

A Graphics Processing Unit (GPU), on the other hand, is built for parallel work. Instead of a few powerful cores, it has thousands of simpler cores. It’s like an enormous kitchen staffed by thousands of cooks, all working at the same time. Each cook might only be able to chop one vegetable, but together they can prep a mountain of ingredients in seconds. This structure makes GPUs exceptionally good at jobs that can be broken down into many small, repetitive tasks, like rendering graphics or training AI models.

Unlike the design of traditional central processing units (CPUs, see “GPU vs CPU” discussion below), GPU design involves a massive number of smaller processing units (cores) that can handle tasks in parallel—tasks that can be divided into many smaller subtasks to be processed simultaneously.

This fundamental difference in design philosophy dictates what each processor is good at. CPUs excel at general-purpose computing where tasks are varied and unpredictable. GPUs shine when a massive amount of data needs the same operation applied to it simultaneously.

The Building Blocks of a GPU

To understand how a GPU achieves massive parallelism, we need to look at its internal structure. It's organized in a clear hierarchy.

The entire GPU contains several Streaming Multiprocessors (SMs). You can think of an SM as a self-contained mini-processor. It’s the primary unit of computation on the GPU.

Inside each SM are numerous CUDA Cores (this is NVIDIA's term; AMD calls them Stream Processors). These are the real workhorses. They are simple, efficient execution units that perform the actual math. An SM might contain 64, 128, or even more of these cores. When a task is sent to the GPU, it's divided among the SMs, and each SM then distributes the work across its many cores.

The GPU Memory Hierarchy

Just as important as the processing cores is how they access data. A fast processor waiting on slow memory is inefficient. GPUs solve this with a tiered memory system, where each level offers a trade-off between speed, size, and accessibility.

Global Memory: This is the largest pool of memory on the GPU, often several gigabytes. It's accessible by all SMs, making it the main way to get data onto and off of the GPU. However, it's also the slowest. It's like a large central warehouse for a factory complex, it holds everything, but trips to get supplies are time-consuming.

Shared Memory: Each SM has its own small, fast block of shared memory. This memory is only accessible to the CUDA cores within that specific SM. Because it's physically closer to the cores, it's much faster than global memory. This is like a small supply cabinet inside a single workshop, allowing a team of workers to quickly share tools and materials without going to the main warehouse.

Registers: These are the fastest and smallest memory units, located directly on the CUDA cores themselves. Each core has its own private set of registers. They hold the data a core is actively working on at that very moment. Think of these as the tools a worker is holding in their hands, instantly available.

Efficient GPU programming involves carefully managing this hierarchy. Programmers try to keep frequently used data in the faster shared memory and registers, minimizing the slow trips to global memory.

FeatureCPU (Central Processing Unit)GPU (Graphics Processing Unit)
Core DesignA few, highly complex coresThousands of simple, efficient cores
Primary GoalMinimize latency for a single taskMaximize throughput for many tasks
Task HandlingOptimized for serial (sequential) tasksOptimized for parallel tasks
Memory FocusLow-latency memory (e.g., large caches)High-bandwidth memory
Best ForGeneral-purpose computing, OS, single-threaded applicationsRepetitive calculations on large datasets, graphics, AI

This table sums up the core differences. Neither is inherently 'better' than the other; they are simply specialized tools designed for different kinds of computational problems. Modern systems use both, letting the CPU handle the overall management and sequential parts of a program while offloading the heavy, parallelizable calculations to the GPU.