Five things you didn't realise your CPU did for you

  Рет қаралды 31,717

Matt Godbolt

Matt Godbolt

Күн бұрын

Пікірлер
@livedandletdie
@livedandletdie 5 жыл бұрын
All my CPU does is overheat, travel to other dimensions, take really really really long vacations, sleeps a lot, and seriously believes that playing solitaire requires 100% CPU power...
@tititwist46
@tititwist46 5 жыл бұрын
its predicting every possible future where you dont win the game and trying to find a future where you do. its still looking
@vintyprod
@vintyprod 5 жыл бұрын
its making friends with some Trojans
@PASTRAMIKick
@PASTRAMIKick 4 жыл бұрын
I just realised you're the guy who made the Godbolt Compiler Explorer, it's a great tool you have my thanks for it.
@MattGodbolt
@MattGodbolt 4 жыл бұрын
Thanks :)
@Xiefux
@Xiefux 5 жыл бұрын
i always thought the cpu was just a rock with lightning in it
@emiliancioca
@emiliancioca 6 жыл бұрын
Short and sweet video :) You caught me with SSA. Never heard about it before. I would have assumed this kind of optimization would still remain the responsibility of the compiler. However, it seems like this can be a way to increase the number of effective registers without having to update the x86 standard (or having to recompile and re-distribute executables). Super cool!
@MattGodbolt
@MattGodbolt 6 жыл бұрын
Absolutely. In the processor the technique is called "Register Renaming". Some CPUs of course have a load more registers, but there's a trade-off between the encoding of the instructions which refer to those registers, and the utility of having explicit control over which registers are used. Register renaming is a cute trick to make more use with fewer architectural registers.
@Diamonddavej
@Diamonddavej 5 жыл бұрын
A CPU generates a similar heat flux as a nuclear reactor fuel rod (100 Watts/cm2 v's125 Watts/cm2).
@dikhim
@dikhim 5 жыл бұрын
Not so much as a lightbulb :)
@Diamonddavej
@Diamonddavej 5 жыл бұрын
@@dikhim I wonder... www.physicsforums.com/threads/surface-area-of-a-bulb-filament.721597/
@rssven1827
@rssven1827 5 жыл бұрын
3.5 roentgen not good but not too bad either
@swimfan313
@swimfan313 5 жыл бұрын
Does this not create a vulnerability in the process by where you could inspect the speculated branches and then by process of elimination get an estimation of the branch that succeeded?
@Revoker1221
@Revoker1221 2 жыл бұрын
I'm a couple of years late, but to answer your question and anyone else wondering the same thing: Yes, yes it does create a pretty significant vulnerability. The vulnerability was called something like "Spectre", there were a number of different flavours of it, and while some of the vulnerability could be patched on the software side of things, there were some flavours that would require a hardware fix. For more info, this CppCon talk should be quite illuminating: kzbin.info/www/bejne/lZeagGZ_m66FaM0 Interestingly enough, the person giving the presentation gave a presentation the previous year about speculative branching, so if you want to learn more about that with some better visualisations and explanations, check out his talk from the year earlier.
@Das_Unterstrich
@Das_Unterstrich 5 жыл бұрын
My CPU doesn't allows me to open 2 chrome tabs at once.
@abdullahamrsobh
@abdullahamrsobh 3 жыл бұрын
Actually that would be problem with your ram
@foxl9195
@foxl9195 2 жыл бұрын
3:10 What if both rsi and rdi point to the same memory address? How does CPU handle this case?
@MattGodbolt
@MattGodbolt 2 жыл бұрын
Great question! There is a considerable amount of magic here - there's load and store queues which can forward the data (if ready), and if not there are hazard detectors that notice when the data being read by a later instruction was actually modified; and then the load needs to be re-run.
@foxl9195
@foxl9195 2 жыл бұрын
Awesome. Thanks, Matt!
@Spike8119
@Spike8119 4 жыл бұрын
Rip spectre and meltdown abusing these fun concepts
@iconjack
@iconjack 2 жыл бұрын
4:14 What if rsi == rdi?
@MattGodbolt
@MattGodbolt 2 жыл бұрын
I replied in a comment below (by Fox L) - short version is there's magic (load/store forwarding and various tracking) that will restart the instructions if it's found to alias afterwards. www.agner.org/optimize/microarchitecture.pdf has lots of info on this (look for "store forwarding" and "memory intermediates in depedendency chains"). I also heartily recommend www.amazon.com/Modern-Processor-Design-Fundamentals-Superscalar/dp/1478607831 if you like this kind of stuff!
@conflagrationTuesday
@conflagrationTuesday 5 жыл бұрын
GREAT video! You say 'parallel' quite a lot.. Do you mean literally simultaneously on another CPU thread/core?
@MattGodbolt
@MattGodbolt 5 жыл бұрын
Literally simultaneously. Modern CPUs can be running many tens of instructions at once on a single thread on a single core
@billthemanofgoodnis
@billthemanofgoodnis 6 жыл бұрын
Nice video!
@deckard5pegasus673
@deckard5pegasus673 Жыл бұрын
And just imagine all the extra complication, just because the CPU is faster than RAM access. If someone could speed up RAM access times... The most interesting imo, is the CPU RISC microcode. In the end RISC won, ARM and Apple M1 are more popular due to phones than Intel/AMD. And the icing on the cake is Intel/AMD are also RISC. x86 is on life support, and I guess probably only kept alive by the ancient Win-Tel Pact (more bloated OS needs faster CPU Pentium XXX-Ultra-power...requiring a new computer ever 2 years consumer scam) and the fact that even modern windows is still running NT/Win32 at it's core. "It was then that I learned that computers were built to make money, not minds." - Gary Kildall (Pioneering Lengend).
@cdriper
@cdriper Жыл бұрын
I already know all 5 points. Where can I obtain my gold medal? )
@MattGodbolt
@MattGodbolt Жыл бұрын
Here: *medal* :D
@thompsonevergreen8006
@thompsonevergreen8006 5 жыл бұрын
My Intel cpu, it got my back, my Intel cpu, it do me proud, my Intel cpu, it be my bro, my Intel cpu it never let me down
@GodofAshes
@GodofAshes 5 жыл бұрын
Except for Meltdown, Spectre and Zombieload, collectively responsible for slowing your CPU down by up to 30% (or your OS by 75%, if you're on MacOS) - These are things that make me wish I hadn't bought that i7, and instead bought an AMD Ryzen CPU.
@thompsonevergreen8006
@thompsonevergreen8006 5 жыл бұрын
@@GodofAshes no one likes you
@GodofAshes
@GodofAshes 5 жыл бұрын
@@thompsonevergreen8006 Thank you, that means a lot to me :')
@elgoog-the-third
@elgoog-the-third 5 жыл бұрын
Your Intel CPU, it's overpriced, your Intel CPU, it heats your house, your Intel CPU, it's full of bugs
@Motscoud
@Motscoud 5 жыл бұрын
My intel cpu, it leaks my data, my intel cpu, it's got more holes than swiss cheese, my intel cpu, it heats up my room, my intel cpu, it's performance drops daily
@kriskeersmaekers233
@kriskeersmaekers233 5 жыл бұрын
With 1. You're actually wrong about that, it will already hit on the second cache as it already pulls a bunch of neighboring memory for exactly this reason
@MattGodbolt
@MattGodbolt 5 жыл бұрын
Which part specifically are you referring to? Cache misses of course pull in neighbouring memory: the whole cache line. However the caches also use patterns in cache misses to pre-emptively start fetching. I have a much longer talk that goes into this in a little more detail, and you can read a lot more about it if you Google for Ulrich Drepper's "What every programmer should know about memory" paper
@Xtcent
@Xtcent 5 жыл бұрын
I wonder what i am going to do with this information. smh
Meltdown And Spectre
48:03
Matt Godbolt
Рет қаралды 31 М.
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
Coding is Difficult Until You Know These 5 Steps
6:17
MicroDegree ಕನ್ನಡ
Рет қаралды 797
Compiler Explorer (part 1 of 2)
11:59
Matt Godbolt
Рет қаралды 26 М.
why are switch statements so HECKIN fast?
11:03
Low Level
Рет қаралды 435 М.
When Optimisations Work, But for the Wrong Reasons
22:19
SimonDev
Рет қаралды 1,1 МЛН
The world's worst video card?
32:47
Ben Eater
Рет қаралды 6 МЛН
Wolfenstein 3D's map renderer
14:49
Matt Godbolt
Рет қаралды 276 М.
I built my own 16-Bit CPU in Excel
15:45
Inkbox
Рет қаралды 1,6 МЛН
x86 Internals for Fun & Profit • Matt Godbolt • GOTO 2014
54:01
GOTO Conferences
Рет қаралды 32 М.
Writing Code That Runs FAST on a GPU
15:32
Low Level
Рет қаралды 572 М.