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
Oh, sorry. I didn't see you there, didn't see you there. Hold on. Let me just pass this on to my friend.
Welcome to CS61C, caches part one. Woo! Great to see you as always. Let's get right in.
So we're first going to learn about something called the binary prefix.
This is really important as you're learning about caches and as you're learning about how to work with 2 to the blank blank, what does that even mean, how to think about how many bits in code, a certain space.
All those things we'll learn in this next very short video. So let's go back in time. Do-da-loo, do-da-loo, do-da-loo. We had kilo, mega, tera, peta, exa, zetta, yotta.
And these were commonly used to SI. Systeme international, I believe it's called — prefixes that we use for things. So if you had — I got a kilo.
I got a ki. This is like Scarface. I got a ki. If you got a ki of something, that's a kilo.
It's 1,000 of something. But in fact, people were using a kilo describe powers of 2.
You notice that the difference — there's a big difference between — only a very small difference between something here is base 10 of something and this thing that we didn't have a name for 1,024.
That adds a little bit. But as you continue to grow, well, how about a mega? I got a mega something. It's a million.
But here, it started at 48,000. Now it's a little bit bigger than that. And as you continue to grow — notice it here — you're now off by a full, say, 20%.
So there's an issue, and we never really had a solution to this.
There is a historical note you see there in the second bullet, which is hard disk manufacturers started years and years ago by using powers of 2.
You notice powers of 10 are smaller than powers of 2. And so they'd say, I have a hard drive that was a 10 meg hard drive.
That used to be 2 to the 20 times 10, , so that was 10 of mega, which is 2 to the 20 bytes.
And they realized, wait, if we actually use the proper terminology, mega is a million, and a million is smaller than this 2 to the 20. So they decided to then move to using that.
So in fact, if you get a 10 meg drive — and nobody gets 10 meg — no, 10 gig drive now, 10 terabyte drive. It's not the left column of powers of 2.
It's the right column of powers of 10. And so they realized they can be a little cheap on things. So when you format it, it's not only — formatting, there's also some overhead.
But the point is you don't get a drive that's actually in its power of 2. Even raw bits, it's a power of 10, not powers of 2.
And we also use — in networking, we use the base 10 for networking. So if I have a gigabit network, it is a 10 to the ninth bits per second.
That's always been that way, and that's fine. So network transmission is base 10. Hard drives are base 10. But everything else — caches, memory, everything else — is base 2.
And so we want to make sure that we talk about this in the right way. I can't just say a kilo. How big is your cache? A kilo, it's kilobyte.
Well, do you mean 1,000 bytes? Or do you mean 1024? Let's actually make sure we have a distinct word for that. We can't just keep using kilo.
We can't keep overloading kilo. Enter the IEC, International Electrotechnical Commission in 1999 — a big deal — introduced these binary prefixes.
And the idea was they kept the same columns as you had before, K, M — as you see up top, K, M, G, T, P, E, Z, Y, except that they added a little bit of an I here.
So each of these, you see there's a little I in front of them. And in fact, the way they pronounce them, it's the kilo and the mega, and they give you.
So the first two letters are the same. But then, they add B-I binary to make it distinct.
But rather than call it B-I — so rather than "kay-buy," "meh-buy," they wanted it — maybe it sounded better to call it "bi."
So it's "meh-bi" — kibi, mebi, gibi, tebi, pebi, exbi, zebi, and yobi. That's how you pronounce them. And now we have distinct meanings, and that's just great.
So now we can be saying, oh, I got a 10 tebi drive. I know I'm 2 to the 40, not 10 to the 12. So that's great much, much better there.
You're going to ask yourself, well, how do you memorize these things?
If I say that — and you want to be able to make a connection between what, at the least, the order of it is.
So this is a fun challenge I offered to 61C students years ago. And I said, come up with a mnemonic. Come up with a way to remember this sequence that no one else has.
I think this is a Berkeley invention, the way to remember these. So feel free to use any of these 10 I'm going to show you, whichever one kind of rings true to you.
So let's jump right in. "Kid meets giant Texas people exercising zen-like yoga." And I try to actually give credit to the student who did that.
I want to give him some anonymity with the last name. But I gave their first name. And in the challenge, I made sure the first two letters are the same, first two letters, everybody.
So you can — once you say, "K-I," make any word with K-I star. It's M-E star, et cetera. "Kind men give ten percent extra, zestfully, youthfully." That's pretty cool.
Some of these are pretty good. "Kissing mentors gives testy persistent extremists zealous youthfulness. Kindness means giving, teaching, permeating excess zeal yourself."
I feel like I connected to that one myself. "Killing messengers" — don't kill the messenger, right? "Killing messengers gives terrible people exactly zero, yo.
You have to do the hand — yo with the hand. This is the yo hand. I hope I'm not giving some gang sign out there.
"Kindergarten means giving teachers perfect examples of zeal and youth." I love that. "Kissing mediocre giraffes teaches people to expect zero from you.
Kinky mean girls teach people exciting zen yoga. Kissing Mel Gibson, Teddy Pendergrass exclaimed, 'Zesty, yo.'" That's the one I remember, actually.
When I'm thinking, is it Z-Y? I'll actually say that one. I'm revealing a little bit of my head here. I actually say that one when I try to remember it.
Is it E-Z? Is it E-Z-Y, E-Y-Z? I use that one if I get stuck. And here's my favorite one.
And it's not the one I use, but it's my favorite one. "Kissing me gives ten percent extra zeal and youth." So tell that to your friends.
Tell their friends — not talking about kissing Dan, but kissing yourself. Hey, Ralph. What Sue? Kissing me gets 10% extra zeal and youth.
Woo! Anyway, whatever you decide to use, pick one of these. Make your own up. But remember the sequence this year, where all of our exams are going to be open book.
But in the future, we might go back to closed book, and we'd like to be able to have you memorize this. So this is a good thing. What is 2 to the 34?
How many bits to address that? How many bits to address 2.5 tebibytes of something? So these are two questions that you might want to be able to answer quickly.
And in fact, I encourage you as a 61C soon-to-be graduate to be able to be fluent in this space.
So the way I think of it is I want you to memorize these two tables.
In fact, I'm going to actually have a little sound here to say please do think about memorizing these tables.
And the way to do this, the way to know how to do this, is the following. 2 to the xy — x is the tens column, and y is the ones column.
I start with the ones column. And it's really easy to memorize this one. Let me just grab. So you want to be memorizing this sequence right here.
So 0, 1, 2, 4, 8, 16, 32 — we're up to five now — six, 64. I'm not even looking. I'm closing my eyes — 64, 128. 256 is eight.
That's another important one because 8 bits used to control 256 different color channels for a standard, old-school monitor, including the PPMs we worked with if you did 61C this semester when we had a project assignment that had PPMs.
Nine, 512 — and then, 10, well, 10 is the next one. So that's all you got to remember, so those nine.
And then, you go back to the kibi, mebi, gibi, tebi, pebi, exbi, zebi, yobi, and you had that sequence. And that is the x. That's the tens column.
So very quickly, ready? 34 — in my brain, I'm saying 4 is 16. See, look? I'm not looking.
4 is 16. 30 is — well, the 30s is gibi. So I'd say 16 gibi. Did I get it right?
I did. That's pretty cool. So let's do another one. I almost feel like I have a random thing.
Here you go, 47. 128, tebi. Pretty cool. 64 — man, I got a 64-bit address space.
How many bytes of memory can I access? 64 — 16, exbi. Wow, that's pretty cool. So continue to think about that.
And now, the reverse of that is the following. If I say I want to be able to address 2.5 tebibytes, well, how many is that?
Well, what you do is you take 2.5, and you take the ceiling of that. What's the next biggest power of 2 above that? 2.5 is bigger than 2, so it'd be 4.
So I'd say 4. That'd be 2. So I'm going to say something 2. Tebi is 4, so I'd say 42.
I think you need 42 bits to address 2.5 tebibytes because 42 bits is 4 tebi. And 4 tebi is the next big power of 2 above 2.5 tebibytes.
So we often call this the IEC numbers, but binary prefixes is the right name. So from now on, this is the beginning lecture on caches.
And this lecture really could have gone — in fact, maybe I'm MOOCifying these lectures into small pieces.
It could have really gone the first lecture because it would have been fun to have this, be fluent about this from the beginning of the semester.
But you don't really need it until caches, and so this is in the cache lecture. But I hope in the future this lecture is in the front.
And feel free to ignore this a little bit about if it actually is in the front why we should move it because it already is moved if we happen to do that.
You didn't understand that, but that's fine. We'll see you at the next lecture, and we'll learn more about caches. Thanks.
Đă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.