This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:multiasm:cs:chapter_3_9 [2025/01/07 10:59] – [Superscalar] ktokarz | en:multiasm:cs:chapter_3_9 [2025/12/05 11:37] (current) – [Hyperthreading] ktokarz | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| ===== Pipeline ===== | ===== Pipeline ===== | ||
| - | As was described in the previous chapter, executing a single instruction requires many actions which must be performed by the processor. We could see that each step, or even substep, can be performed by a separate logical unit. This feature has been used by designers of modern processors to create a processor in which instructions are executed in a pipeline. A pipeline is a collection of logical units that execute many instructions at the same time - each of them at a different stage of execution. If the instructions arrive in a continuous stream, the pipeline allows the program to execute faster than a processor that does not support the pipeline. Note that the pipeline does not reduce the time of execution of a single instruction, it increases the throughput of the instruction stream. | + | As was described in the previous chapter, executing a single instruction requires many actions which must be performed by the processor. We could see that each step, or even substep, can be performed by a separate logical unit. This feature has been used by designers of modern processors to create a processor in which instructions are executed in a pipeline. A pipeline is a collection of logical units that execute many instructions at the same time - each of them at a different stage of execution. If the instructions arrive in a continuous stream, the pipeline allows the program to execute faster than a processor that does not support the pipeline. Note that the pipeline does not reduce the time of execution of a single instruction. It increases the throughput of the instruction stream. |
| - | A simple pipeline is implemented in AVR microcontrollers. It has two stages, which means that while one instruction is executed another one is fetched as shown in Fig {{ref> | + | A simple pipeline is implemented in AVR microcontrollers. It has two stages, which means that while one instruction is executed, another one is fetched as shown in Fig {{ref> |
| <figure pipelineavr> | <figure pipelineavr> | ||
| - | {{ : | + | {{ : |
| < | < | ||
| </ | </ | ||
| Line 17: | Line 17: | ||
| </ | </ | ||
| - | Modern processors implement longer pipelines. For example, Pentium III used the 10-stage pipeline, Pentium 4 20-stage, and Pentium 4 Prescott even a 31-stage pipeline. Does the longer pipeline mean faster program execution? Everything has benefits and drawbacks. The undoubted benefit of a longer pipeline is more instructions executed at the same time which gives the higher instruction throughput. But the problem appears when branch instructions come. While in the instruction stream | + | Modern processors implement longer pipelines. For example, Pentium III used the 10-stage pipeline, Pentium 4 20-stage |
| ===== Superscalar ===== | ===== Superscalar ===== | ||
| - | The superscalar processor increases the speed of program execution because it can execute more than one instruction during a clock cycle. It is realised by simultaneously dispatching instructions to different execution units on the processor. The superscalar processor doesn' | + | The superscalar processor increases the speed of program execution because it can execute more than a single |
| <figure superscalar> | <figure superscalar> | ||
| Line 28: | Line 28: | ||
| </ | </ | ||
| - | In the x86 family first processor with two paths of execution was Pentium with U and V pipelines. Modern x64 processors like i7 implement six execution units. Not all execution units have the same functionality. | + | In the x86 family first processor with two paths of execution was the Pentium with two execution units called |
| - | ^ Execution unit ^ Functionality | + | <table executionunits> |
| - | | 0 | Integer, Floating point multiplication, | + | < |
| - | | 1 | Integer, Floating point addition, SSE addition | + | ^ Execution unit ^ Functionality |
| - | | 2 | Address generation, load | | + | | 0 | Integer |
| - | | 3 | Address generation, store | + | | 1 | Integer |
| - | | 4 | Data store | | + | | 2 | Address generation, load |
| - | | 5 | Integer, Branch, SSE addition | + | | 3 | Address generation, store | |
| + | | 4 | Data store | ||
| + | | 5 | Integer | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Branch prediction ===== | ||
| + | As it was mentioned, the pipeline can suffer invalidation if the conditional branch is not properly predicted. The branch prediction unit is used to guess the outcome of conditional branch instructions. It helps to reduce delays in program execution by predicting the path the program will take. Prediction is based on historical data and program execution patterns. | ||
| + | There are many methods of predicting the branches. In general, the processor implements the buffer with the addresses of the last few branch instructions with a history register for every branch. Based on history, the branch prediction unit can guess if the branch should be taken. | ||
| + | |||
| + | ===== Hyperthreading ===== | ||
| + | Hyper-Threading Technology is an Intel approach to simultaneous multithreading technology, which allows the operating system to execute more than one thread on a single physical core. | ||
| + | For each physical core, the operating system defines two logical processor cores and shares the load between them when possible. The hyperthreading technology uses a superscalar architecture to increase the number of instructions that operate in parallel in the pipeline on separate data. With Hyper-Threading, | ||
| + | |||
| + | <note info> | ||
| + | The real path of instruction processing is much more complex. Additional techniques are implemented to achieve better performance, | ||
| + | </ | ||