Source
Central processing unit
General structure of the CPU and its role in computing.
CPU and GPU solve the same problem - performing calculations, but they do it in different ways. The CPU is focused on versatility and low latency, while the GPU is focused on massive parallelism and throughput.
CPU device (basic)
- Cores - execute instructions and control threads.
- ALU - Performs arithmetic and logical operations.
- Control Unit - controls the execution of instructions.
- Registers are the fastest memory near the core.
- L1/L2/L3 cache - reduces data access latency.
- Memory and bus controller - communication with RAM and devices.
Source
Graphics processing unit
GPU architecture and features of parallel computing.
GPU device (basic)
- SM/CU (multiprocessors) - parallel execution units.
- Many simple cores perform the same operations en masse.
- Scheduler/dispatch - distributes threads across cores.
- VRAM is high-bandwidth local memory.
- Cache and memory controller - speed up data access.
- Command processor - accepts and assigns tasks from the CPU.
Comparison of CPU and GPU
CPU
- Small number of complex kernels
- High performance per thread
- Good for branches and latency
Several powerful cores perform different tasks.
GPU
- Many simple kernels
- High throughput
- Excellent for parallel computing
Many simple cores perform one task in parallel.
Where does it work better?
CPU
- Server queries with strong logic
- Transactions, databases, OS tasks
- Scenarios with unpredictable branches
GPU
- Graphics and rendering
- Machine learning and matrix operations
- Massively parallel computing
Practical conclusion
In modern systems, the CPU and GPU often work together: the CPU manages the logic and orchestration, and the GPU takes care of bulk calculations. The choice depends on the nature of the load: latency and branching are in favor of the CPU, parallel and similar operations are in favor of the GPU.
Why is this important when designing applications?
- Helps you choose an architecture for the type of load: interactive queries on the CPU, batches and inference on the GPU.
- Affects infrastructure costs: CPU-domain and GPU-domain systems are considered differently.
- Determines memory and networking requirements: GPUs often require fast memory and high bandwidth.
