Page 1 of 1

code for melting computer

Posted: Fri Sep 29, 2017 1:36 am UTC
by >-)
What sort of code could I write in a low level language like C in order to induce maximum energy consumption (and hence melt my computer)?

I remember being shown graphs in my computer architecture class that showed most of the energy expended during computation was from moving bits around, and that the actual operations in the ALU didn't consume that much energy. Based on this information, I was thinking that writing some loops to copy random bits between a few arrays which fit in the L3 cache would heat my computer up the most.

The reason why I think the L3 cache would work better than copying to DRAM is because I've never seen or heard of DRAM needing cooling like the CPU does, so I figured DRAM doesn't consume much energy.

My question: would this actually result in more energy consumption than say, running your average computer stress test? I know the small FFT tests in Prime95 are designed to stress the fpu and the cache, so I wonder how this strategy would compare to that.

Also, does the same logic apply to testing out my GPU? Would it be better there to stress the main memory or the scratchpad memory? I know GPU's don't have much cache to speak of.

Re: code for melting computer

Posted: Fri Sep 29, 2017 4:57 pm UTC
by hotaru
unless the hardware has a serious flaw, the worst you'll be able to do is waste electricity and maybe shut down the system (the CPU and GPU are more likely to throttle and stay within safe temperature ranges, but if you have especially poor cooling (for example, a laptop packed full of dust), you might be able to get something hot enough that it shuts off to prevent damage.

Re: code for melting computer

Posted: Fri Sep 29, 2017 7:24 pm UTC
by mosgi
Ooh, I know this one!

Modern computers have very good thermal throttling - ie, when they get hot, they slow way the fuck down to avoid overheating. Old CPUs (10+ years old by now) didn't always have thermal sensors, so you could get them to burn up by running even fairly standard programs without a heatsink - here's an example, from back when Intel had thermal sensors but AMD didn't.

These days you can't really cause that to happen, but I remember seeing a StackOverflow post on how to get your CPU to use as much power as possible. The answer is here - this will burn a ton of power in a very localized area of your processor (the vector unit in each core), so expect it to start throttling pretty quickly if you try running that code.