Search code examples
coptimizationx86avxcpuid

How do I know which AVX C functions are available on different processor models


Basically the title. For example, I am trying to run instructions like:

_mm256_load_pd, _mm256_add_pd, _mm256_stream_pd and the 128 bits version on the processor: Intel Xeon, E5630, 2.53 GHz, IBM HS22. But I am getting Illegal instruction any idea for a site where I could see which functions are available for this processor?


Solution

  • Check your /proc/cpuinfo if you're on an OS that has one.

    Or use clang or gcc -march=native - they will refuse to compile any intrinsics your CPU doesn't support. (Unlike MSVC or ICC, which will let you use intrinsics without telling it that the target machine supports them.)


    To look it up by CPU model, google the model, e.g. Xeon, E5630 -> https://ark.intel.com/content/www/us/en/ark/products/47924/intel-xeon-processor-e5630-12m-cache-2-53-ghz-5-86-gt-s-intel-qpi.html

    • Instruction Set Extensions: Intel® SSE4.2

    So no AVX at all, because it's a Westmere-EP microarchitecture from 2010 (before Sandybridge.)

    For more detail CPUs, you can also check http://instlatx64.atw.hu/ and check the CPUID dump for that model (or one of the same microarchitecture), if you can find one. e.g. a screenshot of Aida64 CPUID running on a Westmere-EX, and instruction latency/throughput benchmark output, with info at the top of the text file including decoded CPUID info showing which ISA extensions it has. Also raw CPUID dumps which you can cross-reference with the CPUID feature-bit required (https://sandpile.org/x86/cpuid.htm) by any extension you're interested in (like cmpxchg16b or FSGSBASE that Intel's ark pages won't mention.).


    related: https://software.intel.com/sites/landingpage/IntrinsicsGuide/ tells you what ISA extension is required by the corresponding asm instruction for each intrinsic.