小编pra*_*jha的帖子

运行基本的Avx512代码时获取非法指令

我正在尝试学习AVX指令,并且在运行我收到的基本代码时

非法指令(核心已转储)

该代码在下面提到,我正在使用它进行编译

g ++ -mavx512f 1.cpp

问题到底是什么?如何解决?谢谢!

#include <immintrin.h>
#include<iostream>
using namespace std;

void add(const float a[], const float b[], float res[], int n)
{
    int i = 0;

    for(; i < (n&(~0x31)) ; i+=32 )
    {
        __m512 x = _mm512_loadu_ps( &a[i] );
        __m512 y = _mm512_loadu_ps( &b[i] );

        __m512 z = _mm512_add_ps(x,y);
        _mm512_stream_ps(&res[i],z);
    }

    for(; i<n; i++) res[i] = a[i] + b[i];
}

int main()
{
    int n = 100000;
    float a[n], b[n], res[n];
    for(int i = 0;i …
Run Code Online (Sandbox Code Playgroud)

c c++ avx avx2 avx512

1
推荐指数
1
解决办法
142
查看次数

标签 统计

avx ×1

avx2 ×1

avx512 ×1

c ×1

c++ ×1