Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we optimize code to reduce power consumption?

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

like image 723
Manik Mahajan Avatar asked May 25 '10 15:05

Manik Mahajan


People also ask

How can we optimize our code?

Optimize Program Algorithm For any code, you should always allocate some time to think the right algorithm to use. So, the first task is to select and improve the algorithm which will be frequently used in the code. 2. Avoid Type Conversion Whenever possible, plan to use the same type of variables for processing.

How does code optimizer improve the performance of the code?

Code optimization is any method of code modification to improve code quality and efficiency. A program may be optimized so that it becomes a smaller size, consumes less memory, executes more rapidly, or performs fewer input/output operations.


2 Answers

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.

like image 174
Dave Swersky Avatar answered Oct 02 '22 18:10

Dave Swersky


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 :)

like image 26
Jeriko Avatar answered Oct 02 '22 19:10

Jeriko