pow for SSE types

前端 未结 4 2094
感情败类
感情败类 2020-12-10 15:40

I do some explicitly vectorised computations using SSE types, such as __m128 (defined in xmmintrin.h etc), but now I need to raise all elements of

相关标签:
4条回答
  • 2020-12-10 16:14

    Use the formula exp(y*log(x)) for pow(x, y) and a library with SSE implementations of exp() and log().

    Edit by @Royi: The above holds only for cases both x and y are positive. Otherwise more carefull Math is needed. See https://math.stackexchange.com/questions/2089690.

    0 讨论(0)
  • 2020-12-10 16:19

    Make a vector out of the float.

     _mm_pow_ps(v,_mm_ps1(f))
    
    0 讨论(0)
  • 2020-12-10 16:20

    I really recommend the Intel Short Vector Math Library for these types of operations. The library is bundled with the Intel compiler which you mention in the list of compilers to support. I doubt it would be useful for gcc and clang but it could serve as a reference point for benchmarking wherever pow implementation you come up with.

    https://software.intel.com/sites/products/documentation/doclib/iss/2013/compiler/cpp-lin/GUID-DEB8B19C-E7A2-432A-85E4-D5648250188E.htm

    0 讨论(0)
  • 2020-12-10 16:27

    An AVX version of the ssemath library is now available: http://software-lisc.fbk.eu/avx_mathfun/

    with the library you can use:

    exp256_ps(y*log256_ps(x)); // for pow(x, y)
    
    0 讨论(0)
提交回复
热议问题