1 - Computer Systems (2023) / CPU - Cores & Cache
|
|
CPU - Cores and Cache
If you have ever shopped for a PC or even individual PC components then you will at some point have been faced with a choice of CPUs. Comparing CPUs can be quite daunting as there are many numbers and technical terms to get your head around.
On this page we will try to understand the two items circled in the image above - Cores and Cache.
CPU Cores
In the CPU a core is essentially a processor unit that is capable of fetching, decoding and executing instructions independently. In the past, CPUs would only contain one core, however, in recent years CPU manufacturers have managed to create CPUs containing between 2 and 32 cores.
What this means is that the modern CPU will contain between 2 and 32 processors... but why would we want this?
Having multiple cores in a CPU makes it capable of completing multiple tasks at the same time (Multitasking). This drastically increases the performance of the CPU as more tasks can be complete in less time.
What this means is that the modern CPU will contain between 2 and 32 processors... but why would we want this?
Having multiple cores in a CPU makes it capable of completing multiple tasks at the same time (Multitasking). This drastically increases the performance of the CPU as more tasks can be complete in less time.
Each CPU core contains its own ALU, Control Unit and Registers thus allowing it to work on tasks independently.
More cores = More power?
It is true that adding more cores to a CPU will increase the overall performance. This technology has allowed us to stop chasing higher clock speeds (covered in the next section).
It is important to realise that increasing the number of cores will not result in a direct 100% performance improvement. This means that doubling the number of cores will not result in exactly double the performance. Quadrupling the number of cores will not result in exactly 4 times the performance.
Why?
Well each time you add a new core to the CPU it increases the channels of communication and the amount of coordination that needs to take place between them.
It is important to realise that increasing the number of cores will not result in a direct 100% performance improvement. This means that doubling the number of cores will not result in exactly double the performance. Quadrupling the number of cores will not result in exactly 4 times the performance.
Why?
Well each time you add a new core to the CPU it increases the channels of communication and the amount of coordination that needs to take place between them.
Clock Speed
As you can see above, the CPU pictured has 8 - 16 cores. This detail is closely followed by a "Clock speed" of 3.80 GHZ.
What is clock speed?
Clock speed essentially refers to the speed that your CPU cores can execute instructions. The higher the clock speed, the faster your CPU can operate.
The CPU will process a large amount of low level instructions every second. The clock speed, (generally) referred to as GHz (gigahertz) measures how many cycles your CPU can execute per second.
The actual unit used to describe a processors speed will of course depend on how many instruction cycles it can carry out per second. The units used are detailed in the table below:
What is clock speed?
Clock speed essentially refers to the speed that your CPU cores can execute instructions. The higher the clock speed, the faster your CPU can operate.
The CPU will process a large amount of low level instructions every second. The clock speed, (generally) referred to as GHz (gigahertz) measures how many cycles your CPU can execute per second.
The actual unit used to describe a processors speed will of course depend on how many instruction cycles it can carry out per second. The units used are detailed in the table below:
Unit |
Cycles per second |
1 Hertz (Hz) |
1 instruction per second |
1 Kilohertz (kHz) |
1000 Cycles per second |
1 Megahertz (mHz) |
1,000,000 Cycles per second |
1 Gigahertz (Ghz) |
1,000,000,000 Cycles per second |
1GHz = 1 billion CPU cycles per second!
This means that the core clock speed in our pictured CPU allows for 3.8 billion cycles per second.
In General you can assume that the higher the clock speed the faster the performance of the CPU will be.
This means that the core clock speed in our pictured CPU allows for 3.8 billion cycles per second.
In General you can assume that the higher the clock speed the faster the performance of the CPU will be.
CPU Cache
Modern CPUs are fast, so fast in fact that their processing speeds can often out pace the speed of RAM. This causes the CPU to slow down as it deals with the speed bottle neck.
To try and combat this a small but extremely fast piece of memory is built into the CPU called the cache.
To try and combat this a small but extremely fast piece of memory is built into the CPU called the cache.
Cache Levels
There are three levels of cache within a CPU, each with differing speed size and responsibility. The three levels are referred to as L1, L2 and L3 Cache.
L1 Cache - This is the fastest of all three caches and it stores the data that the CPU is most likely to use whilst completing current tasks. It is very fast but also very small in size. Typical L! caches will be between 2 and 64 KiB.
L2 Cache - This is slightly slower than the L1 cache but it does have a larger storage capacity. L2 cache size can vary between 256KiB and 8MiB. Although the L2 cache is slower than the L1 cache it is still approximately 25 times faster than RAM.
All cores in a CPU will have access to their own individual L1 and L2 caches. This is illustrated in the diagram above.
L3 Cache - This cache is slower than the L1 and L2 caches, however it is still much faster than RAM. L3 caches are shared between all CPU cores as illustrated in the above diagram. The storage capacity of L3 cache is far superior to that of L1 and L2. Most decent CPUs these days will offer L3 cache with a capacity of between 32 and 64 MiB.
What does the cache store?
The cache will store commonly used functions / data that are normally held in the RAM. When a CPU needs to process data it will first look in the Cache. If the data is found in the cache it is known as a cache hit! If the data is not found it is referred to as a cache miss. After a cache miss the CPU must then look in the RAM for the data required.
To help further improve performance the CPU cache will attempt to predict what data will be required in the cache For example, if a CPU is processing a video file, the cache may attempt to retrieve additional parts of the file ready for process.
Typically each core within a CPU will have its own cache to store data that it will process.
The larger the CPU cache the better it can perform as more data can be quickly accessed from the ultrafast memory.
There are three levels of cache within a CPU, each with differing speed size and responsibility. The three levels are referred to as L1, L2 and L3 Cache.
L1 Cache - This is the fastest of all three caches and it stores the data that the CPU is most likely to use whilst completing current tasks. It is very fast but also very small in size. Typical L! caches will be between 2 and 64 KiB.
L2 Cache - This is slightly slower than the L1 cache but it does have a larger storage capacity. L2 cache size can vary between 256KiB and 8MiB. Although the L2 cache is slower than the L1 cache it is still approximately 25 times faster than RAM.
All cores in a CPU will have access to their own individual L1 and L2 caches. This is illustrated in the diagram above.
L3 Cache - This cache is slower than the L1 and L2 caches, however it is still much faster than RAM. L3 caches are shared between all CPU cores as illustrated in the above diagram. The storage capacity of L3 cache is far superior to that of L1 and L2. Most decent CPUs these days will offer L3 cache with a capacity of between 32 and 64 MiB.
What does the cache store?
The cache will store commonly used functions / data that are normally held in the RAM. When a CPU needs to process data it will first look in the Cache. If the data is found in the cache it is known as a cache hit! If the data is not found it is referred to as a cache miss. After a cache miss the CPU must then look in the RAM for the data required.
To help further improve performance the CPU cache will attempt to predict what data will be required in the cache For example, if a CPU is processing a video file, the cache may attempt to retrieve additional parts of the file ready for process.
Typically each core within a CPU will have its own cache to store data that it will process.
The larger the CPU cache the better it can perform as more data can be quickly accessed from the ultrafast memory.