Remix.run Logo
Tepix 10 hours ago

From TFA:

> It encodes to the same number of bytes, executes in the same number of cycles.

abainbridge 9 hours ago | parent [-]

Those aren't the only resources. I could imagine XOR takes less energy because using it might activate less circuitry than SUB.

zahlman 5 hours ago | parent [-]

I'm not aware of any stories in the historical record of "real programmers" optimizing for power use, only for speed or code size.

toast0 an hour ago | parent | next [-]

Sibling posted a good example. But I know of (without details) things where you have to insert nops to keep peak power down, so the system doesn't brown out (in my experience, the 68hc11 won't take conditional branches if the power supply voltage dips too far; but I didn't work around that, I just made sure to use fresh batteries when my code started acting up). Especially during early boot.

Apple got in a lot of trouble for reducing peak power without telling people, to avoid overloading dying batteries.

abainbridge 3 hours ago | parent | prev [-]

For a few years I worked in the team that wrote software for an embedded audio DSP. The power draw to do something was normally more important than the speed. Eg when decoding MP3 or SBC you probably had enough MIPS to keep up with the stream rate, so the main thing the customers cared about was battery life. Mostly the techniques to optimize for speed were the same as those for power. But I remember being told that add/sub used less power than multiply even though both were single cycle. And that for loops with fewer than 16 instructions used less power because there was a simple 16 instruction program memory cache that saved the energy required to fetch instructions from RAM or ROM. (The RAM and ROM access was generally single cycle too).

Nowadays, I expect optimizations that minimize energy consumption are an important target for LLM hosts.