gpt4 book ai didi

assembly - 英特尔架构和 IEEE 754 合规性(minNum 和 maxNum)?

转载 作者:行者123 更新时间:2023-12-02 22:13:44 27 4
gpt4 key购买 nike

我一直在查看 x64 软件开发人员手册,看起来内置的 {MIN|MAX}{S|P}{S|D} 指令没有实现称为 minNum 和maxNum 在 IEEE 754 标准中,尽管英特尔在同一份文件中声称他们的 CPU 完全兼容。

如果任一操作数均为 QNaN 而任一操作数都不是 SNaN,则英特尔运算始终返回第二操作数,而 minNum 和 maxNum 返回其他操作数,即:

IEE 754:
minNum(1.0, QNaN) -> 1.0
minNum(QNaN, 1.0) -> 1.0

Intel x64:
MIN(1.0, QNaN) -> QNaN
MIN(QNaN, 1.0) -> 1.0

我是否正确地认为,符合标准的 minNum/maxNum 函数必须通过对第一个操作数进行额外检查来进行模拟,并且不能直接转换为相应的指令?

最佳答案

是的,您将需要额外的说明。

this comment on a Julia issue thread 中对此进行了讨论作者:阿奇·罗宾逊:

The semantics of minsd were designed back in the '90s, well before IEEE 754-2008, so that compilers could optimize the common C idiom x<y?x:y.

该问题继续建议使用一系列 AVX 指令来使其出现 NaN 中毒。如果您想要 IEEE 行为,那么您可以使用

VMIN R, a, b           // result is b if a or b are NaN, min(a,b) otherwise
// so Nan is not propagated only if a is the NaN
VCMPNEQ M, b, b // M=11…11 if b is NaN, 0 otherwise
VBLENDV Res, R, a, M // Res = R if M=0 (b not NaN), otherwise Res=a (if b is NaN)

关于assembly - 英特尔架构和 IEEE 754 合规性(minNum 和 maxNum)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32330945/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com