added more compiler flags. Added option for avx2

master
Ismael Gomez 8 years ago
parent ef01150982
commit 49a2a749a1

@ -112,11 +112,16 @@ if(CMAKE_COMPILER_IS_GNUCC)
else(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
find_package(SSE)
if (HAVE_AVX2)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx2 -Ofast -flto -funroll-loops -DLV_HAVE_AVX -DLV_HAVE_SSE")
elseif (HAVE_AVX2)
if(HAVE_AVX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx -DLV_HAVE_AVX -DLV_HAVE_SSE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx -Ofast -flto -funroll-loops -DLV_HAVE_AVX -DLV_HAVE_SSE")
elseif(HAVE_SSE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -msse4.1 -DLV_HAVE_SSE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -msse4.1 -Ofast -flto -funroll-loops -DLV_HAVE_SSE")
endif(HAVE_AVX)
endif (HAVE_AVX2)
endif(${CMAKE_BUILD_TYPE} STREQUAL "Debug")

@ -6,6 +6,7 @@ include(CheckCSourceRuns)
option(ENABLE_SSE "Enable compile-time SSE4.1 support." ON)
option(ENABLE_AVX "Enable compile-time AVX support." ON)
option(ENABLE_AVX2 "Enable compile-time AVX2 support." ON)
if (ENABLE_SSE)
#
@ -53,6 +54,30 @@ if (ENABLE_SSE)
endif()
endif()
if (ENABLE_AVX2)
#
# Check compiler for AVX intrinsics
#
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG )
set(CMAKE_REQUIRED_FLAGS "-mavx2")
check_c_source_runs("
#include <immintrin.h>
int main()
{
__m256i a = _mm256_setzero_si256();
__m256i b = _mm256_abs_epi16(a);
return 0;
}"
HAVE_AVX2)
endif()
if (HAVE_AVX2)
message(STATUS "AVX2 is enabled - target CPU must support it")
endif()
endif()
endif()
mark_as_advanced(HAVE_SSE, HAVE_AVX)
mark_as_advanced(HAVE_SSE, HAVE_AVX, HAVE_AVX2)
Loading…
Cancel
Save