diff options
author | Tom Rondeau <tom@trondeau.com> | 2014-01-09 14:16:09 -0500 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2014-01-09 14:53:19 -0500 |
commit | 3b749c6abca94e01047ac375bc65a25cc1a9a1a6 (patch) | |
tree | 978182326ea8545149ec3ca34ce3b6417804f895 /volk/lib | |
parent | 7fcf514bab5d62aefec0d7741c720af76666b3f1 (diff) |
volk: modifying tests for AVX and SSE4a support in compiler/CPU.
Diffstat (limited to 'volk/lib')
-rw-r--r-- | volk/lib/CMakeLists.txt | 87 |
1 files changed, 51 insertions, 36 deletions
diff --git a/volk/lib/CMakeLists.txt b/volk/lib/CMakeLists.txt index 2727a9182c..8195d9eea7 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,48 +149,62 @@ 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 like some versions of clang + ######################################################################### + + # 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 + 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_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) + + # 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() -######################################################################### -# eliminate AVX if cvtpi32_ps intrinsic fails like some versions of clang -######################################################################### - -# check to see if the compiler/linker works with cvtpi32_ps instrinsic -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 - 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_CVTPI32_PS 0) -endif() -file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps - ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c) - -if(${HAVE_CVTPI32_PS}) - add_definitions(-DHAVE_CVTPI32_PS) +if(${HAVE_AVX_CVTPI32_PS}) + add_definitions(-DHAVE_AVX_CVTPI32_PS) endif() -if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") - execute_process(COMMAND ${CMAKE_C_COMPILER} --version - OUTPUT_VARIABLE cmake_c_compiler_version) - - # 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 - string(FIND ${cmake_c_compiler_version} "LLVM " clang_version_index) - string(SUBSTRING ${cmake_c_compiler_version} ${clang_version_index} 8 clang_version) - string(SUBSTRING ${clang_version} 5 3 CMAKE_C_COMPILER_VERSION) - 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") ######################################################################## # implement overruling in the ORC case, |