diff options
author | Tom Rondeau <tom@trondeau.com> | 2014-01-09 16:35:58 -0500 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2014-01-09 16:35:58 -0500 |
commit | cbd21fccd6108ed2568508e72073ab1fc02604c7 (patch) | |
tree | 5e8e3f0daa971b5f34a37b31e54ee233f00a0bc4 /volk/lib | |
parent | e751e54aaeae1eb47b83169d905331b4c704b431 (diff) | |
parent | 7bb11823caaef273f9a0b2a033fedf11c3b88bc2 (diff) |
Merge branch 'maint'
Diffstat (limited to 'volk/lib')
-rw-r--r-- | volk/lib/CMakeLists.txt | 62 |
1 files changed, 47 insertions, 15 deletions
diff --git a/volk/lib/CMakeLists.txt b/volk/lib/CMakeLists.txt index 07e1408b51..cda10872c7 100644 --- a/volk/lib/CMakeLists.txt +++ b/volk/lib/CMakeLists.txt @@ -123,6 +123,7 @@ endmacro(OVERRULE_ARCH) # executable does not function correctly}. ######################################################################## set(HAVE_XGETBV 0) +set(HAVE_AVX_CVTPI32_PS 0) if(CPU_IS_x86) # check to see if the compiler/linker works with xgetb instruction file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv.c "unsigned long long _xgetbv(unsigned int index) { unsigned int eax, edx; __asm__ __volatile__(\"xgetbv\" : \"=a\"(eax), \"=d\"(edx) : \"c\"(index)); return ((unsigned long long)edx << 32) | eax; } int main (void) { (void) _xgetbv(0); return (0); }") @@ -138,7 +139,7 @@ if(CPU_IS_x86) OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE avx_exe_result) if(NOT ${avx_exe_result} EQUAL 0) - OVERRULE_ARCH(avx "CPU missing xgetbv.") + OVERRULE_ARCH(avx "CPU missing xgetbv") else() set(HAVE_XGETBV 1) endif() @@ -148,32 +149,63 @@ if(CPU_IS_x86) endif() file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv ${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv.c) -endif() -######################################################################## -# eliminate AVX if cvtpi32_ps intrinsic fails on Apple -######################################################################## + ######################################################################### + # eliminate AVX if cvtpi32_ps intrinsic fails like some versions of clang + ######################################################################### -if(${HAVE_XGETBV}) - # check to see if the compiler/linker works with cvtpi32_ps instrinsic + # check to see if the compiler/linker works with cvtpi32_ps instrinsic when using AVX file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c "#include <immintrin.h>\nint main (void) {__m128 __a; __m64 __b; __m128 foo = _mm_cvtpi32_ps(__a, __b); return (0); }") execute_process(COMMAND ${CMAKE_C_COMPILER} -mavx -o - ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps - ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c + ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps + ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c + OUTPUT_QUIET ERROR_QUIET + RESULT_VARIABLE avx_compile_result) + if(NOT ${avx_compile_result} EQUAL 0) + OVERRULE_ARCH(avx "Compiler missing cvtpi32_ps instrinsic") + elseif(NOT CROSSCOMPILE_MULTILIB) + execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps OUTPUT_QUIET ERROR_QUIET - RESULT_VARIABLE avx_compile_result) - if(NOT ${avx_compile_result} EQUAL 0) - OVERRULE_ARCH(avx "Compiler missing cvtpi32_ps instrinsic") - set(HAVE_XGETBV 0) + RESULT_VARIABLE avx_exe_result) + if(NOT ${avx_exe_result} EQUAL 0) + OVERRULE_ARCH(avx "CPU missing cvtpi32_ps") + else() + set(HAVE_AVX_CVTPI32_PS 1) + endif() + else() + set(HAVE_AVX_CVTPI32_PS 1) endif() file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps - ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c) -endif() + ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c) + + # Disable SSE4a if Clang is less than version 3.2 + if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") + # Figure out the version of Clang + if(CMAKE_VERSION VERSION_LESS "2.8.10") + # Exctract the Clang version from the --version string. + # In cmake 2.8.10, we can just use CMAKE_C_COMPILER_VERSION + # without having to go through these string manipulations + execute_process(COMMAND ${CMAKE_C_COMPILER} --version + OUTPUT_VARIABLE clang_version) + string(REGEX MATCH "[0-9].[0-9]" CMAKE_C_COMPILER_VERSION ${clang_version}) + endif(CMAKE_VERSION VERSION_LESS "2.8.10") + + if(CMAKE_C_COMPILER_VERSION VERSION_LESS "3.2") + OVERRULE_ARCH(sse4_a "Clang >= 3.2 required for SSE4a") + endif(CMAKE_C_COMPILER_VERSION VERSION_LESS "3.2") + endif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") + +endif(CPU_IS_x86) if(${HAVE_XGETBV}) add_definitions(-DHAVE_XGETBV) endif() +if(${HAVE_AVX_CVTPI32_PS}) + add_definitions(-DHAVE_AVX_CVTPI32_PS) +endif() + + ######################################################################## # implement overruling in the ORC case, # since ORC always passes flag detection |