Floating Point Math Execution Time

前端 未结 2 953
礼貌的吻别
礼貌的吻别 2020-12-19 18:18

What accounts for the added execution time of the first data set? The assembly instructions are the same.

With DN_FLUSH flag not on, the first data set takes 63 m

相关标签:
2条回答
  • 2020-12-19 18:28

    Quoting from Intel's optimization manual:

    When an input operand for a SIMD floating-point instruction [here this includes scalar arithmetic done using SSE] contains values that are less than the representable range of the data type, a denormal exception occurs. This causes a significant performance penalty. An SIMD floating-point operation has a flush-to-zero mode in which the results will not underflow. Therefore subsequent computation will not face the performance penalty of handling denormal input operands.

    As for how to avoid this, if you can't flush denormals: do what you can to make sure your data is scaled appropriately and you don't encounter denormals in the first place. Usually this means delaying applying some scale factor until you've finished all of your other computation.

    Alternatively, do your computations in double which has a much larger exponent range, and therefore makes it much less likely that you will encounter denormals in the first place.

    0 讨论(0)
  • 2020-12-19 18:38

    Another quote from the Intel manuals, volume 1, chapter 10.2.3.3:

    The flush-to-zero mode is not compatible with IEEE Standard 754. The IEEE mandated masked response to underflow is to deliver the denormalized result (see Section 4.8.3.2, “Normalized and Denormalized Finite Numbers”). The flush-to-zero mode is provided primarily for performance reasons. At the cost of a slight precision loss, faster execution can be achieved for applications where underflows are common and rounding the underflow result to zero can be tolerated.

    0 讨论(0)
提交回复
热议问题