Understanding Compiler Optimization - Chandler Carruth - Opening Keynote Meeting C++ 2015

  Переглядів 128,094

Meeting Cpp

Meeting Cpp

8 років тому

Understanding Compiler Optimization
Chandler Carruth
Opening Keynote Meeting C++ 2015
Slides: meetingcpp.com/files/mcpp/201...

КОМЕНТАРІ: 81
@napat9
@napat9 3 роки тому
0:00: C++ performance based on compiler optimization 6:10: high level parts of compiler 9:10: LLVM's IR example, simple routine 10:22: LLVM's IR example, modelling data control flow 16:38: optimizer duties, cleanup 18:56: optimizer duties, canonicalization 22:26: optimizer duties, collapse abstractions 23:40: 3 key abstractions (function calls, memory, loops) 25:48: function calls abstraction, inlining 27:40: function calls abstraction, call graph 36:18: function calls abstraction, variadic functions 40:28: memory abstraction 44:20: memory abstraction (partitioning, isolating, other) 50:51: loop abstraction 54:30: loop abstraction, canonicalization 58:50: loop abstraction, loop unroll 1:04:00: loop abstraction, invariant control flow 1:09:00: loop abstraction, questions from audience 1:30:58: optimizing combined abstractions 1:35:30: const not optimized 1:37:52: conclusion and questions
@kadiyamsrikar9565
@kadiyamsrikar9565 2 роки тому
Thanx :)
@diegonayalazo
@diegonayalazo 2 роки тому
Thanks!
@kamilziemian995
@kamilziemian995 Рік тому
Thank you.
@inthegaps
@inthegaps 3 роки тому
Kudos to whatever genius decided to put the dot pattern at the back of the stage, so that any camera motion is distracting at best, and nauseating at worst.
@MeetingCPP
@MeetingCPP 3 роки тому
Yes, I hate that wall so much :/
@jacobschmidt
@jacobschmidt 3 роки тому
I didn't notice until you pointed it out :/
@DatMilu2K
@DatMilu2K 7 років тому
When he asked the crowd if they are excited about C++ I was totally with him. :D
@ChristopherGray00
@ChristopherGray00 Рік тому
How can you tell a C developer versus a C++ developer? The C++ developer is hyped for both, the C developer hates anything that is not C
@nickwilson1883
@nickwilson1883 Рік тому
@@ChristopherGray00 Usually c++ people complain about how bad C is all day and how you're a mongrel for not using C++
@nero512
@nero512 7 років тому
The first suggested video linked to this one is "Don't help the compiler" haha.
@ihatenumberinemail
@ihatenumberinemail 7 років тому
1:45:41 "once you have code that is clean on the sanitizers, then you know you have a compiler bug" "If we don't sanitize for it, we aren't going to optimize based on it" That guarantee makes me feel warm and fuzzy inside.
@KirillShvesov
@KirillShvesov 8 років тому
This cellular background makings me dizziness.
@wesofx8148
@wesofx8148 8 років тому
That wagon-wheel effect
@yemiez
@yemiez 8 років тому
+Kirill Shvesov Yea
@nicholasfazzolari3647
@nicholasfazzolari3647 8 років тому
Thanks for pointing it out. Now I'm dizzy :)
@malharjajoo6237
@malharjajoo6237 7 років тому
is making me dizzy*
@sorskilla
@sorskilla 4 роки тому
Holy shit! This.
@budiardjo6610
@budiardjo6610 7 місяців тому
8 years later this person build carbon language
@BossGxngOfficial
@BossGxngOfficial 5 місяців тому
Bruh are you Indonesian?
@budiardjo6610
@budiardjo6610 5 місяців тому
@@BossGxngOfficial sure
@BossGxngOfficial
@BossGxngOfficial 5 місяців тому
@@budiardjo6610 nyari teman dengan interested yang sama agak susah soalnya
@nathasion9556
@nathasion9556 3 роки тому
Chandler dude when someone asks you a question, please stop walking, and surely don't give him your back while walking. Also when there is a question in the public, please repeat the question so everyone knows what you are answering to....It is abc in public talking. Except that, brilliant lecture.
@MeetingCPP
@MeetingCPP 3 роки тому
I think he has learned that by now, video is from 2015.
@nathasion9556
@nathasion9556 3 роки тому
@@MeetingCPP haha well seen
@nnicolas17
@nnicolas17 6 років тому
The slides going out of sync made this really hard to follow.
@dkierans
@dkierans 3 роки тому
I know this is five years old but looking through this comment section is a bit sad. It’s a pretty good talk.
@kamilziemian995
@kamilziemian995 Рік тому
What a fantastic talk.
@jean-francoiscaron5706
@jean-francoiscaron5706 8 років тому
This is pretty hard to follow because the slide shown doesn't sync with the slide he's talking about. E.g. around 1:03:00 is pretty bad.
@jensw.6173
@jensw.6173 8 років тому
+Jean-Francois Caron Well, slides aren't recorded, so at some point it wasn't that easy to get it synced. But you can download the slides from Meeting C++.
@aaronr.9644
@aaronr.9644 6 років тому
Very interesting talk. I am not familiar with fortran so I did not exactly follow what he said at 1:20:59 . As for sanitizers, yes ubsan is cool but it is runtime. This is the type of stuff I want to catch with static analysis.
@szirsp
@szirsp 2 роки тому
20:40 Doesn't that discard potential branch prediction hint from the programmer who might know if it is going to be more likely for the 'if' condition to be true?
@OMARI-yp6dk
@OMARI-yp6dk 7 років тому
thank you very much sir
@nguonbonnit
@nguonbonnit Рік тому
Wow ! So great. You help me a lots.
@juzujuzu4555
@juzujuzu4555 5 років тому
I have been wondering, what kind of information we could provide within our source code, for example through annotations, that could help the compiler to optimize better or to allow completely new optimizations? We could add new annotations as we find more useful information for compilers. What kind of information the developer knows of how his code should work that the compiler could use?
@darkengine5931
@darkengine5931 3 роки тому
The top priority that comes to mind for me is hot/cold splitting of both branches and especially data. We have a lot in the way of indicating hot/cold branching paths with most compilers although they tend to be compiler-specific, such as 'likely' and 'unlikely' in GCC, '__assume' in MSVC, and 'noinline' and 'forceinline' available in most compilers. The trickier part is hot/cold splitting of data (and it tends to make the bigger difference in most domains). Consider an example like this: struct Particle { // hot fields constantly accessed in critical loops __hot float x=0.0f, y=0.0f, z=0.0f, w=0.0f; // cold field only accessed in non-performance critical UI areas __cold uint32_t q = 0; }; Ideally in a such a scenario, storing a collection of particles such as in std::vector would not store all particle fields in a contiguous interleaved format like 'xyzwqxyzwqxyzwq', since 'q' would not be accessed in those critical loops. Loading it into a cache line would just be loading irrelevant data into it and wasting it. Instead it should store the data like: 'xyzwxyzwxyzw....' with an array for the cold field(s) like 'qqqqqq....' in parallel. Things of this nature, or even being able to store an SoA representation of such a structure without collapsing it into multiple structures.
@OmarChida
@OmarChida 2 роки тому
@@darkengine5931 thanks this was very helpful :)
@ChristopherGray00
@ChristopherGray00 Рік тому
with o2 or o3 flag, the compiler isn't leaving out optimizations that you could otherwise specify with annotations, the idea is that it already does all of that for you, providing optimizations without the sacrifice of safety (as long as you are not using o3 then maybe)
@bobweiram6321
@bobweiram6321 3 місяці тому
Ada's strict type system specifies intent, which hints possible optimizations to the compiler.
@alexanderwesterstahl
@alexanderwesterstahl 8 років тому
Around 8 minutes in, the AST is mentioned, and dismissed as uninteresting for this subject. Isn't the AST a great place for optimizations?
@user-jq2tz6yw6p
@user-jq2tz6yw6p 8 років тому
AST is Front End level representation of a program, it is a good place to do language specific optimizations. LLVM Intermediate Representation level has no language specific (although it inherits some notions like memory model from C/C++11) and this is good from compiler architecture level. Here you see Clang AST, but what if you want to create other than C-like programming language? In this case you will have to create another Front End which produces its own AST so to be able to benefit from generic optimizations and machine code generation (this is already implemented in LLVM) it may translate it to LLVM IR and voila, you have a complete working compiler for a huge variety of target machines from Intel, AMD, ARM, and so on.
@alexanderwesterstahl
@alexanderwesterstahl 8 років тому
Пеш Любоп Thanks!
@Courserasrikanthdrk
@Courserasrikanthdrk 7 років тому
very descriptive :)
@diegonayalazo
@diegonayalazo 2 роки тому
Thanks
@SamualN
@SamualN 8 місяців тому
1:35 "they get ever smaller" he doesn't know
@nameguy101
@nameguy101 8 років тому
You didn't have to re-upload. Just add the tag "yt:stretch=16:9" to the original video.
@jensw.6173
@jensw.6173 8 років тому
+Nameguy didn't work & would also stretch the slides...
@karnajitw
@karnajitw 6 років тому
Awesome point 4:30
@User-cv4ee
@User-cv4ee 2 роки тому
I had fun learning something new but that's about the extent of it. I would not remember any of the details after a week, except for some key takeaways which could have been like 5 slides. Great talk nonetheless.
@ochgottnochma
@ochgottnochma 8 років тому
To help dem lost culture in germanies: The Goldilocks principle is derived from a children's story "The Three Bears" in which a little girl named Goldilocks finds a house owned by three bears. Each bear has its own preference of food and beds. After testing all three examples of both items, Goldilocks determines that one of them is always too much in one extreme (too hot or too large), one is too much in the opposite extreme (too cold or too small), and one is "just right".[1]
@jrmoulton
@jrmoulton Рік тому
@533rosy
@533rosy 7 років тому
What was the bug at 18.40?
@JohannesSchreiner1
@JohannesSchreiner1 7 років тому
The arguments to the phi-node are flipped!
@Shockszzbyyous
@Shockszzbyyous 7 років тому
i think i don't understand why must they be flipped to be right?
@andydufresne9387
@andydufresne9387 2 роки тому
those dots on the wall make me dizzy
@juzujuzu4555
@juzujuzu4555 5 років тому
It sucks that we can't unite and put our collective effort on researching better optimizations, tools and methods that allow those optimizations etc. How many devices we have that run C/C++ coded kernel and software? If those devices are battery powered, then saving CPU is having even more benefits. All major software and hardware giants should donate to this research, or participate at least somehow. Interesting question is what is theoretically possible, or what can we know for sure is or isn't possible, if we would have like exabyte of ram and exa instruction per second CPU and couple of days time to wait for the compiler to optimize. Perhaps in the future we compile the production quality version by sending our sources to supercomputer that does the optimization. While this sounds funny right now, there are still lots of thought behind these lines that hold truths. Anyway, bug free coding to you all =)
@azizas9366
@azizas9366 6 років тому
The prerequisite for this talk: Assembly language.
@TheBilly
@TheBilly 4 роки тому
The Intermediate Representation may resemble assembly language, but it is not. It is abstract, representing operations on values but not machine-level operations on memory locations and physical registers.
6 років тому
"The keyword inline has nothing to do with optimization"... Say that again?
@jonesconrad1
@jonesconrad1 5 років тому
it tells the compiler the symbol or function can appear in multiple translation units and not to freak out, it does not tell the compiler to inline it.
@greenfloatingtoad
@greenfloatingtoad 3 роки тому
It sometimes gives a hint to the compiler but the compiler is free to ignore it (or decide to inline something you didn't mark inline) The only guarantee is inline allows repeating the definition in multiple translation units
3 роки тому
@@jonesconrad1 But it allows it, so it has something to do with it, a lot actually #ThatsWhyPeopleUseInlinePrimarily
@TheEVEInspiration
@TheEVEInspiration 6 років тому
Compiler and language builders are doing something wrong if they consider "const" as not helpful. It is information and can be a guarantee something does not get modified. That the "constness" can be casted away for out of program "API reasons" is no excuse. Having such a cast anywhere else in the code is just as bad as a non-atomic memory access in a multi-threaded application and would just be a bug. People link libraries, and especially there, knowing a provided argument will not change during a library call is gold. There is no other way to optimize that case with the same guarantee that the argument will not change. It is not the first time I seen this attitude among language and compiler builders and it annoys me quite a bit.
@Verdagon
@Verdagon 5 років тому
(Not counting const_cast) I believe you're mixing up "const" with "immutable". When I have a const reference to something, there's a guarantee that I won't change it, but there's no guarantee that nobody else will change it. See stackoverflow.com/questions/4486326/does-const-just-mean-read-only-or-something-more I think what you want is a language that takes immutability into account, so you'd want something like functional languages or Rust.
@nicolasabramlujan
@nicolasabramlujan 4 роки тому
I believe you could make an argument that that's a language level issue and not really the compiler's fault
@whydoineedausername1386
@whydoineedausername1386 4 роки тому
@@Verdagon Rust pretty much ignores immutability when compiling because LLVM is so buggy when you have so many consts. Yes really. It used to but then they had to disable it because of LLVM bugs
@SolomonUcko
@SolomonUcko 3 роки тому
@@Verdagon stackoverflow.com/questions/57259126/why-does-the-rust-compiler-not-optimize-code-assuming-that-two-mutable-reference/57259339#57259339
@Courserasrikanthdrk
@Courserasrikanthdrk 7 років тому
the alk gave me idea about compiler innerworking....................
@Fl4shback
@Fl4shback 7 років тому
Claiming that C++ is the fastest with least overhead and totally forgetting about C.... Not saying that C is completly superior but it is still quite relevent in these aspects...
@MeetingCPP
@MeetingCPP 7 років тому
Well, C++ is superior, as it has access to a different feature set, that isn't available to C. While C is a subset of C++...
@cthutu
@cthutu 7 років тому
I disagree. In theory it can be but in practice it isn't due to way C++ is normally used. The way C++ classes tend to be organically made plays havoc with the cache and is very anti-data-oriented.
@Fl4shback
@Fl4shback 7 років тому
Saying that C is a subset of C++ is completly wrong. They are different languages with different grammar. Expressions can be valid in one but illegal in the other. And BECAUSE of the bigger "feature set" it starts with a disadvantage for optimization, given that nowadays this is not really an issue. Still if C++ would be superior in every aspect then C would not be the number 1 language in embedded development( at least this is what I last saw in usage polls). Still I don't say C is generally superior, I just say C++ is not generally better than C nor is C a subset of C++. They evolved differently.
@Dima-ht4rb
@Dima-ht4rb 6 років тому
Spot C programmer.
@kristupasantanavicius9093
@kristupasantanavicius9093 5 років тому
C++ is a mix of high level Java like programming mixed with the possibility of using pure C anytime you desire. That is what makes it so powerful.
🔥 Україна виходить у ФІНАЛ ЄВРОБАЧЕННЯ-2024! Реакція alyona alyona та Jerry Heil #eurovision2024
00:10
Євробачення Україна | Eurovision Ukraine official
Переглядів 175 тис.
Піхотинець - про рутину на фронті
00:46
Суспільне Новини
Переглядів 521 тис.
TDD for Microcontrollers - Daniel Penning - Meeting C++ 2023
53:35
Meeting Cpp
Переглядів 1,8 тис.
CppCon 2015: Sean Parent "Better Code: Data Structures"
1:04:00
CppCon
Переглядів 100 тис.
CppCon 2015: Herb Sutter "Writing Good C++14... By Default"
1:29:06
Игровой ноутбук за 100тр в МВИДЕО
0:58
KOLBIN REVIEW
Переглядів 361 тис.
Радиоприемник из фольги, стаканчика и светодиода с батарейкой?
1:00
wyłącznik
0:50
Panele Fotowoltaiczne
Переглядів 853 тис.
Creepy Samsung Alarm cannot be turned off 😱🤣 #shorts
0:14
Adani Family
Переглядів 1 млн