Powerful coding software

In a typical portable / portable integrated system device, battery life is a serious problem in designing the H / W, S / W, and features that the device can support. From a software point of view, one knows about MIPS, Memory (Data and Program) optimized code. I know about H / W deep sleep mode, a standby mode that is used to synchronize hardware in lower cycles or to turn on whole whole hours in a few unused cycles to save energy, but I'm looking for some ideas from this point of view

While my code is working and it needs to continue executing, given this, how can I efficiently write the "power" of the code to consume minimal watts?

Are there any special programming constructs, data structures, control structures that I have to look at in order to achieve the minimum power consumption for this functionality.

Are there any high-level design considerations that should be considered when designing a code structure or when developing at a low level to make the code as efficient as possible (least power-consuming)?

+42
embedded power management
Sep 15 '08 at 5:06
source share
17 answers
  • As 1800 INFORMATION said, avoid polling; Subscribe to events and wait for them.
  • Updating the contents of the window only if necessary - let the system decide when to redraw it.
  • When updating the contents of the window, make sure that your code recreates as little as possible invalid area
  • With a fast code, the CPU returns to deep sleep mode faster, and there is more chance that such a code will remain in the L1 cache
  • Work with small data at a time so that data is also cached.
  • Make sure your application does not do unnecessary actions when in the background
  • Make your software not only energy-efficient, but also energy-efficient - update your graphics less often when on battery, turn off the animation, and then scroll through the hard drive.

And read another guidelines .;)

Recently, Intel Software Blogs has posted a series of posts titled "Optimizing Power Software Applications . " May be useful for x86 developers.

+22
Sep 15 '08 at 5:42
source share

Zeroith, use a fully static machine that can stop when idle. You cannot beat zero Hz.

First go to the keyless scheduler. Awakening every milliseconds or so is wasting energy. If you cannot, consider slowing down the scheduler interrupt.

Secondly, make sure that your idle thread is power-saving, wait for the next interrupt instruction. You can do this in the form of an underdeveloped “user field” that most small devices have.

Thirdly, if you need to interrogate or perform user actions, such as updating the user interface, sleep, do it and fall asleep again.

Do not trust GUI frameworks that you haven’t tested for sleep and rotation. Especially for an event timer you can tempt to use for # 2.

Block the stream while reading instead of polling with select () / epoll () / WaitForMultipleObjects (). Puts stress on the thread twist (and your brain), but the device is usually all right. This ultimately changed your design a bit to a high standard; he becomes more accurate !. The main loop, which checks everything you need, ends up slow and wasteful on the processor, but guarantees performance. (Guaranteed to be slow)

Cache results lazily create things. Users expect the device to be slow, so don't disappoint them. Less works better. Run as little as possible. Individual threads may be destroyed when you stop executing them.

Try to get more memory than you need, then you can insert into multiple hash tables and save the search ever. This is a direct compromise if the memory is DRAM.

Look at the real-time system than you think you might need. This saves time (sic) later. They also handle streams.

+9
Sep 15 '08 at 5:37
source share

Do not conduct a survey. Use events and other OS primitives to wait for notified occurrences. The survey ensures that the processor remains active and will use more battery life.

+5
Sep 15 '08 at 5:17
source share

From my work using smartphones, the best way to save battery life is to ensure that everything you don't need, so that your program functions at that particular point, is disabled.

For example, just turn on Bluetooth when you need it, similar to the phone’s capabilities, turn off the screen brightness when not needed, turn down the volume, etc.

The power used by these features tends to far exceed the power used by your code.

+5
Sep 15 '08 at 7:23
source share

To avoid questioning, this is a good suggestion.

The microprocessor's power consumption is approximately proportional to its clock frequency and the square of its supply voltage. If you have the ability to configure them using software, this can save some power. In addition, you can disable parts of the processor that you do not need (for example, a floating-point block), but this is very dependent on your platform. In any case, you need a way to measure the actual power consumption of your processor so that you can find out what works and what doesn't. Like speed optimization, power optimization must be carefully profiled.

+3
Apr 21 '09 at 19:37
source share

Think about using network interfaces as little as possible. You might want to collect information and send it in queues rather than constantly sending it.

+1
Sep 15 '08 at 5:29
source share

See what your compiler generates, especially for hot areas of code.

+1
Sep 15 '08 at 10:02
source share

