等同于各种Unices上的fesetflushtozero() [英] Equivalent of fesetflushtozero() on various Unices
问题描述
fesetflushtozero
来切换渐变下溢和变为零之间的浮点行为。 <尽管结合了几个Unix libc(包括glibc)的文档和手册页,但我还没有找到在其他Unices中如何实现相同的事情。我特别感兴趣的是Linux / glibc,Solaris和AIX。
正如你无疑指出的那样,这样做(就此而言,没有清零的标准定义,也没有硬件实现的任何要求)。因此,所有这些做法都是针对平台的。要添加一些更多的名单,因为这是一个有用的参考:
-
OSX / Intel:
fesetenv(_FE_DFL_DISABLE_SSE_DENORMS_ENV)
。请注意,在float
或double
中完成的 only (由此得名);long double
算法是使用传统的x87指令执行的,不支持刷新功能。 arm:在iOS下的32位ARM上,flush-to-zero是默认模式。您可以通过清除 -
iOS / arm64:
fesetenv(_FE_DFL_DISABLE_DENORMS_ENV)
。
fenv_t 中的 __ fpscr_flush_to_zero
位来将VFP指令(而不是NEON) code>对象并使用 fesetenv()
安装该环境。
HP-UX's libc has the function fesetflushtozero
to switch floating-point behavior between "gradual underflow" and "flush to zero".
Despite combing through documentation and man pages of several Unix libc's (including glibc), I have yet to find how to achieve the same thing in other Unices. I'm particularly interest in Linux/glibc, Solaris and AIX.
As you have doubtless noted, there’s no standard way to do this (for that matter, there’s no standard definition of "flush to zero", nor any requirement that hardware implement it). So all of the means of doing this are platform-specific. To add a few more to the list, since this is a useful reference:
OSX / Intel:
fesetenv(_FE_DFL_DISABLE_SSE_DENORMS_ENV)
. Note that this only effects arithmetic done infloat
ordouble
, which is done using SSE2 (hence the name);long double
arithmetic is performed using the legacy x87 instructions, which do not support flushing.iOS / arm: On 32-bit ARM under iOS, flush-to-zero is the default mode. You can turn it off for VFP instructions (but not for NEON) by clearing the
__fpscr_flush_to_zero
bit in afenv_t
object and installing that environment withfesetenv( )
.iOS / arm64:
fesetenv(_FE_DFL_DISABLE_DENORMS_ENV)
.
这篇关于等同于各种Unices上的fesetflushtozero()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!