Numpy performance differences depending on numerical values

后端 未结 2 689
天命终不由人
天命终不由人 2021-01-02 13:05

I found a strange performance difference while evaluating an expression in Numpy.

I executed the following code:

import numpy as np
myarr = np.random         


        
2条回答
  •  渐次进展
    2021-01-02 14:03

    This may produce denormalised numbers which slow down computations.

    You may like to disable denormalized numbers using daz library:

    import daz
    daz.set_daz()
    

    More info: x87 and SSE Floating Point Assists in IA-32: Flush-To-Zero (FTZ) and Denormals-Are-Zero (DAZ):

    To avoid serialization and performance issues due to denormals and underflow numbers, use the SSE and SSE2 instructions to set Flush-to-Zero and Denormals-Are-Zero modes within the hardware to enable highest performance for floating-point applications.

    Note that in 64-bit mode floating point computations use SSE instructions, not x87.

提交回复
热议问题