AVX log intrinsics (_mm256_log_ps) missing in g++-4.8?

和自甴很熟 提交于 2019-11-28 00:29:13

问题


I am trying to utilise some AVX intrinsics in my code and have run into a brick wall with the logarithm intrinsics.

Using the Intel Intrinsics Guide v3.0.1 for Linux, I see the intrinsic _mm256_log_ps(__m256) listed as being part of "immintrin.h" and also supported on my current arch.

However trying to compile this simple test case fails with "error: ‘_mm256_log_ps’ was not declared in this scope"

The example was compiled with g++-4.8 -march=native -mavx test.cpp

#include <immintrin.h>
int main()
{
        __m256 i;
        _mm256_log_ps(i);
}

Am I missing something fundamental here? Are certain intrinsics not supported by g++ and only available in icc?

SOLVED: This instruction is not a true intrinsic but instead implemented as part of the Intel SVML for ICC.


回答1:


As indicated in the comments to your question, that intrinsic doesn't map to an actual AVX instruction; it is an Intel extension to the intrinsic set. The implementation likely uses many underlying instructions, as a logarithm isn't a trivial operation.

If you'd like to use a non-Intel compiler but want a fast logarithm implementation, you might check out this open-source implementation of sin(), cos(), exp(), and log() functions using AVX. They are based on an earlier SSE2 version of the same functions.




回答2:


I've posted my implementation of _mm256_log_pd(__m256d) here: https://stackoverflow.com/a/45898937/1915854 . With some effort you should be able to extend it to 8 packed floats instead of 4 doubles, though you need to revise the bit manipulations. And some parts are easies because you don't need to repack odd-/even-numbered 32-bit components of __m256i into __m128i.



来源:https://stackoverflow.com/questions/18747768/avx-log-intrinsics-mm256-log-ps-missing-in-g-4-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!