等同于各种Unices上的fesetflushtozero() [英] Equivalent of fesetflushtozero() on various Unices

查看:307
本文介绍了等同于各种Unices上的fesetflushtozero()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HP-UX的libc具有 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是默认模式。您可以通过清除 fenv_t 中的 __ fpscr_flush_to_zero 位来将VFP指令(而不是NEON) code>对象并使用 fesetenv()安装该环境。
  • iOS / arm64: fesetenv(_FE_DFL_DISABLE_DENORMS_ENV)



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 in float or double, 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 a fenv_t object and installing that environment with fesetenv( ).

  • iOS / arm64: fesetenv(_FE_DFL_DISABLE_DENORMS_ENV).

这篇关于等同于各种Unices上的fesetflushtozero()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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