Search code examples
c++x86clang++intrinsicsavx

__m256 unknown type (clang 5.1/i5 CPU)?


I just started to experiment with intrinsics. I managed to successfully compile a program using __m128 on a Mac using Clang 5.1. The CPU on this Mac is an Intel core i5 M540.

When I tried to compile the same code with __m256, I get the following message:

simple.cpp:4:2: error: unknown type name '__m256'
    __m256 A;

The code looks like this:

#include <immintrin.h>
int main()
{
    __m256 A;
    return 0;
}

And here is the command used to compile it:

c++ -o simple simple.cpp -march=native -O3

Is it just that my CPU is too old to support AVX instruction set? Are all the options I use (on the command line) correct? I checked in the immintrin.h include file, and it does call another including file which seems to be defining AVX intrinsics. Apologies if the question is naive or if the terminology is misused, as I said, I am new to this topic.


Solution

  • The Intel 540M CPU is in the Westmere microarchitecture (sorry for the mistake in the comment) which appears before Sandy Bridge when AVX was introduced so it doesn't support AVX. The term "core i5" covers a wide range of architectures from Nehalem to Haswell (current) so using a core i5 CPU doesn't mean that you'll have support for all instruction sets like the lates ones.