当前位置:天才代写 > tutorial > C语言/C++ 教程 > Vdsp(bf561)中的浮点运算(9):long double和float的较量

Vdsp(bf561)中的浮点运算(9):long double和float的较量

2017-11-05 08:00 星期日 所属: C语言/C++ 教程 浏览:1123

在默认环境下,vdsp认为double和float这两种范例是一样的,因此我们较量long double和float。

1.1 范例暗示

下面是两种范例的数据暗示:

  float long double
字节数 4 8
标记位 1 1
指数位数 8 11
尾数位数 23 52
最小值 1.1754943508222875E-38F 2.2250738585072014E-308L
最大值 3.4028234663852886E+38F 1.797693134862315708E+308L
判别率 1.1920928955078125E-07F 2.2204460492503131E-16L

1.2 正常环境下的运算效率

下表给出两种范例下做运算的效率较量,选择High performance

  float long double
加减运算 132 cycle 166 cycle
乘法运算 92 cycle 179 cycle
除法运算 240 cycle 1506 cycle

狂汗,这个long double做除法也太狠了点!

下表给出两种范例下做运算的效率较量,选择Strict IEEE:

  Float long double
加减运算 310 cycle 381 cycle
乘法运算 274 cycle 585 cycle
除法运算 497 cycle 1063 cycle

这里有一个值显得很奇怪,在选择了Strict IEEE选项之后,long double举办除法运算反而变快了!

在vdsp的文档里这样表明这两种差异的选项:

The -fast-fp (fast floating point) switch directs the compiler to link with the high-speed floating-point emulation library. This library relaxes some of the IEEE floating-point standard’s rules for checking inputs against not-a-number (NaN) and denormalized numbers to improve performance. This switch is enabled by default.

The -ieee-fp (slower floating point) switch directs the compiler to link with the fully-compliant floating-point emulation library. This library obeys all of the IEEE floating-point standard’s rules, and incurs a performance penalty when compared with the default floating-point emulation library.

照说利用Strict IEEE选项之后应该所有的计较都变慢,但long double的浮点除法好像是个破例!

 

    关键字:

天才代写-代写联系方式