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ả.
DAN GARCIA
And welcome back. This is it. We're at the end. This is the last lecture of the caches series.
I love this. Let's show some pictures of actual CPUs. Let's see what it looks like. So let's take a look.
The early PowerPC — so this is a long time ago. This is a couple generations ago.
We mentioned before that we have separate L1 caches for instructions and data, partly because they come from different places in memory. So why corrupt them? So how big are they?
32 kibibytes of instructions and data. For each, instruction and data. I've got an external L2 cache interface, and the integrated controller, and cache tags.
So look at this. This L2 cache tags — just the tags for L2 are here. Here's my data cache. This is my L1 data cache.
This is my L1 instruction cache. That's the big one. And what I've stored is I don't have L2 on chip. But I have the tags are on chip.
So I can do the tag comparison really fast. But that's it. By the way, here are the tags for data. There's the tags for my L1.
There's my tags for my L1. And these are my tags for my L1 instruction. So each of these related to that guy. This is the L2 cache tags.
I've got different units here. So we can talk about this. Here's a memory management unit to coordinate all of this. We don't know about the TLB for now.
I've got a load store unit, a integer unit, and a floating point unit. And that lets me in a best case — we talked about there's a little bit of pipelining.
Superscalar means I can run parallel jobs. So I can actually have three — I can have a load/store situation. I can have an integer. I'm doing some ALU kind of thing.
I'm doing a floating point thing. All at the same time. That was pretty cool.
So here is 6 execution units, allow for 2 integer and 1 double precision at exactly the same time in terms of execution units. This is a single core.
This wasn't a multicore machine back in the day. Pentium M — this is again early. Here we go — same kind of thing. So completely different company — that was Motorola.
This is Intel. Here's my 32 kibi of instructional and data here. And anything else I want to say? Ooh, look.
Here is my L2 cache. So not just, well, here's the tags for L2, I put — this on the chip. L2 is on the chip. This is L2.
There's my L2 there. Here's my L1. And here's my L1. I love this.
So that's pretty cool. And now, watch what happens as I get to the next level. Intel Core i7 — it's hard to get more recent than this. I've got 6 cores.
Here's 6 cores.
In that core, I'm not showing you what the cache looks like. But rarely — I'm going to show you something interesting.
Each core has an L2 on it and probably — I actually don't know where it is. I think it's — usually what happens is you look for the things that look all the same.
See all this looks like it's all the same housing? I don't have it in this document. So I'm just going to guess that I'm looking at here is an area.
And here there's a big area. I'm not sure this is. We can take a look at this. But this has L1 and L2 per core.
We talked about it. We saw that number from when I did the parameter of that. And here's what's fun. I also have on chip — this is on chip.
I also have a shared L3 across all cores. So all cores share this L3, which is pretty neat.
In conclusion — boy, bringing it all together — we have talked about caching. We spent four lectures talking about caching in detail. I mean, this is remarkable.
And caching shows up — as I mentioned before in one of my first lectures, caching's a big deal. Caching's a big deal in computer science.
That's one of the big ideas that we've contributed to the space. I don't know if caching — as an example, abstraction exists in engineering. There's abstraction.
You hide the details of how you have a shuttle flight or something, how you build a bridge. Abstraction is there.
I don't know if caching occurs in a non-computer engineering computer science context, if there's an equivalent thing like that.
I certainly know that I have — any kind of technology where I can make a simple copy of something it's there.
But if I don't make — if it's a physical element — I don't know if the idea of a cache and a memory hierarchy exists outside of a computer engineering computer science kind of idea.
But we certainly have software caches. And caches exists everywhere — file system caches, web page caches, game databases, table bases, phone most recent calls — all those things are caches.
Software memorization — my goodness, software memorization is a big — is a cache in some sense. As I'm walking through Fibonacci, why don't you just write it down as you're seeing it?
And so you're caching — have I seen it recently? Yes, I have. Forget about the recently part. But have I seen it before?
Yes. Well, grab it from my "cache" and my memorization storage. Same idea. So that same idea is with caches.
And again, the big idea is if something's expensive, we want to do it repeatedly, do it once and cache the result.
So if I have this computation that's being really heavy, I don't care what it is, do it once and remember what it is. That's what it is. That's the big idea in computing.
But it's also don't go to Sacramento. Don't compute it and spend an hour computing it. If I'm going to ask for it twice, compute it once, remember it.
Now I've got it for the second time, especially if it's a function and the output is only a function of its input.
So if it's somehow a function of all these other state elements, I can't cache it because it might be different. But if it's a pure function, certainly remember that for the next time.
Similarly, if I have to go to Sacramento, why go to Sacramento all the time? Bring it to some local space.
Don't have to go to the book to — I mean, imagine the world without caches. Really like Dumb & Dumber level. Okay, I'm going to write a paper.
I go to the — I look in the thing. I find the book. I get it out. I read one line of it.
Okay, great. Put it back. I start my paper. Oop.
What else did they say? I have to go get the book again. Are you kidding me? That's like going to Sacramento all the time.
Put it on your table. That's the cache. So the library analogy I introduced the first or second lecture, same idea here.
Go grab it and have it in a local space so it's handy, you can use it. That's the idea. A ton of knobs. Holy moly, how many knobs do you have?
How big is your cache overall? What's your technology behind that? What's your block size? How wide is your cache?
What's your write — what's your aspect ratio? Once you have your cache, is it fat and thin? Is it short and fat? Or one big block size?
Or is it really small block size and now it's really tall and skinny? What's my write policy? Write-through versus write-back — we talked about that. What's my associativity?
What's my knob for my n — for my m? Is it 1 or is it n? What's my block replacement policy? We talked about a couple of policies.
Do I have a second level cache? Do I have a third level? Oh my gosh.
But all that for a cache designer is just more freedom, more flex, more pens of an artist to draw whatever I want, to be able to create what I want to optimize for whatever usage case I have.
And again, there are software usage cases. There are hardware usage cases. All these things are out there for a cache designer, which, again, is not always a hardware designer.
Could be a software designer thinking about what parameters for the cache they want. And again, what's your metric? You're trying to think about you have some metric.
As you're having all these knobs, don't just — okay, I'll randomly set it. I'm good. Thanks so much. Where's the paycheck?
No, you go and you try to run it on traces. You run it on practice things. You see if it's performing. And you adjust, you tweak.
Maybe I'll change a block replacement policy. Maybe I'll make it more associative. All those things are parameters that you can play.
All the things listed here are things you can play with as you're trying to adjust it for whatever work, whatever traces you're going to be running on. Those are simulated traces.
May not be perfect, but it'll be a show me the example how I'm going to be hitting this cache in the future, thinking about that.
And use that performance model to adjust between all those choices. And also factor in your budget, factor in your technology, your budget, what's there. All of a sudden, Flash comes around.
How might that factor? I mean, that was really fun watching the computer engineering world as Flash became really interesting, where that fit in. By the way, your hard drive has a cache.
Go look at your hardware specs. There's a cache on your hard drive because going to disk — spinning disk — is really slow. So there'll be a cache on your hard drive.
Caches are everywhere. So think about what technology you have, the space based on, and think of your cost for your particular workload. That's it. Thank you so much for coming to these cache lectures.
I really had a good time teaching them to you. And we'll see you at the next module. Take care, folks.
Đă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.