9. What Compilers Can and Cannot Do

Поделиться
HTML-код
  • Опубликовано: 24 ноя 2024

Комментарии • 57

  • @leixun
    @leixun 3 года назад +69

    *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 года назад +19

    @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 года назад +1

      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 года назад +7

    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 года назад +14

    what a great teacher! thank you!

  • @WhiteDragon103
    @WhiteDragon103 2 года назад +3

    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 года назад +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 Год назад +1

      @@bibanez135 please tell me in detail what you mean. give at least one example

  • @AlFredo-sx2yy
    @AlFredo-sx2yy Год назад +3

    "What about GCC? I have a 20 thousand line DIVINE intellect compiler that operates Just In Time AND ahead of time."

  • @lohphat
    @lohphat 2 года назад +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.

  • @kewtomrao
    @kewtomrao 2 года назад +3

    For anyone wondering, eax is lower 32 bits of rax

  • @pschneider1968
    @pschneider1968 2 года назад +5

    I'm glad I don't have to write a compiler 😉🙏

  • @TranscendentBen
    @TranscendentBen 3 года назад +4

    I just saw the video "restrict: the only C keyword with no C++ equivalent" - inexplicably, I'd never seen the restrict keyword before.

  • @user-pg9te8ug1j
    @user-pg9te8ug1j 2 года назад +2

    Fantastic content. Chapeau to the tutor.

  • @abdulshabazz8597
    @abdulshabazz8597 2 года назад +1

    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

  • @danielkrajnik3817
    @danielkrajnik3817 3 года назад +11

    13:30 yeah not gonna lie they got us in the first half

  • @proweiqi
    @proweiqi 4 года назад +10

    This is a great lecture

  • @gsxrveli
    @gsxrveli 2 года назад

    teacher is beyond smart! Great lecture!

  • @erikvesa8850
    @erikvesa8850 Год назад

    Thank you for these lectures, this one was absolutely amazing 🎉

  • @entaditorium
    @entaditorium 2 года назад +1

    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 года назад +1

      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

  • @sortof3337
    @sortof3337 5 лет назад +5

    Thank you for this course. :)

  • @Rfc1394
    @Rfc1394 2 года назад +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 года назад +2

      4,000 seconds = 1 hour 6 minutes 40 seconds... Just saying.
      Enough to not even check the rest of your "calculations" SMH

  • @SphereofTime
    @SphereofTime Месяц назад

    16:51 compiler optimization

  • @pragmatic_p8
    @pragmatic_p8 3 года назад +1

    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 года назад +1

      Are you preparing for GATE CS 2022?

  • @ericksmith1974
    @ericksmith1974 4 года назад +6

    He even looks like a genious :)

    • @jilongzhang1851
      @jilongzhang1851 4 года назад +1

      I think he looks like Neymar :)

    • @sbalogh53
      @sbalogh53 3 года назад +1

      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.

  • @SalesforceUSA
    @SalesforceUSA 3 года назад +4

    I don't know why RUclips recommended this to me, but I stayed for the whole lecture.

  • @about2mount
    @about2mount 3 года назад +2

    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.

  • @alexyakoveno4682
    @alexyakoveno4682 2 года назад

  • @w1d3r75
    @w1d3r75 3 года назад +2

    Hacker's delight book

    • @w1d3r75
      @w1d3r75 2 года назад +1

      @Pi Pony it contains a lot of tricks involving the use of bits operators

    • @w1d3r75
      @w1d3r75 2 года назад +1

      @Pi Pony I don't know anything about compilers or bit operations. I was mentioning the book

  • @ariloops
    @ariloops 3 года назад

    Werever dando clases.

  • @MikhailGoncharov-tl4cr
    @MikhailGoncharov-tl4cr Год назад

    please, if you are not difficult tell me the main conclusion of this video in one minute. please

  • @SphereofTime
    @SphereofTime 9 месяцев назад

    17:06

  • @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. 👍

  • @Er.Sunil.Pedgaonkar
    @Er.Sunil.Pedgaonkar Год назад

    But what is his education, CV? -- Er. Sunil Pedgaonkar, India, Consulting Engineer (IT), India

  • @saddicticallee8090
    @saddicticallee8090 2 года назад

    Ok I I

  • @JG_1998
    @JG_1998 2 года назад +8

    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 года назад +1

      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 Год назад +3

      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