Week 7 Day 2 - Pipelining
Today we learned about a major topic in computer science, called pipelining.
A pipeline in a CPU means that rather than fetching, then decoding, then executing one instruction, and then moving on to the next instruction, there are different "stages" in the pipeline that allow multiple instructions to be worked on at the same time. The reason for this is identical to how having a separate washer and dryer allows for better throughput if you have lots of loads of laundry to do.
Longer pipelines allow for more instructions to get processed at the same time, however, they have a weakness: the more stages in a pipeline the bigger the penalty if your "branch predictor" doesn't work right. You see, when you fetch the next instruction, it's usually pretty simple (just get the one after the current one), but when there's a branch you won't know which branch will run until you've actually finished the previous instruction. So a branch predictor will guess, and fetch instructions from that branch. If it's wrong, all of those mispredicted instructions need to get tossed out, yielding a cycle penalty roughly equal to the depth of the pipeline. So if you can minimize branches, this can help performance.
We then talked about a second kind of pipeline stall, which is when one instruction is dependent upon the results of an earlier instruction. Since it can't run until the previous one finishes, this can result in "bubbles"/"stalls"/NOPs (No Operation commands) in the pipeline, reducing performance. To combat this, good processors will engage in Out of Order Execution, in which it builds a dependency graph to see what instructions read values from other instructions' writes (RAW - read after write), and then reorders the instructions so that the code is still correct but minimizes stalls.
We then went over the next homework assignment, which is doing 2D array accesses in assembly, using a first semester assignment (using UNCC's BRIDGES API) that will visualize the results of your code online.
Other Videos By Bill Kerney
2021-03-04 | Week 7 Day 2 - Modal Logic |
2021-03-03 | Week 8 Day 2 - Memory Leaks, RPG 41 |
2021-03-02 | Week 8 Day 1 - Dot Products |
2021-03-02 | Week 8 Day 1 - Out of Order Execution, Register Renaming, Superscalar |
2021-03-02 | Week 7 Day 1 - Quantifiers |
2021-03-01 | Week 8 Day 1 - Templates |
2021-02-28 | Week 7 |
2021-02-28 | Week 7 Day 3 - Deep Copies, Stacks |
2021-02-27 | Week 6 Day 3 - Moar Midterm Review |
2021-02-25 | Week 7 Day 2 - Vector Math |
2021-02-25 | Week 7 Day 2 - Pipelining |
2021-02-24 | Week 7 Day 2 - Debugging II and Queues |
2021-02-24 | Week 6 Day 2 - Midterm Review |
2021-02-23 | Week 7 Day 1 - The Triangle in Games |
2021-02-23 | Week 7 Day 1 - Classes in C and Assembly |
2021-02-23 | Week 6 Day 1 - Fallacies III |
2021-02-22 | Week 7 Day 1 - Using Invariants to Debug Linked Lists |
2021-02-20 | Week 5 Day 2 - Fallacies II |
2021-02-19 | Week 6 - Auto Landscapes |
2021-02-19 | Week 6 Day 2 - Linked Lists Part III |
2021-02-18 | Week 6 Day 2 - Auto Landscapes |