Tác giả giữ toàn bộ bản quyền (All Rights Reserved) — không phải giấy phép mở. Bạn vẫn xem và học miễn phí trên OpenER; muốn tái sử dụng cần xin phép tác giả.
[MUSIC PLAYING] PROFESSOR: Hi, welcome back to our pipelining module.
We're almost done. We have learned how to design a pipeline process. We actually learn the principles of designing a pipeline processor.
You will get the true feeling for how to design one when doing a project and actually going through the designing of pipeline and resolution of all the hazards.
That's really fun, actually. But, for now, we understood all the principles that we need to deal with in order to design a good processor.
There is one more advanced concept that is out there. That's the concept of so-called superscalar processors. You might have heard about that.
Many of the modern, very high performance processors are of superscalar type.
Before we get to those, let's see how can we increase processor performance further from what we know so far.
So we have designed a five stage pipeline. And what is kind of interesting in this five stage pipeline is the industry workhorse nowadays.
Probably 80% or 90% of processors that are out there all around us are five stage pipelines, but they don't have the highest possible performance.
There are many designs that are different. They're higher performance. And let me say, majority of processors out there are five stage pipelines.
You will find them in all kinds of applications — cars, and various appliances, and so on. They're really common. They're like that. They're these invisible computers that are all around us.
But those that we'll find in laptops, or in desktops, or even in cell phones, there are usually a few higher performance processors, and a lot of these five stage pipelines as well.
So how do we crank up the performance of a processor? We have a few options. One, we can try to crank up the clock frequency. But the clock frequency is limited by two things.
How fast transistors will switch, and that is set by the technology. And the other one is the power dissipation. We have mentioned that before.
Cranking up the clock frequency was our primary means of adding performance in the '90s up to early 2000s, but then we hit the power ceiling, and our designers discovered that they can design processors that will run very fast at very high clock frequencies.
But there is no practical means of cooling them, so the clock frequency had to be held constant to allow for reasonable cooling.
Then the second option that often works in concert with clock rate increases is the concept of deeper pipelining.
So we have seen our five stage pipeline, but we can break up the execution into smaller and smaller chunks. So people have built pipelines that are 10 stages deep or 15 stages deep.
Intel processors I think went up to 20 stages deep at some point.
So the idea here is to do less work in each cycle to have less logic depth, to go through less logic gates so we can have a shorter clock cycle.
And that enables us to either run at a higher frequency, or if we are limited with power, to drop the supply voltage and run at the same clock frequency, but with lower power.
However, the deeper the pipeline, the higher the chances that we are going to run into hazards. So our CPI is naturally going to get higher, to be higher than 1.
So what came as an alternative to that are so-called multi-issue, or superscalar, processors. Those are the ones that theoretically can have CPI that is much less than 1.
So how do those work? In superscalar processor, we have multiple issues. What does it mean? We have multiple execution units in everything else that helps feed those execution units.
So each execution unit is actually a pipeline on its own that is capable of executing either integer instructions or floating point instructions, or we may have dedicated load and store pipelines.
So since we have multiple execution units, we can fetch multiple instructions per clock cycle and so-called issue them to different execution pipelines.
So this enables us to drop our CPI below 1 so we are going to be completing multiple instructions per clock cycle.
Often, people will use a concept IPC such that it's easier to understand things, to compare things that are greater than 1.
For example, if you have a 4 gigahertz four way multiple issue processor, it is capable of executing 16 billions instructions per second, and would have a peak CPI of 0.25.
And peak IPC would be 1 over that, which is 4.
Peak means that if there are no conflicts, there are no dependencies, no hazards, we can get to that peak CPI or IPC. But in practice, that number is not going to be so great.
Often, these processors employ something that is called out-of-order execution.
So in order to deal with the dependencies and hazards, there will be a harder unit that will be picking and figuring out which instructions have dependencies and trying to execute them in an order where they don't depend on each other.
And then there'll be a reorder unit at the end of the pipeline that will put the results back in order such that whoever runs that program gets meaningful results.
And that is all done perfectly. This we definitely are not going to cover in 61C, but CS152 goes into great depth of that.
What we will do is a quick overview of what you will find in a superscalar processor.
So generally, there will be an instruction fetch and decode that will be fetching and decoding multiple instructions per cycle.
And then it would go and issue them in different execution pipelines.
It will recognize what kind of an instruction it is, and it would send it down the integer pipelines, or floating point pipelines, or load store pipelines.
It use some kind of reservation station that would be there to reserve the resources, to reserve this functional unit for future use because the processor will try to keep them all filled as much as possible.
And, finally, the instructions will be committed or retired in order. So they'll be arriving out of order, but coming out of this committee on it in order.
Here is an example of an out-of-order superscalar processor, which is Intel i7, a relatively modern processor that you'll find in laptops, like the one that I'm using now for this presentation.
What is shown here is the CPI for a number of benchmarks here. And these are different kinds of benchmarks.
You don't really need to know which kinds are those, but this has something to do with some quantum mechanics simulations. This 264 is video compression.
bzip is a zip type of a program that is compressing some files. You'll find the, goal, game, and then gcc that is compiling some kind of target code.
And then they measure what is the CPI that is achieved for these benchmarks.
And what you will find out here is that the CPIs in most cases will drop below 1.
So there will be less than 1 and, in some cases, maybe more than 1. There is another interesting thing to notice on this graph.
There is ideal CPI that is sitting around 0.25 down here. And then there is a realistic CPI that rarely gets below 0.5.
So the ideal CPI is 0.25, or about a quarter, and realistic one is 0.44 and so on.
Real CPI is due to stalls, respeculation, and handling hazards. By the way, how is this CPI number actually achieved or measured?
It's not something magic. It's just the reverse of our iron law of processor performance. So what we have there, in there, we had our CPI, which stands for cycles per instruction.
And the CPI can be evaluated by knowing all the other elements of this equation. So we can time the program. How long does it take us to execute the program?
Then we can count the number of instructions that that benchmark has. And finally, we can look up, how long does it take to execute the cycle as the frequency of a processor?
That gives us the number of cycles per instruction. And that is straight time to execute a program divided by instructions for a program times the time per cycle.
So that's it. This is the way how these average CPI numbers have been measured for i7 or many other processors.
A few notes about the design of ISA and which ISAs are good for pipelining. So RISC-V is a type of a risk ISA that is designed with pipelining in mind.
And there are several features that you will recognize that are in there that are very helpful for designing a pipeline.
For example, in our version, 32 version, all instructions and registers are 32 bits.
But in every case, in every variant of RISC-V, all the instructions are 32 bits.
So all these instructions are easy to decode in one cycle. Compare that to x86.
Their instructions can be 1 or anything up to 15 bytes. So decoding is really complicated there. So you take a look at one instruction.
You may be able to decode what is in there, what are you supposed to do. But more likely, you have to go and give me a few more bytes.
Now can I decode? Not yet. A few more bytes. And finally, after 15 of them, the most complex instructions can be decoded.
RISC-V has a small number, six different instruction formats. They're very easy to decode and read registers in one step. So in one stage, we can do both.
Many more complex sizes require us to do that in multiple steps. Load store addressing can be done in third stage by using the ALU and access the memory in the fourth stage.
And then memory operands are all aligned and take only one cycle. That is something that is very convenient.
And we have taken advantage of all of this when designing our pipeline. And that's it. So we have done it. We got our pipeline.
We got our working processor that is capable of executing all arbitrary to high instructions. First, in one cycle, and then we figure out how to pipeline it.
We identify these five phases of execution that we associate with five stages of a pipeline.
And we have designed this controller first for a single stage pipeline, but then we have outlined the principles for a single stage execution, I'm sorry.
And then we have identified how we need to modify it to support resolution of hazards in a pipeline.
Pipelining improves the performance and opens an avenue to building something that is really, really powerful. We're going to wrap up this module now.
In the next module, we are going to continue building better and better computer. See you after a bit of a longer break.
Đăng nhập để đánh giá học liệu này.
Đăng nhập để bình luận — chưa ai bình luận về học liệu này.
Không có khóa học liên quan.