错误:“_mm512_loadu_epi64”未在此范围内声明

2024-01-12

我正在尝试创建一个最小的再现器本期报告 https://github.com/weidai11/cryptopp/issues/753。 AVX-512 似乎存在一些问题,它在配备 Skylake 处理器的最新 Apple 机器上发布。

根据GCC6 发行说明 https://gcc.gnu.org/gcc-6/changes.htmlAVX-512 齿轮应该可用。根据英特尔内联指南 https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=vmovdqu64 vmovdqu64可用AVX-512VL and AVX-512F:

$ cat test.cxx
#include <cstdint>
#include <immintrin.h>
int main(int argc, char* argv[])
{
    uint64_t x[8];
    __m512i y = _mm512_loadu_epi64(x);
    return 0;
}

进而:

$ /opt/local/bin/g++-mp-6 -mavx512f -Wa,-q test.cxx -o test.exe
test.cxx: In function 'int main(int, char**)':
test.cxx:6:37: error: '_mm512_loadu_epi64' was not declared in this scope
     __m512i y = _mm512_loadu_epi64(x);
                                     ^
$ /opt/local/bin/g++-mp-6 -mavx -mavx2 -mavx512f -Wa,-q test.cxx -o test.exe
test.cxx: In function 'int main(int, char**)':
test.cxx:6:37: error: '_mm512_loadu_epi64' was not declared in this scope
     __m512i y = _mm512_loadu_epi64(x);
                                     ^
$ /opt/local/bin/g++-mp-6 -msse4.1 -msse4.2 -mavx -mavx2 -mavx512f -Wa,-q test.cxx -o test.exe
test.cxx: In function 'int main(int, char**)':
test.cxx:6:37: error: '_mm512_loadu_epi64' was not declared in this scope
     __m512i y = _mm512_loadu_epi64(x);
                                     ^

我把选项走回到-msse2没有成功。我似乎错过了一些东西。

为现代 GCC 使用 AVX-512 需要什么?


根据一个/opt/local/bin/g++-mp-6 -v,这些是标头搜索路径:

#include "..." search starts here:
#include <...> search starts here:
 /opt/local/include/gcc6/c++/
 /opt/local/include/gcc6/c++//x86_64-apple-darwin13
 /opt/local/include/gcc6/c++//backward
 /opt/local/lib/gcc6/gcc/x86_64-apple-darwin13/6.5.0/include
 /opt/local/include
 /opt/local/lib/gcc6/gcc/x86_64-apple-darwin13/6.5.0/include-fixed
 /usr/include
 /System/Library/Frameworks
 /Library/Frameworks

进而:

$ grep -R '_mm512_' /opt/local/lib/gcc6/ | grep avx512f | head -n 8
/opt/local/lib/gcc6//gcc/x86_64-apple-darwin13/6.5.0/include/avx512fintrin.h:_mm512_set_epi64 (long long __A, long long __B, long long __C,
/opt/local/lib/gcc6//gcc/x86_64-apple-darwin13/6.5.0/include/avx512fintrin.h:_mm512_set_epi32 (int __A, int __B, int __C, int __D,
/opt/local/lib/gcc6//gcc/x86_64-apple-darwin13/6.5.0/include/avx512fintrin.h:_mm512_set_pd (double __A, double __B, double __C, double __D,
/opt/local/lib/gcc6//gcc/x86_64-apple-darwin13/6.5.0/include/avx512fintrin.h:_mm512_set_ps (float __A, float __B, float __C, float __D,
/opt/local/lib/gcc6//gcc/x86_64-apple-darwin13/6.5.0/include/avx512fintrin.h:#define _mm512_setr_epi64(e0,e1,e2,e3,e4,e5,e6,e7)                       \
/opt/local/lib/gcc6//gcc/x86_64-apple-darwin13/6.5.0/include/avx512fintrin.h:  _mm512_set_epi64(e7,e6,e5,e4,e3,e2,e1,e0)
/opt/local/lib/gcc6//gcc/x86_64-apple-darwin13/6.5.0/include/avx512fintrin.h:#define _mm512_setr_epi32(e0,e1,e2,e3,e4,e5,e6,e7,                       \
/opt/local/lib/gcc6//gcc/x86_64-apple-darwin13/6.5.0/include/avx512fintrin.h:  _mm512_set_epi32(e15,e14,e13,e12,e11,e10,e9,e8,e7,e6,e5,e4,e3,e2,e1,e0)
...

如果没有屏蔽,这个内在函数就没有理由存在或使用它来代替等效的_mm512_loadu_si512。这只是令人困惑,并且可能会欺骗人类读者认为这是一个vmovq单个零延伸载荷epi64.

,但即使是当前的 trunk gcc(在 Godbolt 上)也没有定义它。

