Can we optimize code to reduce power consumption?

后端 未结 9 1552
南方客
南方客 2021-02-07 13:01

Are there any techniques to optimize code in order to ensure lesser power consumption.Architecture is ARM.language is C

相关标签:
9条回答
  • 2021-02-07 13:12

    Yes. Use a profiler and see what routines are using most of the CPU. On ARM you can use some JTAG connectors, if available (I used Lauterbach both for debugging and for profiling). The main problem is generally to put your processor, when in idle, in a low-consumption state (deep sleep). If you cannot reduce the CPU percentage used by much (for example from 80% to 50%) it won't make a big difference. Depending on what operating systems you are running the options may vary.

    0 讨论(0)
  • 2021-02-07 13:14

    Optimizing code to use less power is, effectively, just optimizing code. Regardless of whether your motives are monetary, social, politital or the like, fewer CPU cycles = less energy used. What I'm trying to say is I think you can probably replace "power consumption" with "execution time", as they would, essentially, be directly proportional - and you therefore may have more success when not "scaring" people off with a power-related question. I may, however, stand corrected :)

    0 讨论(0)
  • 2021-02-07 13:18

    If the processor is tuned to use less power when it needs less cycles, then simply making your code run more efficiently is the solution. Else, there's not much you can do unless the operating system exposes some sort of power management functionality.

    0 讨论(0)
  • 2021-02-07 13:27

    From the ARM technical reference site:

    The features of the ARM11 MPCore processor that improve energy efficiency include:

    • accurate branch and sub-routine return prediction, reducing the number of incorrect instruction fetch and decode operations
    • use of physically addressed caches, which reduces the number of cache flushes and refills, saving energy in the system
    • the use of MicroTLBs reduces the power consumed in translation and protection lookups each cycle
    • the caches use sequential access information to reduce the number of accesses to the tag RAMs and to unwanted data RAMs.

    In the ARM11 MPCore processor extensive use is also made of gated clocks and gates to disable inputs to unused functional blocks. Only the logic actively in use to perform a calculation consumes any dynamic power.

    Based on this information, I'd say that the processor does a lot of work for you to save power. Any power wastage would come from poorly written code that does more processing than necessary, which you wouldn't want anyway. If you're looking to save power, the overall design of your application will have more effect. Network access, screen rendering, and other power-hungry operations will be of more concern for power consumption.

    0 讨论(0)
  • 2021-02-07 13:27

    The July 2010 edition of the Communications of the ACM has an article on energy-efficient algorithms which might interest you. I haven't read it yet so cannot impart any of its wisdom.

    0 讨论(0)
  • 2021-02-07 13:28

    If you are not running Windows XP+ or a newer version of Linux, you could run a background thread which does nothing but HLT.

    This is how programs like CPUIdle reduce power consumption/heat.

    0 讨论(0)
提交回复
热议问题