Reputation: 766
I am using Clion in Mac to write C++ code with the Clang compiler. I know that my CPU supports AVX1.0. However, I think there is a problem with compiling AVX
stuff in this simple code. The error is:
always_inline function '_mm256_set_ps' requires target feature 'avx', but would be inlined into function 'main' that is compiled without support for 'avx'
and the code:
#include <immintrin.h>
#include <cstdio>
int main() {
/* Initialize the two argument vectors */
__m256 evens = _mm256_set_ps(2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0);
__m256 odds = _mm256_set_ps(1.0, 3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0);
/* Compute the difference between the two vectors */
__m256 result = _mm256_sub_ps(evens, odds);
/* Display the elements of the result vector */
auto* f = (float*)&result;
printf("%f %f %f %f %f %f %f %f\n",
f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7]);
return 0;
}
should I change something in Clion?
Upvotes: 0
Views: 622
Reputation: 766
I just found the solution. Add it in your Cmake file:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
Now, it works properly.
Upvotes: 1