9. What Compilers Can and Cannot Do

  Рет қаралды 78,332

MIT OpenCourseWare

MIT OpenCourseWare

Күн бұрын

Пікірлер: 57
@leixun
@leixun 4 жыл бұрын
*My takeaways:* 1. Why study the compiler optimizations? 4:05 2. Simple model of the compiler 8:30 3. Compiler report 9:33 4. Overview of compiler optimizations 13:20 5. Example compiler optimizations 26:00 - Optimizing a scalar 30:20 - Optimizing a structure 33:56 - Optimizing function calls 43:10 - Optimizing loops 56:05 6. WHat compilers can and cannot do 1:04:25 7. Diagnosing failures: case studies 1:06:30
@elliott8175
@elliott8175 4 жыл бұрын
@25:43, the reason for choosing 38 is because it's a dealing with a 32-bit integer on a 64-bit register, so we have an extra 32 bits to play with. 71 > 64 = 2^6, so magic_num = 2^38/71 is definitely less than 2^32, so num_32 * magic_num shifts the top bit by no more than num_32
@bibanez135
@bibanez135 2 жыл бұрын
Thank you for the explanation. 2^38/71+1=3871519817, which is the number that appear in the slides, so the +1 rounding is pre-calculated.
@abevigoda3149
@abevigoda3149 2 жыл бұрын
Those times when the compiler de-optimizes sections of your code or introduces elusive "bugs" in your code, similar to what happened to me when the MFC were still in development and I was programming for Win NT, the good "o'l" times.
@MikhailGoncharov-tl4cr
@MikhailGoncharov-tl4cr Жыл бұрын
Those times when the compiler de-optimizes sections of your code or introduces elusive "bugs" in your code, similar to what happened to me when the MFC were still in development and I was programming for Win NT, the good "o'l" times.
@robertplautz9722
@robertplautz9722 3 жыл бұрын
what a great teacher! thank you!
@WhiteDragon103
@WhiteDragon103 2 жыл бұрын
Ahem, the problem at 1:06:00 is very much optimizable by looking at a computation graph and seeing that the two sequences for F12 and -F21 are algebraically equivalent, without needing to know physics.
@bibanez135
@bibanez135 2 жыл бұрын
In the slide it says "unlikely" that it will do so, so maybe it could do it in some cases. Although, two numbers that resulted in the same were not necessarily calculated the same way, and I guess the compiler can be wary
@MikhailGoncharov-tl4cr
@MikhailGoncharov-tl4cr Жыл бұрын
@@bibanez135 please tell me in detail what you mean. give at least one example
@AlFredo-sx2yy
@AlFredo-sx2yy Жыл бұрын
"What about GCC? I have a 20 thousand line DIVINE intellect compiler that operates Just In Time AND ahead of time."
@SphereofTime
@SphereofTime Ай бұрын
16:51 compiler optimization
@proweiqi
@proweiqi 4 жыл бұрын
This is a great lecture
@TranscendentBen
@TranscendentBen 3 жыл бұрын
I just saw the video "restrict: the only C keyword with no C++ equivalent" - inexplicably, I'd never seen the restrict keyword before.
@lohphat
@lohphat 2 жыл бұрын
What frustrates me is that compilers don't take advantage of advanced instruction intrinsics automatically enough -- most of the modern CPU optimized SIMD/AVX instructions go unused. You have to manually construct SIMD usage most of the time which makes it a fools errand most of the time unless you're compiling code for your own system. If you're going to distribute compiled software, you have to dumb it down to a neutral architecture that doesn't risk using unsupported opcodes on the target system.
@danielkrajnik3817
@danielkrajnik3817 4 жыл бұрын
13:30 yeah not gonna lie they got us in the first half
@user-pg9te8ug1j
@user-pg9te8ug1j 2 жыл бұрын
Fantastic content. Chapeau to the tutor.
@abdulshabazz8597
@abdulshabazz8597 2 жыл бұрын
A compiler appears to choose optimal decision branches based upon the choices available. This methodology is similar to substitution networks in theorem provers. Perhaps theorem provers built into compilers will become the first A.I. driven constructs to achieve true sentience and artificial intelligence. Imagine a compiler that understands algebra, philosophy, and all scientific topics, including physics. With the ability to generate and reason over its own code, the compiler would become the ultimate decision maker.
@alang.2054
@alang.2054 Жыл бұрын
Bullshit. These all decisions magical compiler makes are just code, nothing more. Someone had to wrote this, maybe from some researcher's paper, nothing more. Stop hallucinating
@kewtomrao
@kewtomrao 2 жыл бұрын
For anyone wondering, eax is lower 32 bits of rax
@pschneider1968
@pschneider1968 2 жыл бұрын
I'm glad I don't have to write a compiler 😉🙏
@gsxrveli
@gsxrveli 2 жыл бұрын
teacher is beyond smart! Great lecture!
@sortof3337
@sortof3337 5 жыл бұрын
Thank you for this course. :)
@entaditorium
@entaditorium 2 жыл бұрын
As a compiler engineer, i was interested in the part where professor describes what compilers can't do. And what he describes appears to be true! It will be a real challenge to establish if two forces cancel each other. We could certainly encode rules (or laws of Physics for this example) as type constraints and then compiler may be able to figure that out but that is probably years ahead of the scope of modern compilers.
@bibanez135
@bibanez135 2 жыл бұрын
What the compiler can't do, it's what's implied for the current developer to optimize. Specifically simulations lend themselves to working out the math and solving it satisfyingly before implementing it in code
@MikhailGoncharov-tl4cr
@MikhailGoncharov-tl4cr Жыл бұрын
@@bibanez135 What the compiler can't do, it's what's implied for the current developer to optimize. Specifically simulations lend themselves to working out the math and solving it satisfyingly before implementing it in code
@erikvesa8850
@erikvesa8850 Жыл бұрын
Thank you for these lectures, this one was absolutely amazing 🎉
@SalesforceUSA
@SalesforceUSA 3 жыл бұрын
I don't know why KZbin recommended this to me, but I stayed for the whole lecture.
@shashikalaraju5769
@shashikalaraju5769 2 жыл бұрын
You must be knowledgeable with this sort of bend
@Rfc1394
@Rfc1394 3 жыл бұрын
I just realized why the '32 seconds' timing claim is wrong. Now, we can presume the processor has 16 cores, each with only one thread, that could execute 32 billion instructions per second. Except for one thing. Memory. Fastest memory DDR4-4400 has sustained transfer rate 4.4 gb/sec, throttling processors to that., and, ia64/AMD64 instructions run from 1-15 bytes each. If we estimate an average of 4 bytes per instruction, at that rate it requires 40 terabytes of ram, and that would require 4,000 seconds (6 1/2 hours) at the 4.4 ghz rate. Now there is a burst speed of 35gb/sec, so if you could run the memory that fast, at the 35gb/sec burst rate (and I don't think you'd get burst speed continuously) it would take about 120 seconds.
@abevigoda3149
@abevigoda3149 2 жыл бұрын
4,000 seconds = 1 hour 6 minutes 40 seconds... Just saying. Enough to not even check the rest of your "calculations" SMH
@ericksmith1974
@ericksmith1974 4 жыл бұрын
He even looks like a genious :)
@jilongzhang1851
@jilongzhang1851 4 жыл бұрын
I think he looks like Neymar :)
@sbalogh53
@sbalogh53 3 жыл бұрын
At first I thought he had an "interesting" beard, but then I forgot about his looks and listened intently to what he had to say. Great lecture.
@SphereofTime
@SphereofTime 9 ай бұрын
17:06
@pragmatic_p8
@pragmatic_p8 3 жыл бұрын
Watched this video to understand minisicule things in Optimization by compiler...hope this give me clear understanding in design of compilers and for my gate prep..
@hareeshr3791
@hareeshr3791 3 жыл бұрын
Are you preparing for GATE CS 2022?
@about2mount
@about2mount 3 жыл бұрын
The greatest computer language to develop a Lexical Analyzer and a Compiler for any computer language is CPython hands down. In fact CPython's Regular Expression re.sub() methods and string replace methods work in multiple algorithms nested and can handle the heavy lifting end of both exceptionally well. Under 280 lines of code will do both, and do some things today's compilers cannot do.
@MikhailGoncharov-tl4cr
@MikhailGoncharov-tl4cr Жыл бұрын
please give me the one example, for the learning
@alexyakoveno4682
@alexyakoveno4682 2 жыл бұрын
@w1d3r75
@w1d3r75 3 жыл бұрын
Hacker's delight book
@w1d3r75
@w1d3r75 2 жыл бұрын
@Pi Pony it contains a lot of tricks involving the use of bits operators
@w1d3r75
@w1d3r75 2 жыл бұрын
@Pi Pony I don't know anything about compilers or bit operations. I was mentioning the book
@ariloops
@ariloops 3 жыл бұрын
Werever dando clases.
@bramblebop1904
@bramblebop1904 Жыл бұрын
The guy stands there looking lime an über-dork in his charlie-chaplin pants and with the stupid beard, if you can call it that... Then he starts to talk, and my god. Perception totally changes, suddenly he's an athletic giant, lol. 👍 Intellect is attractive. 👍
@saddicticallee8090
@saddicticallee8090 2 жыл бұрын
Ok I I
@MikhailGoncharov-tl4cr
@MikhailGoncharov-tl4cr Жыл бұрын
please, if you are not difficult tell me the main conclusion of this video in one minute. please
@Er.Sunil.Pedgaonkar
@Er.Sunil.Pedgaonkar Жыл бұрын
But what is his education, CV? -- Er. Sunil Pedgaonkar, India, Consulting Engineer (IT), India
@JG_1998
@JG_1998 2 жыл бұрын
You have to be kind of sick in the head to think studying how a compiler works is fun ;). It is quite interesting, but it's definitely not "fun" for the average engineer/computer scientist. I guess that's why he's at MIT lol.
@imnikhil3831
@imnikhil3831 2 жыл бұрын
well if u gotta be a good coder, u've to know the inside out of what is going on, infact the shallow minds are lazy, stuck and might be sick as they seek quick results with little effort
@JG_1998
@JG_1998 2 жыл бұрын
@@imnikhil3831 i agree, which is why I'm watching this series on compiler design. I don't think I need to take the full class at my university, but it is helpful to know a decent amount about the compiler and not leave it as a black box.
@alang.2054
@alang.2054 Жыл бұрын
It is very fun for me, even I would call it more interesting than kernel / low level development, for sure more interesting than all these popular websh*t / business logic jobs
@hamiltonborah4834
@hamiltonborah4834 3 жыл бұрын
Here for neymar
10. Measurement and Timing
1:21:28
MIT OpenCourseWare
Рет қаралды 19 М.
6. Multicore Programming
1:16:46
MIT OpenCourseWare
Рет қаралды 141 М.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 20 МЛН
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
Let's Create a Compiler (Pt.1)
1:11:03
Pixeled
Рет қаралды 568 М.
Programming w/o Language
1:47:00
Tsoding Daily
Рет қаралды 61 М.
4. Assembly Language & Computer Architecture
1:17:35
MIT OpenCourseWare
Рет қаралды 730 М.
1. Introduction to 'The Society of Mind'
2:05:54
MIT OpenCourseWare
Рет қаралды 1,4 МЛН
1. Introduction and Matrix Multiplication
1:00:21
MIT OpenCourseWare
Рет қаралды 206 М.
How do computers read code?
12:01
Frame of Essence
Рет қаралды 3,1 МЛН
Evolution of software architecture with the co-creator of UML (Grady Booch)
1:30:43
The Pragmatic Engineer
Рет қаралды 36 М.
Just In Time (JIT) Compilers - Computerphile
10:41
Computerphile
Рет қаралды 281 М.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 20 МЛН