SSE指令会消耗更多的功率/能量吗? [英] Do sse instructions consume more power/energy?

查看:116
本文介绍了SSE指令会消耗更多的功率/能量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

非常简单的问题,可能很难回答:

例如,使用SSE指令进行并行求和/最小值/最大值/平均运算会比执行任何其他指令(例如单个求和)消耗更多的功率吗?

例如,在维基百科上,我找不到这方面的任何信息.

>

我能找到答案的唯一提示是此处,但这有点通用,没有任何参考.在这方面发表的材料.

解决方案

几年前,我实际上对此进行了研究.答案取决于您的问题到底是什么:

在当今的处理器中,功耗不是由指令类型(标量vs. SIMD)决定的,而是由诸如以下的其他所有东西决定的:

  1. 内存/缓存
  2. 指令解码
  3. OOE,注册文件
  4. 还有很多其他人.


因此,如果问题是:

在所有其他条件都相同的情况下:SIMD指令比标量指令消耗更多的功率吗?

为此,我敢说是.

我的一个研究生项目最终成为这个答案:SSE2的并排比较(2-实际上,这种方式确实表明AVX具有明显更高的功耗和更高的处理器温度. (不过我不记得确切的数字.)

这是因为SSE和AVX之间的代码相同.仅指令的宽度不同.而且,AVX版本的工作量翻了一番.

但是,如果问题是:

矢量化我的代码以使用SIMD会比标量实现消耗更多的电量.

这里涉及许多因素,因此我将避免直接回答:

降低功耗的因素:

  • 我们需要记住,SIMD的目的是提高性能.而且,如果您可以提高性能,则您的应用程序将花费较少的时间运行,从而节省了电量.

  • 根据应用程序和实现,SIMD将减少执行特定任务所需的指令数量.那是因为您要对每条指令执行多项操作.

增加功耗的因素:

  • 如前所述,SIMD指令比标量等效项执行更多的工作,并且可以使用更多的功率.
  • 使用SIMD会带来标量代码中不存在的开销(例如,随机播放和置换指令).这些还需要通过指令执行管道.

打破现状:

  • 更少的指令->更少的发布和执行开销->更少的功率
  • 更快的代码->运行时间更少->功耗更低
  • SIMD需要更多的力量来执行->更多的力量

因此,SIMD通过减少应用程序的时间来节省您的电量.但是在运行时,它每单位时间消耗更多的功率.谁赢取决于情况.

根据我的经验,对于那些通过SIMD(或其他方法)获得有价值的加速的应用程序,前者通常会胜出,而功耗会下降.

这是因为运行时往往是现代PC(笔记本电脑,台式机,服务器)功耗的主要因素.原因是大部分功耗不是在CPU中,而是在其他所有方面:主板,内存,硬盘驱动器,显示器,闲置的视频卡等…其中大多数功耗相对固定. >

对于我的计算机,仅将其保持在(闲置)状态下已经消耗了全核心SIMD负载(例如prime95或Linpack)下可绘制内容的一半以上.因此,如果我可以通过SIMD/并行化使应用程序速度提高2倍,那么我几乎肯定可以节省功耗.

Very simple question, probably difficult answer:

Does using SSE instructions for example for parallel sum/min/max/average operations consume more power than doing any other instructions (e.g. a single sum)?

For example, on Wikipedia I couldn't find any information in this respect.

The only hint of an answer I could find is here, but it's a little bit generic and there is no reference to any published material in this respect.

解决方案

I actually did a study on this a few years ago. The answer depends on what exactly your question is:

In today's processors, power consumption is not much determined by the type of instruction (scalar vs. SIMD), but rather everything else such as:

  1. Memory/cache
  2. Instruction decoding
  3. OOE, register file
  4. And lots others.


So if the question is:

All other things being equal: Does a SIMD instruction consume more power than a scalar instruction.

For this, I dare to say yes.

One of my graduate school projects eventually became this answer: A side-by-side comparison of SSE2 (2-way SIMD) and AVX (4-way SIMD) did in fact show that AVX had a noticably higher power consumption and higher processor temperatures. (I don't remember the exact numbers though.)

This is because the code is identical between the SSE and the AVX. Only the width of the instruction was different. And the AVX version did double the work.

But if the question is:

Will vectorizing my code to use SIMD consume more power than a scalar implementation.

There's numerous factors involved here so I'll avoid a direct answer:

Factors that reduce power consumption:

  • We need to remember that the point of SIMD is to improve performance. And if you can improve performance, your app will take less time to run thus saving you power.

  • Depending on the application and the implementation, SIMD will reduce the number instructions that are needed to do a certain task. That's because you're doing several operations per instruction.

Factors that increase power consumption:

  • As mentioned earlier, SIMD instructions do more work and can use more power than scalar equivalents.
  • Use of SIMD introduces overhead not present in scalar code (such as shuffle and permute instructions). These also need to go through the instruction execution pipeline.

Breaking it down:

  • Fewer instructions -> less overhead for issuing and executing them -> less power
  • Faster code -> run less time -> less power
  • SIMD takes more power to execute -> more power

So SIMD saves you power by making your app take less time. But while its running, it consumes more power per unit time. Who wins depends on the situation.

From my experience, for applications that get a worthwhile speedup from SIMD (or anything other method), the former usually wins and the power consumption goes down.

That's because run-time tends to be the dominant factor in power consumption for modern PCs (laptops, desktops, servers). The reason being that most of the power consumption is not in the CPU, but rather in everything else: motherboard, ram, hard drives, monitors, idle video cards, etc... most of which have a relatively fixed power draw.

For my computer, just keeping it on (idle) already draws more than half of what it can draw under an all-core SIMD load such as prime95 or Linpack. So if I can make an app 2x faster by means of SIMD/parallelization, I've almost certainly saved power.

这篇关于SSE指令会消耗更多的功率/能量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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