Optimizing for Low Power Consumption

Mike Stump mrs@apple.com
Wed Jun 4 01:44:00 GMT 2003


On Tuesday, June 3, 2003, at 12:49 PM, Christopher Wolff wrote:
> I'm working on a research project concerned with reducing the power
> consumption of programs running on embedded systems.  The m68hc11 is 
> one
> of the chips we are working with.  I would like to modify gcc's backend
> for this target to select the instructions with the lowest cost in 
> terms
> of power consumption.  It seems that this could be implemented using
> peephole optimization.

No, you don't want to do it that way.

> As someone who is unfamiliar with the internals of gcc, can anyone 
> tell me
> what the scope of this project would be, and if it is a realistic goal 
> for
> a short-term summer project?

I think so.  The benefit you get will be directly proportional to how 
good you are, how much time you speed, and how much you know about 
gcc/compilers already.

Roughly, just modify the costs of the instructions to be the energy 
consumption of those instructions, and you then just have the compiler 
compile and optimize as normal.  You can think of it as a variant of 
the cpu architecture that is selected with -mtune=savepower, and all 
the costs of the savepower implementation of the architecture relate to 
power.

This is a cheap, easy way to implement it.

At the limits of this, you might find certain areas of the compiler 
that just know that one form is better than  another, despite the power 
numbers of your port, and those may have to be disabled, hacked out, or 
otherwise taught to not kick in.  Worry about those last...

To get started, grep -i cost m68hc11.[ch]...  add savepower CPU variant 
(see how 68hc12 was added for hints on how to add an additional cpu 
variant), compile, make sure it works, use -mcpu=savepower to compile 
code, pick testcase that shows a power bug, modify costs of those 
instructions until you get the right codegen, repeat until done.  Have 
fun.



More information about the Gcc mailing list