算术求反是否算作浮点运算?

发布于 2024-09-07 05:09:05 字数 215 浏览 2 评论 0原文

我目前正在测量一些代码在 FLOPS 中的性能。此代码提供了一些算术求反指令,如下所示:

d = -a

其中 da 是浮点变量。 我当前使用的架构确实有特定的否定指令。我是否应该考虑这种操作来测量 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 技术交流群。

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

发布评论

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

评论(3

墨落成白 2024-09-14 05:09:05

尝试反汇编代码并检查该操作是如何执行的。

如果它使用指令FCHS(改变符号)那么你可以认为它是浮点运算。

MSVC (Visual Studio 2008)

    double c = -b;
00971397  fld         qword ptr [b] 
0097139A  fchs             
0097139C  fstp        qword ptr [c] 

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)

    double c = -b;
00971397  fld         qword ptr [b] 
0097139A  fchs             
0097139C  fstp        qword ptr [c] 

fchs - see that?

哆兒滾 2024-09-14 05:09:05

正如@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.

感情旳空白 2024-09-14 05:09:05

有一种使用 LINPACK 作为一种标准基准来计算 FLOPS 的约定。

There is a kind of convention to calculate the FLOPS using LINPACK as a kind of standard benchmark.

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