If you have intermittent low-priority operations, do not use specific wake-up timers to deal with them, but handle them when processing other events.

Use logic to avoid stupid scenarios where your application can sleep for 10 ms and then wake up again for the next event. For the mentioned platforms, it should not matter whether both events are processed simultaneously. Having an appropriate timer and callback mechanism may be appropriate for this kind of decision making. The trade-off is the complexity of the code and its maintenance and possible energy savings.

+1
Sep 15 '08 at 10:29
source share

Simply put, do as little as possible.

+1
Sep 30 '08 at 13:19
source share

Well, to the extent that your code can be fully executed in the processor cache, you will have less bus activity and save energy. To the extent that your program is small enough to fully contain code + data in the cache, you get this benefit "for free." OTOH, if your program is too large and you can divide your programs into modules that are more or less independent of each other, you can get some energy savings by dividing it into separate programs. (I believe it is also possible to create a tool chain that issues related code and data packets into chunks the size of a cache ...)

I believe that theoretically you can save some unnecessary work by reducing the number of dereferencing pointers and refactoring your jumps so that the first jumps are made first, but this is not realistic to do as a programmer,

Transmeta had the idea of ​​letting the machine do some optimization on-the-fly to save energy ... But that didn't seem to help ... And look where they got it.

+1
Oct 21 '08 at 22:59
source share

Set the unused memory or flash to 0xFF not 0x00. This is certainly true for flash and eeprom, not sure about s or d ram. There is an inversion for proms, so 0 is stored as 1 and consumes more energy, 1 is stored as zero and takes less. This is why you read 0xFF after erasing a block.

+1
May 18 '09 at 1:54 a.m.
source share

In addition, something that is not trivial is to reduce the accuracy of mathematical operations, move on to the smallest dataset available and available for your data packages and aggregate operations of the development environment.

knuth books can give you the full range of specific algorithms needed to save memory or processor, or with reduced accuracy, minimizing rounding errors.

also spent some time checking all the built-in api devices - for example, most Symbian phones could perform audio encoding through specialized equipment

0
Sep 30 '08 at 13:39
source share

Do your work as quickly as possible, and then go into some unoccupied state, waiting for interruptions (or events). Try to ensure that the code ends with a cache with a minimum amount of external memory traffic.

0
Sep 23 '09 at 8:03
source share

On Linux, install powertop to find out how often a piece of software wakes up the processor. And follow the various tips referenced by the powertop website, some of which are probably also applicable to non-Linux.

http://www.lesswatts.org/projects/powertop/

0
Dec 10 '09 at 20:41
source share

Choose efficient algorithms that are fast and have small base blocks and minimal memory access.

Understanding the size of the cache and the functional blocks of your processor.

Do not access memory. Do not use objects or garbage collection or any other high-level constructors if they extend your working code or data set outside the available cache. If you know the cache size and associativity, lay out the entire set of operational data that you will need in low-power mode and insert it into dcache (forget some “correct” encoding methods that scatter data around in separate objects or structure data, if it’s causes the cache to crash). Same thing with all routines. Put your working code in one module, if necessary, to cross out everything in icache. If your processor has multiple cache levels, try setting a minimum instruction cache or data cache level. Do not use a floating point block or any other instructions that may activate any other optional function blocks unless you can make a good case that using these instructions significantly reduces the time that the CPU wakes up from sleep mode.

and etc.

0
Aug 29 '10 at 8:50
source share

Pretty timely, an article on Hackaday today about measuring the energy consumption of various teams: Hackaday: code-on-energy-effect

Besides:
- Interruptions - your friends
- Poll / wait () is not your friends
- Make as little as possible
- make your code as small / efficient as possible
- Disconnect as many modules, pins, peripherals as possible in micro
- Run as slowly as possible
- If the microphone has settings for increasing the frequency of drives, slew rate, etc., check them and adjust them, the default values ​​often have full power / maximum speed.
- Returning to the article above, go back and measure the power and see if you can reset it by changing things.

0
Jun 14 '12 at 15:31
source share

Do not poll, sleep

Avoid using the energy sources located in the chip whenever possible. For example, the factors are hungry, if you can change and add, you can save a few Joules (as long as you do not shift so much and add that in fact the factor is a victory!)

If you're really serious, I get a power-enabled debugger that can correlate power usage with the source code. Like this

0
Jun 15 2018-12-12T00:
source share



All Articles