哪个代码消耗的功率更少? [英] which code is consuming less power?

查看:72
本文介绍了哪个代码消耗的功率更少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是针对某些特殊情况开发并实现绿色算法.我已经为相同的算法开发了两种算法.

My goal is to develop and implement a green algorithm for some special situation. I have developed two algorithms for the same.

有一个大号.访问内存(加载和存储).该模式有时会合并,有时会不合并.我假设最坏的情况是,大多数访问将导致缓存失败.请参阅示例代码段a).

One is having large no. of memory accesses(load and store). The pattern is some time coalesced and some time non-coalesced. I am assuming a worst case where most of the access will result in cache failure. See sample Code snippet a).

另一个没有大号.计算,大致相当于下面的代码片段b).

Another is having large no. of calculations, roughly equivalent to the code snippet b) below.

如何估算每种情况下的功耗.哪一个更节能?为什么?

How do I estimate power consumption in each case. Which one is more energy efficient and why?

平台:我将在配备Windows 7、4 GB DRAM,3 MB缓存的Intel I3处理器上运行这些代码.

Platform: I will be running these codes on Intel I3 processor, with Windows 7, with 4 GB DRAM, 3 MB Cache.

注意:我不想使用任何外部功率计.如果您发现代码没有做任何建设性的工作,也请忽略.这是因为它只是完整算法的一部分.

更新:

这很困难,但并非没有.一个人可以很好地计算读取DRAM并乘以CPU的ALU所产生的成本.唯一的事情是必须具有DRAMS和CPU的电子学知识,这是我目前所缺乏的.至少在最坏的情况下,我认为可以很好地确定这一点.最坏的情况意味着没有合并访问,没有编译器优化.

It is difficult but not impossible. One can very well calculate the cost incurred in reading DRAMs and doing multiplications by an ALU of the CPU. The only thing is one must have required knowledge of electronics of DRAMS and CPU, which I am lacking at this point of time. At least in worst case I think this can very well be established. Worst case means no coalesced access, no compiler optimization.

如果您可以估算访问DRAM并进行浮点乘法的成本,那么为什么不可能估算电流,因此在这些操作中功耗的概算呢?另请参阅我的帖子,我不是在问多少功耗,而是在问哪个代码消耗更少/更多的功率,或者哪个代码更节能?

If you can estimate the cost of accessing DRAM and doing a float multiplication , then why is it impossible for estimating the current, hence a rough idea of power during these operations? Also see me post, I am not asking how much power consumption is there, rather I am asking which code is consuming less/more power or which one is more energy efficient?

a) for(i=0; i<1000000; i++)

  {

  a[i]= b[i]; //a, b floats in RAM.  

  {




 b) for(i=1; i<1000000; i++)

  {

   float j= j * i;  //j has some value. which is used later in the program , not  
                    // shown here    

  {

推荐答案

要测量实际功耗,应使用

To measure the actual power consumption you should use add an electricity meter to your power supply (remove the batteries if using a notebook).

请注意,您将测量整个系统的功耗,因此请确保避免使用令人讨厌的参数(任何其他系统活动,例如,防病毒更新,图形桌面环境,索引服务,(内部)硬件设备),执行反复进行测量,无论是否运行您的算法都可以消除背景"消耗.如果可能,请使用嵌入式系统.

Note that you will measure the power consumption of the entire system, so make sure to avoid nuisance parameters (any other system activity, i.e. anti-virus updates, graphical desktop environment, indexing services, (internal) hardware devices), perform measurements repeatedly, with and without your algorithms running to cancel out "background" consumption. If possible use an embedded system.

关于您的算法,实际的能源效率不仅取决于C代码,还取决于编译器的性能以及与周围系统交互时的运行时行为.但是,这里有一些资源可以作为开发人员来帮助您解决此问题:

Concerning your algorithms, the actual energy efficiency depends not only on the C code but also on the performance of the compiler and also the runtime behavior in interaction with the surrounding system. However, here are some resources what you can do as developer to help on this:

尤其要查看检查表"上方的工具段落,因为其中列出了一些可以帮助您进行粗略估算的工具(基于应用程序分析).它列出了(除其他之外):

Especially take a look on the paragraph Tools in above "Checklist", as it lists some tools that may help you on rough estimates (based on application profiling). It lists (besides others):

  • Perfmon
  • PwrTest/Windows驱动程序工具包
  • Windows事件查看器(计时器刻度更改事件,Microsoft-Windows-Kernel-PowerDiagnostic日志)
  • 英特尔PowerInformer
  • Windows ETW(性能监视框架)
  • 英特尔应用能源工具包

这篇关于哪个代码消耗的功率更少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