浮点运算中的清零行为
然而,据我所知,IEEE 754 没有提到用清零模式来处理非规范化数字< /a> 更快,某些体系结构提供此模式(例如 http://docs.sun .com/source/806-3568/ncg_lib.html)。
在本技术文档的特定情况下,非规范化数字的标准处理是默认的,并且必须显式激活清零。在默认模式下,非规范化数字也在软件中处理,速度较慢。
我正在开发一个嵌入式 C 静态分析器,它试图预测运行时可能发生的值的正确(如果有时不精确)范围。它的目标是正确的,因为它旨在可用于排除运行时出错的可能性(例如对于关键的嵌入式代码)。这需要在分析过程中捕获所有可能的行为,从而捕获浮点计算期间产生的所有可能的值。
在这种情况下,我的问题是双重的:
在嵌入式架构中,是否有仅提供清零的架构?他们也许不必将自己宣传为“IEEE 754”,但可以提供足够接近 IEEE 754 风格的浮点运算。
对于在嵌入式环境中同时提供这两种功能的架构,系统不太可能清零,以便使反应时间更加可预测(常见的对于这些嵌入式系统的约束)?
如果我知道我必须这样做,那么在我用于浮点值的区间算术中处理清零就足够简单了,我的问题更多的是我是否必须这样做。
While, as far as I remember, IEEE 754 says nothing about a flush-to-zero mode to handle denormalized numbers faster, some architectures offer this mode (e.g. http://docs.sun.com/source/806-3568/ncg_lib.html ).
In the particular case of this technical documentation, standard handling of denormalized numbers is the default, and flush-to-zero has to be activated explicitly. In the default mode, denormalized numbers are also handled in software, which is slower.
I work on a static analyzer for embedded C which tries to predict correct (if sometimes imprecise) ranges for the values that can happen at run-time. It aims at being correct because it is intended to be usable to exclude the possibility of something going wrong at run-time (for instance for critical embedded code). This requires having captured all possible behaviors during the analysis, and therefore all possible values produced during floating-point computations.
In this context, my question is twofold:
among the embedded architectures, are there architectures that offer only flush-to-zero? They would perhaps not have to right to advertise themselves as "IEEE 754", but could offer close-enough IEEE 754-style floating-point operations.
For the architectures that offer both, in an embedded context, isn't flush-to-zero likely to be activated by the system, in order to make the reaction time more predictable (a common constraint for these embedded systems)?
Handling flush-to-zero in the interval arithmetic that I use for floating-point values is simple enough if I know I have to do it, my question is more whether I have to do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这两个问题都是肯定的。有些平台仅支持刷新到零,并且有许多平台默认刷新到零。
您还应该注意,许多嵌入式和 DSP 平台使用“非正规数为零”模式,这是浮点语义中的另一个问题。
编辑 FTZ 与 DAZ 的进一步解释:
在 FTZ 中,当运算在通常的算术下产生非正规结果时,会返回零。请注意,某些实现始终刷新为正零,而其他实现可能刷新为正零或负零。最好不要依赖这两种行为。
在 DAZ 中,当操作的输入是非正规的时,将用零代替它的位置。同样,对于哪个零将被替换并没有一般保证。
支持这些模式的一些实现允许独立设置它们(有些仅支持两种模式之一),因此您可能需要能够独立或一起对任一模式进行建模。
另请注意,某些实现将这两种模式组合成“刷新至零”。例如,ARM VFP“清零”模式既是 FTZ 又是 DAZ。
Yes to both questions. There are platforms that support flush-to-zero only, and there are many platforms where flush-to-zero is the default.
You should also be aware that many embedded and dsp platforms use a "Denormals Are Zero" mode, which is another wrinkle in the floating-point semantics.
Edit further explanation of FTZ vs. DAZ:
In FTZ, when an operation would produce a denormal result under the usual arithmetic, a zero is returned instead. Note that some implementations always flush to positive zero, whereas others may flush to either positive or negative zero. It's probably best not to depend on either behavior.
In DAZ, when an input to an operation is a denormal, a zero is substituted in its place. Again, there's no general guarantee about which zero will be substituted.
Some implementations that support these modes allow them to be set independently (and some support only one of the two), so it may be necessary for you to be able model either mode independently as well as together.
Note also that some implementations combine these two modes into "Flush to Zero". The ARM VFP "flush to zero" mode is both FTZ and DAZ, for example.
ARM Cortex 内核具有清零选项,很难看出如何忽略它。再说一遍,不要从论坛上获取商业建议。与您的客户交谈。
ARM Cortex cores have a flush to zero option, hard to see how you can ignore it. Then again, don't take business advice from a forum. Talk to your customers.