A processor executes programs?including the operating system itself and user applications?all of which perform useful work. From the processor's point of view, a program is simply a group of low-level instructions that the processor executes more or less in sequence as it receives them. How efficiently and effectively the processor executes instructions is determined by its internal design, also called its architecture. The CPU architecture, in conjunction with CPU speed, determines how fast the CPU executes instructions of various types. The external design of the processor, specifically its external interfaces, determines how fast it communicates information back and forth with external cache, main memory, the chipset, and other system components.
Modern processors have the following internal components:
The core of the CPU, the execution unit processes instructions.
The branch predictor attempts to guess where the program will jump (or branch) next, allowing the prefetch and decode unit to retrieve instructions and data in advance so that they will already be available when the CPU requests them.
The floating-point unit (FPU) is a specialized logic unit optimized to perform noninteger calculations much faster than the general-purpose logic unit can perform them.
Also called Level 1 or L1 cache, primary cache is a small amount of very fast memory that allows the CPU to retrieve data immediately, rather than waiting for slower main memory to respond. See Chapter 5 for more information about cache memory.
Bus interfaces are the pathways that connect the processor to memory and other components. For example, modern processors connect to the chipset Northbridge via a dedicated bus called the frontside bus (FSB) or host bus.
The processor clock coordinates all CPU and memory operations by periodically generating a time reference signal called a clock cycle or tick. Clock frequency is specified in megahertz (MHz), which specifies millions of ticks per second, or gigahertz (GHz), which specifies billions of ticks per second. Clock speed determines how fast instructions execute. Some instructions require one tick, others multiple ticks, and some processors execute multiple instructions during one tick. The number of ticks per instruction varies according to processor architecture, its instruction set, and the specific instruction. Complex Instruction Set Computer (CISC) processors use complex instructions. Each requires many clock cycles to execute, but accomplishes a lot of work. Reduced Instruction Set Computer (RISC) processors use fewer, simpler instructions. Each takes few ticks but accomplishes relatively little work.
These differences in efficiency mean that one CPU cannot be directly compared to another purely on the basis of clock speed. For example, an AMD Athlon XP 3000+, which actually runs at 2.167 GHz, may be faster than an Intel Pentium 4 running at 3.06 GHz, depending on the application. The comparison is complicated because different CPUs have different strengths and weaknesses. For example, the Athlon is generally faster than the Pentium 4 clock for clock on both integer and floating-point operations (that is, it does more work per CPU tick), but the Pentium 4 has an extended instruction set that may allow it to run optimized software literally twice as fast as the Athlon. The only safe use of direct clock speed comparisons is within a single family. A 1.2 GHz Tualatin-core Pentium III, for example, is roughly 20% faster than a 1.0 GHz Tualatin-core Pentium III, but even there the relationship is not absolutely linear. And a 1.2 GHz Tualatin-core Pentium III is more than 20% faster than a 1.0 GHz Pentium III that uses the older Coppermine core. Also, even within a family, processors with similar names may differ substantially internally.
Clock speeds increase every year, but the laws of physics limit how fast CPUs can run. If designers depended only on faster clock speeds for better performance, CPU performance would have hit the wall years ago. Instead, designers have improved internal architectures while also increasing clock speeds. Recent CPUs run at more than 650 times the clock speed of the PC/XT's 8088 processor, but provide 6,500 or more times the performance. Here are some major architectural improvements that have allowed CPUs to continue to get faster every year:
For a given clock speed, the amount of work done depends on the amount of data processed in one operation. Early CPUs processed data in 4-bit (nibble) or 8-bit (byte) chunks, whereas current CPUs process 32 or 64 bits per operation.
All CPUs work well with integers, but processing floating-point numbers to high precision on a general-purpose CPU requires a huge number of operations. All modern CPUs include a dedicated FPU that handles floating-point operations efficiently.
Early CPUs took five ticks to process an instruction?one each to load the instruction, decode it, retrieve the data, execute the instruction, and write the result. Modern CPUs use pipelining, which dedicates a separate stage to each process and allows one full instruction to be executed per clock cycle.
If one pipeline is good, more are better. Using multiple pipelines allows multiple instructions to be processed in parallel, an architecture called superscalar. A superscalar processor processes multiple instructions per tick.