RyuJIT not making full use of SIMD intrinsics

前端 未结 1 898
萌比男神i
萌比男神i 2021-02-19 03:37

I\'m running some C# code that uses System.Numerics.Vector but as far as I can tell I\'m not getting the full benefit of SIMD intrinsics. I\'m using Visual

1条回答
  •  渐次进展
    2021-02-19 04:28

    Your processor is a bit dated, its micro-architecture is Ivy Bridge. The "tock" of Sandy Bridge, a feature shrink without architectural changes. Your nemesis is this bit of code in RyuJIT, located in ee_il_dll.cpp, CILJit::getMaxIntrinsicSIMDVectorLength() function:

    if (((cpuCompileFlags & CORJIT_FLG_PREJIT) == 0) &&
        ((cpuCompileFlags & CORJIT_FLG_FEATURE_SIMD) != 0) &&
        ((cpuCompileFlags & CORJIT_FLG_USE_AVX2) != 0))
    {
        static ConfigDWORD fEnableAVX;
        if (fEnableAVX.val(CLRConfig::EXTERNAL_EnableAVX) != 0)
        {
            return 32;
        }
    }
    

    Note the use of CORJIT_FLG_USE_AVX2. Your processor does not support AVX2 yet, that extension became available in Haswell. The next micro-architecture after Ivy Bridge, a "tick". Very nice processor btw, discoveries like this one have a major wow factor.

    Nothing you can do about this but go shopping. For inspiration, you can look at the kind of code it generates in this post.

    0 讨论(0)
提交回复
热议问题