Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using AVX with GCC - avxintrin.h missing

Tags:

c++

gcc

avx

I'm running my Laptop(coreI5) on Ubuntu-64bit 12.04LTS. I'm trying to get into AVX for some random number generation.

In Eclipse-CDT I created a new C++ "Hello World" project using Linux GCC. I included immintrin.h and tried just to load something in a __m256 type.

The Compiler throws an Error:

Type '__m256' was not declared in this scope

I looked in the immintrin.h and looked for the avxintrin.h, just in case, there is a spelling error. When clicking open declaration on avxintrin.h Eclipse says:

Could not find include file 'avxintrin.h' on include paths

allthow the file is available at /usr/lib/gcc/x86_64-linux-gnu/4.6/include/avxintrin.h.

Can anyone give me hint , what to do? There are not a lot of tutorials or help about AVX online. I think I have to make some adjustments in the compiler options or something like this(!?)

Anyways here is the code:

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

int main() {
    float out[8];
    float a[8] = { 0.0,1.0,2.0,3.0,4.0,5.0,6.0,7};
    __m256 test =  _mm256_load_ps(&a[0]);
    cout << "" << endl; // prints 
    return 0;
}

And here the errors:

../src/seminar.cpp:15:2: error: '__m256' was not declared in this scope
../src/seminar.cpp:15:9: error: expected ';' before 'test'

Thanks in advance!

like image 630
toebs Avatar asked Sep 05 '13 13:09

toebs


1 Answers

Compile with -mavx to tell the compiler that you want to use AVX instructions.

like image 164
Greg Allen Avatar answered Oct 16 '22 08:10

Greg Allen