g++-4.8 中缺少 AVX 日志内在函数 (_mm256_log_ps)?

2022-01-23 00:00:00 g++ c++ intrinsics avx

我正在尝试在我的代码中使用一些 AVX 内在函数,但遇到了对数内在函数的障碍.

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

使用适用于 Linux 的英特尔内部指南 v3.0.1,我看到内部 _mm256_log_ps(__m256) 被列为immintrin.h"的一部分,并且在我当前的架构中也受支持.

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.

但是,尝试编译这个简单的测试用例失败并显示错误:'_mm256_log_ps' 未在此范围内声明"

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

示例使用g++-4.8 -march=native -mavx test.cpp

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

我在这里遗漏了一些基本的东西吗?某些内在函数是否不受 g++ 支持且仅在 icc 中可用?

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

已解决:此指令不是真正的内在指令,而是作为面向 ICC 的英特尔 SVML 的一部分实现的.

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

推荐答案

正如您对问题的评论中指出的那样,该内在函数并未映射到实际的 AVX 指令;它是内部集的英特尔扩展.该实现可能使用许多底层指令,因为对数不是一个简单的操作.

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.

如果您想使用非英特尔编译器但想要快速实现对数,您可以查看 this open-使用 AVX 实现 sin()cos()exp()log() 函数的源代码实现.它们基于相同功能的早期 SSE2 版本.

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.

相关文章