算术求反是否算作浮点运算?
我目前正在测量一些代码在 FLOPS 中的性能。此代码提供了一些算术求反指令,如下所示:
d = -a
其中 d
和 a
是浮点变量。 我当前使用的架构确实有特定的否定指令。我是否应该考虑这种操作来测量 FLOPS?什么样的操作会导致 FLOPS?有什么约定吗?
I'm currently measuring the performance of some code in FLOPS. This code presents some arithmetic negate instructions like this one:
d = -a
where d
and a
are floating point variables. The architecture I'm currently using does have specific negate instructions. Should I have to take into account this kind of operations to measure FLOPS? What kind of operations account for FLOPS? Is there a convention or anything?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试反汇编代码并检查该操作是如何执行的。
如果它使用指令
FCHS
(改变符号)那么你可以认为它是浮点运算。MSVC (Visual Studio 2008)
fchs - 看到了吗?
try to disassemble the code and check how this operation is performed.
if it uses instruction
FCHS
(Change sign) then you can consider it floating point operation.MSVC (Visual Studio 2008)
fchs - see that?
正如@Andrey所说,为了确保你应该检查反汇编代码。
但一般来说,是的,该指令可能会在 FPU 上执行。它只是翻转一点,所以它也可以在整数单元上完成,但由于您正在操作浮点值,这些很可能已经加载到 FP 寄存器中,所以就这样了。将它们移动到通用寄存器、翻转该位并将它们移回需要相当大的开销。
我不知道是否有一个完整的通用指南来说明“什么应该算作 FLOP”,但这很可能是在 FPU 上执行的指令,因此它与其他 FP 指令竞争 CPU 上的资源,所以是的,我会将其包含在 FLOPS 计数中。
As @Andrey said, to be sure you should check the disassembled code.
But in general, yes, the instruction would likely execute on a FPU. It simply flips a bit, so it could be done on an integer unit as well, but since you're operating on floating point values, these are most likely already loaded into FP registers, and so there'd be a fair amount of overhead to moving them to general purpose registers, flipping the bit and moving them back.
I don't know if there is a complete universal guide to "what should be counted as a FLOP", but this is most likely an instruction which executes on a FPU, and so it is competing with other FP instructions for resources on the CPU, so yes, I would include it in a FLOPS count.
有一种使用 LINPACK 作为一种标准基准来计算 FLOPS 的约定。
There is a kind of convention to calculate the FLOPS using LINPACK as a kind of standard benchmark.