The basics of programming embedded processors: Part 8

Wayne Wolf

September 11, 2007

Wayne WolfSeptember 11, 2007

Power consumption is a particularly important design metric for battery-powered systems because the battery has a very limited lifetime. However, power consumption is increasingly important in systems that run off the power grid. Fast chips run hot, and controlling power consumption is an important element of increasing reliability and reducing system cost.

How much control do we have over power consumption? Ultimately, we must consume the energy required to perform necessary computations. However, there are opportunities for saving power. Examples include the following:

* We may be able to replace the algorithms with others that do things in clever ways that consume less power.
* Memory accesses are a major component of power consumption in many applications. By optimizing memory accesses we may be able to significantly reduce power.
* We may be able to turn off parts of the system - such as subsystems of the CPU, chips in the system, and so on - when we don't need them in order to save power.

The first step in optimizing a program's energy consumption is knowing how much energy the program consumes. It is possible to measure power consumption for an instruction or a small code fragment [Tiw94]. The technique, illustrated in Figure 5-25 below, executes the code under test over and over in a loop.

By measuring the current flowing into the CPU, we are measuring the power consumption of the complete loop, including both the body and other code. By separately measuring the power consumption of a loop with no body (making sure, of course, that the compiler hasn't optimized away the empty loop), we can calculate the power consumption of the loop body code as the difference between the full loop and the bare loop energy cost of an instruction.

Figure 5-25. Measuring energy consumption for a piece of code

Program Energy Consumption and Optimization
Several factors contribute to the energy consumption of the program:

* Energy consumption varies somewhat from instruction to instruction.
* The sequence of instructions has some influence.
* The opcode and the locations of the operands also matter.

Choosing which instructions to use can make some difference in a program's energy consumption, but concentrating on the instruction opcodes has limited payoffs in most CPUs. The program has to do a certain amount of computation to perform its function.

While there may be some clever ways to perform that computation, the energy cost of the basic computation will change only a fairly small amount compared to the total system energy consumption, and usually only after a great deal of effort. We are further hampered in our ability to optimize instruction-level energy consumption because most manufacturers do not provide detailed, instruction-level energy consumption figures for their processors.

< Previous
Page 1 of 4
Next >

Loading comments...

Most Commented

  • Currently no items

Parts Search