Lex Fridman PodcastChris Lattner: Compilers, LLVM, Swift, TPU, and ML Accelerators | Lex Fridman Podcast #21
EVERY SPOKEN WORD
145 min read · 28,512 words- 0:00 – 1:10:40
Intro
- LFLex Fridman
The following is a conversation with Chris Lattner. Currently, he's a senior director at Google working on several projects, including CPU, GPU, TPU accelerators for TensorFlow, Swift for TensorFlow, and all kinds of machine learning compiler magic going on behind the scenes. He's one of the top experts in the world on compiler technologies, which means he deeply understands the intricacies of how hardware and software come together to create efficient code. He created the LLVM Compiler Infrastructure Project and the Clang compiler. He led major engineering efforts at Apple, including the creation of the Swift programming language. He also briefly spent time at Tesla as vice president of Autopilot Software during the transition from Autopilot Hardware 1.0 to Hardware 2.0, when Tesla essentially started from scratch to build an in-house software infrastructure for Autopilot. I could have easily talked to Chris for many more hours. Compiling code down across the levels of abstraction is one of the most fundamental and fascinating aspects of what computers do, and he is one of the world experts in this process. It's rigorous science, and it's messy, beautiful art. This conversation is part of The Artificial Intelligence Podcast. If you enjoy it, subscribe on YouTube, iTunes, or simply connect with me on Twitter @lexfridman, spelled F-R-I-D. And now here's my conversation with Chris Lattner. What was the first program you've ever written?
- CLChris Lattner
My first program-
- LFLex Fridman
Hmm, back. And when was it?
- CLChris Lattner
I think I started as a kid, and my parents got a BASIC programming book. And so when I started, it was typing out programs from a book, and seeing how they worked, and then typing them in wrong and trying to figure out why (laughs) they were not working right, that kinda stuff.
- LFLex Fridman
So BASIC. What was the first language that you remember yourself maybe falling in love with, like really connecting with?
- CLChris Lattner
Oh. I don't know, I mean, I feel like I've learned a lot along the way and, and each of them have a different special thing about them. So I started in BASIC and then went, like, GW-BASIC, which was the thing back in the DOS days, and then upgraded to QBasic and eventually QuickBASIC, which are all slightly more fancy versions of Microsoft BASIC. Um, made the jump to Pascal and started doing machine language programming in Assembly in Pascal, which was really cool. Turbo Pascal was amazing for its day. Um, eventually got into C, C++, and then kinda did lots of other weird things, so.
- LFLex Fridman
I feel like you took the dark path, which is the, uh... You coulda, you coulda gone Lisp.
- CLChris Lattner
Yeah, yeah.
- LFLex Fridman
You coulda gone higher level-
- CLChris Lattner
Yeah.
- LFLex Fridman
... sort of functional, philosophical, hippie route.
- CLChris Lattner
Yeah.
- LFLex Fridman
Instead, you went into, like, the dark arts-
- CLChris Lattner
Yeah.
- LFLex Fridman
... of the C++.
- CLChris Lattner
It was straight, straight into the machine, right?
- LFLex Fridman
Straight to the machine.
- CLChris Lattner
And so I s- so started with BASIC, Pascal, and then Assembly, and then wrote a lot of Assembly. And, um-
- LFLex Fridman
Why? How?
- CLChris Lattner
Eventually, eventually did Smalltalk and other things like that.
- LFLex Fridman
Yeah. (laughs)
- CLChris Lattner
But that was not the starting point.
- LFLex Fridman
But, so what, uh, what is this journey into C? Is that in high school? Is that in college?
- CLChris Lattner
That was in high school, yeah. So, and, and then that was, uh, it was really about trying to be able to do more powerful things than what Pascal could do and also to learn a different world. C was really confusing to me with the pointers and the syntax and everything, and it took a while. But Pascal's much more principled in various ways. C is more the, I mean, it has its historical roots, but it's, it's not as easy to learn.
- LFLex Fridman
With pointers, there's this memory management thing that you have to become conscious of. Is that the first time you start to understand that there's resources that you're supposed to manage?
- CLChris Lattner
Yeah. Uh, well, so you have that in, in Pascal as well, but in Pascal, they s- like the caret instead of the star and thing. There's some small differences like that, but it's not about, uh, pointer arithmetic. In p- in, in C, it, you end up thinking about how things get laid out in memory a lot more.
- LFLex Fridman
Mm-hmm.
- CLChris Lattner
And so in Pascal, you have allocating and deallocating and owning the, the memory, but just the programs are simpler and you don't have to... Well, for example, Pascal has a string type, and so you can think about a string instead of an array of characters which are consecutive in memory, yeah? So it's a little bit of a higher level abstraction.
- LFLex Fridman
So, uh, let's get into it. Let's talk about-
- CLChris Lattner
Yeah.
- 1:10:40 – 1:13:11
Dragons
- CLChris Lattner
- LFLex Fridman
So last question. LLVM logo is a dragon.
- CLChris Lattner
Yeah.
- LFLex Fridman
You explain that this is because dragons have connotations of power, speed, intelligence. It can also be sleek, elegant, and modular, though you remove the, the modular part. What is your favorite dragon-related character from fiction, video, or movies?
- CLChris Lattner
So those are all very kind ways of explaining it. The... Do you wanna know the real reason it's a dragon?
- LFLex Fridman
Well, y- yeah. Yeah, let's... (laughs)
- CLChris Lattner
(laughs) Is that better? So there's a, a seminal book on compiler design called The Dragon Book. And so this is a really old now, uh, book on compilers. And so, um-
- LFLex Fridman
(laughs)
- CLChris Lattner
... th- the, the dragon logo for LLVM came about because at Apple we kept talking about LLVM-related technologies and there was no logo to put on a slide.
- LFLex Fridman
Right. (laughs) Yeah.
- CLChris Lattner
And so we're like, "What, what do we do?" And somebody's like, "Well, what kind of logo should a compiler technology have?" And I'm like, "I don't know. I mean, the dragons are... a dragon is the best thing that, that we've got." And, you know, Apple somehow magically came up with the logo and-
- LFLex Fridman
(laughs)
- CLChris Lattner
... and it was a great thing and the whole community rallied around it. And, uh, and then it got better as other graphic designers got involved. But that's, that's originally where it came from.
- LFLex Fridman
Good story.
- CLChris Lattner
Yeah.
- LFLex Fridman
Is there dragons from fiction that you connect with for, uh, that, uh-
- CLChris Lattner
Yeah.
- LFLex Fridman
... Game of Thrones, Lord of the Rings, that kind of thing?
- CLChris Lattner
Uh, Lord of the Rings is great. I also like role-playing games and things like inpu- computer role-playing games. And so dragons often show up in there. But, but really it comes back to, uh, to...
- LFLex Fridman
To the book.
- CLChris Lattner
Oh no, we need, we need a thing. What do we do?
- LFLex Fridman
Yeah.
- CLChris Lattner
And, and hilariously, one of the, one of the, the funny things about LLVM is that my wife, who's amazing, runs the, the LLVM Foundation, and she goes to Grace Hopper and is trying to get more women involved in the... She's also a compiler engineer, so she's trying to get other, other women to get interested in compilers and things like this. And so she hands out the stickers and people like the LLVM sticker because of Game of Thrones.
- LFLex Fridman
(laughs)
- CLChris Lattner
And so sometimes culture has this-
- LFLex Fridman
Yeah.
- CLChris Lattner
... helpful effect to, like, get the next generation of compiler engineers engaged f- with the cause.
- LFLex Fridman
(laughs) Okay. Awesome. Chris, thanks so much for talking to me today.
- CLChris Lattner
Yeah, it's been great talking with you.
Episode duration: 1:13:05
Install uListen for AI-powered chat & search across the full episode — Get Full Transcript
Transcript of episode yCd3CzGSte8