How to solve “illegal instruction” for vfmadd213ps?

限于喜欢 提交于 2020-01-30 12:26:09

问题


I have tried AVX intrinsics. But it caused "Unhandled exception at 0x00E01555 in test.exe: 0xC000001D: Illegal Instruction."

I used Visual studio 2015. And the exception error is caused at "vfmadd213ps ymm2,ymm1,ymm0" instruction. I have tried set "/arch:AVX" and "/arch:AVX2", but still error caused. Below is my code.

    #include <immintrin.h>

    int main(int argc, char *argv[])
    {
    float a[8] = { 0 };
    float b[8] = { 0 };
    float c[8] = { 0 };
    __m256 _a = _mm256_loadu_ps(a);
    __m256 _b = _mm256_loadu_ps(b);
    __m256 _c = _mm256_loadu_ps(c);
    __m256 result = _mm256_fmadd_ps(_a, _b, _c);
    _mm256_storeu_ps(c, result);
    return 0;
    }

"__m256 result = _mm256_fmadd_ps(_a, _b, _c);" is disassembly

    vmovups     ymm0,ymmword ptr [_c]  
    vmovups     ymm1,ymmword ptr [_b]  
    vmovups     ymm2,ymmword ptr [_a]  
    vfmadd213ps ymm2,ymm1,ymm0  
    vmovups     ymmword ptr [ebp-160h],ymm2  
    vmovups     ymm0,ymmword ptr [ebp-160h]  
    vmovups     ymmword ptr [result],ymm0  

and the error caused at "vfmadd213ps ymm2,ymm1,ymm0".

So what did I wrong? OS is win 7 64bit, CPU is Intel(R) Core(TM) i7-3520M CPU @ 2.90Ghz (4 CPUs), ~2.9Ghz.


回答1:


Because your processor doesn't support that instruction.

FVMADD213PS is part of the FMA3 instruction set extension. Intel added support for this instruction set extension in the Haswell ("fourth-generation core") Intel microarchitecture; the processor in your laptop is an Ivy Bridge ("third-generation core") part, so it is too old to support this feature.



来源:https://stackoverflow.com/questions/57155545/how-to-solve-illegal-instruction-for-vfmadd213ps

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