我们可以优化代码来降低功耗吗?

发布于 2024-09-02 11:40:32 字数 40 浏览 4 评论 0原文

有没有什么技术可以优化代码以确保更低的功耗。架构是ARM。语言是C

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

王权女流氓 2024-09-09 11:40:32

来自 ARM 技术参考网站:

ARM11 MPCore 的特性
提高能源效率的处理器
效率包括:

  • 准确的分支和子程序返回预测,减少数量
    不正确的指令获取和
    解码操作
  • 使用物理寻址缓存,减少缓存数量
    冲洗和补充,节省能源
    系统
  • MicroTLB 的使用降低了转换过程中消耗的功耗
    每个周期进行保护查找
  • 缓存使用顺序访问信息来减少
    访问标签 RAM 并
    不需要的数据 RAM。

在ARM11 MPCore处理器中
门控也被广泛使用
时钟和门禁用输入
未使用的功能块。只有
积极使用逻辑来执行
计算消耗任何动态
电源。

根据这些信息,我想说处理器为您做了很多工作来节省电量。任何电力浪费都来自于编写得不好的代码,这些代码执行了不必要的处理,无论如何您都不希望这样做。如果您希望节省电量,应用程序的整体设计将会产生更大的效果。网络访问、屏幕渲染等高耗电操作将是功耗比较受关注的。

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.

愿得七秒忆 2024-09-09 11:40:32

实际上,优化代码以使用更少的功耗只是优化代码。无论您的动机是金钱、社会、政治还是类似的,更少的 CPU 周期 = 更少的能源消耗。我想说的是,我认为你可以用“执行时间”代替“功耗”,因为它们本质上是成正比的——因此,当你不用“吓跑”人们时,你可能会取得更大的成功。与电源相关的问题。不过,我可能会纠正:)

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

望喜 2024-09-09 11:40:32

是的。使用 分析器 并查看哪些例程使用了大部分 CPU。在 ARM 上,您可以使用一些 JTAG 连接器(如果可用)(我使用了 Lauterbach 用于调试和分析)。主要问题通常是让处理器在空闲时处于低功耗状态(深度睡眠)。如果您无法大幅降低 CPU 使用百分比(例如从 80% 降低到 50%),则不会产生太大影响。根据您运行的操作系统,选项可能会有所不同。

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.

说不完的你爱 2024-09-09 11:40:32

2010 年 7 月版的ACM 通讯有一篇关于节能算法的文章,您可能会感兴趣。我还没有读过它,所以无法传授它的任何智慧。

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.

最终幸福 2024-09-09 11:40:32

尝试保留在片上内存(高速缓存)中进行空闲循环,将 I/O 保持在最低限度,将总线上的位翻转保持在最低限度。像 proms 和闪存这样的 NV 存储器在存储 0 时消耗的电量比存储 1 多(这就是为什么它们会擦除为 1,它实际上是 0,但在您看到它之前,传输器会反转该位,0 存储为 1,1 存储为零,这也是它们在失败时降级为 1 的原因),我不知道易失性存储器,dram 使用的晶体管数量是 sram 的一半,但必须刷新。

为了使所有这些变得重要,您需要从较低功率的系统开始,因为上述情况可能并不明显。例如,不要使用英特尔的任何产品。

Try to stay in on chip memory (cache) for idle loops, keep I/O to a minimum, keep bit flipping to a minimum on busses. NV memory like proms and flash consume more power to store zeros than ones (which is why they erase to ones, it is actually a zero but the transitor(s) invert the bit before you see it, zeros stored as ones, ones stored as zeros, this is also why they degrade to ones when they fail), I dont know about volatile memories, dram uses half as many transistors as sram, but has to be refreshed.

For all of this to matter though you need to start with a lower power system as the above may not be noticeable. dont use anything from intel for example.

日暮斜阳 2024-09-09 11:40:32

如果您没有运行 Windows XP+ 或较新版本的 Linux,则可以运行一个后台线程,该线程除了 HLT 之外不执行任何操作。

这就是 CPUIdle 等程序降低功耗/热量的方式。

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.

薄凉少年不暖心 2024-09-09 11:40:32

如果处理器被调整为在需要更少的周期时使用更少的功率,那么简单地让代码运行更高效就是解决方案。否则,除非操作系统公开某种电源管理功能,否则您无能为力。

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.

霞映澄塘 2024-09-09 11:40:32

将 IO 保持在最低限度。

Keep IO to a minimum.

孤单情人 2024-09-09 11:40:32

在某些 ARM 处理器上,可以通过将稳压器置于待机模式来降低功耗。

On some ARM processors it's possible to reduce power consumption by putting the voltage regulator in standby mode.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文