几乎所有 AVX512 指令都支持合并掩码和零掩码。过去纯粹按位/整个寄存器的指令,没有有意义的元素边界,现在有 32 位和 64 位元素风格,例如vpxord and vpxorq. Or vmovdqa32 and vmovdqa64 http://www.felixcloutier.com/x86/movdqa:vmovdqa32:vmovdqa64. But 使用任何一个不带掩码的版本仍然只是普通的向量加载/存储/寄存器复制,并且在带有内在函数的 C++ 源代码中为它们指定有关元素大小的任何内容是没有意义的,只有总向量宽度。

也可以看看_mm512_load_epi32 和 _mm512_load_si512 有什么区别? https://stackoverflow.com/questions/53905757/what-is-the-difference-between-mm512-load-epi32-and-mm512-load-si512


SSE* 和 AVX1/2 选项与 GCC 标头是否根据 gcc 内置函数定义此内在函数无关;-mavx512f已经暗示了 AVX512 之前的所有 Intel SSE/AVX 扩展。


它存在于 clang trunk 中(但不是 7.0,所以它是最近才添加的)。

  • 未对齐的_mm512_loadu_si512- 到处都支持,用这个
  • 未对齐的_mm512_loadu_epi64- clang trunk,而不是 gcc。
  • aligned _mm512_load_si512- 到处都支持,用这个
  • aligned _mm512_load_epi64- 令人惊讶的是,到处都受到支持。
  • 未对齐的_mm512_maskz_loadu_epi64- 到处都受支持,将其用于零屏蔽负载
  • 未对齐的_mm512_mask_loadu_epi64- 到处都受支持,将其用于合并掩码加载。

此代码早在 4.9.0 就可以在 gcc 上编译,早在 3.9 就可以在主线 (Linux) clang 上编译,两者都带有-march=avx512f。或者如果他们支持的话-march=skylake-avx512 or -march=knl。我还没有用 Apple Clang 进行过测试。

#include <immintrin.h>

__m512i loadu_si512(void *x) { return _mm512_loadu_si512(x); }
__m512i load_epi64(void *x)  {  return _mm512_load_epi64(x); }
//__m512i loadu_epi64(void *x) {  return _mm512_loadu_epi64(x); }

__m512i loadu_maskz(void *x) { return _mm512_maskz_loadu_epi64(0xf0, x); }
__m512i loadu_mask(void *x)  { return _mm512_mask_loadu_epi64(_mm512_setzero_si512(), 0xf0, x); }

神箭链接 https://godbolt.org/#g:!((g:!((g:!((g:!((h:codeEditor,i:(j:1,lang:c%2B%2B,source:'%23include+%3Cimmintrin.h%3E%0A%0A__m512i+loadu_si512(void+*x)+%7B+return+_mm512_loadu_si512(x)%3B+%7D%0A__m512i+load_epi64(void+*x)++%7B++return+_mm512_load_epi64(x)%3B+%7D%0A//__m512i+loadu_epi64(void+*x)+%7B++return+_mm512_loadu_epi64(x)%3B+%7D%0A%0A__m512i+loadu_maskz(void+*x)+%7B+return+_mm512_maskz_loadu_epi64(0xf0,+x)%3B+%7D%0A__m512i+loadu_mask(void+*x)++%7B+return+_mm512_mask_loadu_epi64(_mm512_setzero_si512(),+0xf0,+x)%3B+%7D%0A'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:51.80156657963446,l:'4',m:32.73092369477912,n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:clang390,filters:(b:'0',binary:'1',commentOnly:'0',demangle:'1',directives:'0',execute:'1',intel:'0',trim:'1'),lang:c%2B%2B,libs:!(),options:'-O3+-march%3Dskylake+-mavx512f+-Wall',source:1),l:'5',n:'0',o:'x86-64+clang+3.9.0+(Editor+%231,+Compiler+%232)+C%2B%2B',t:'0')),header:(),l:'4',m:46.354326123627544,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compiler:2,editor:1,wrap:'1'),l:'5',n:'0',o:'%232+with+x86-64+clang+3.9.0',t:'0')),l:'4',m:20.914750181593334,n:'0',o:'',s:0,t:'0')),k:51.80156657963446,l:'3',n:'0',o:'',t:'0'),(g:!((g:!((h:compiler,i:(compiler:g490,filters:(b:'0',binary:'1',commentOnly:'0',demangle:'1',directives:'0',execute:'1',intel:'0',trim:'1'),lang:c%2B%2B,libs:!(),options:'-O3+-mavx512f+-Wall',source:1),l:'5',n:'0',o:'x86-64+gcc+4.9.0+(Editor+%231,+Compiler+%231)+C%2B%2B',t:'0')),k:56.03983023179889,l:'4',m:58.266666666666666,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compiler:1,editor:1,wrap:'1'),l:'5',n:'0',o:'%231+with+x86-64+gcc+4.9.0',t:'0')),header:(),l:'4',m:41.733333333333334,n:'0',o:'',s:0,t:'0')),k:48.19843342036554,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4;你可以取消注释_mm512_loadu_epi64并将编译器翻转到 clang trunk 以查看它在那里工作。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

错误:“_mm512_loadu_epi64”未在此范围内声明 的相关文章

随机推荐