1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-12 10:20:32 +00:00

Fix detection of AVX and NEON

Let the compiler know where to find volk/volk_common.h when testing for AVX and NEON

Make use of __VOLK_VOLATILE

Replace <inttypes.h> by <stdint.h> in volk/volk_common.h, fixes configuration in macOS
This commit is contained in:
Carles Fernandez 2020-01-14 12:51:55 +01:00
parent 931d69b76e
commit 98ea7dc276
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
2 changed files with 7 additions and 5 deletions

View File

@ -132,7 +132,7 @@
//
// The bit128 union used by some
//
#include <inttypes.h>
#include <stdint.h>
#ifdef LV_HAVE_SSE
#ifdef _WIN32

View File

@ -151,12 +151,13 @@ set(HAVE_AVX_CVTPI32_PS 0)
if(CPU_IS_x86)
# check to see if the compiler/linker works with xgetb instruction
if(NOT MSVC)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv.c "#include <volk_gnsssdr/volk_gnsssdr_common.h>\n unsigned long long _xgetbv(unsigned int index) { unsigned int eax, edx; __VOLK_ASM __volatile__(\"xgetbv\" : \"=a\"(eax), \"=d\"(edx) : \"c\"(index)); return ((unsigned long long)edx << 32) | eax; } int main (void) { (void) _xgetbv(0); return (0); }")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv.c "#include <volk_gnsssdr/volk_gnsssdr_common.h>\n unsigned long long _xgetbv(unsigned int index) { unsigned int eax, edx; __VOLK_ASM __VOLK_VOLATILE(\"xgetbv\" : \"=a\"(eax), \"=d\"(edx) : \"c\"(index)); return ((unsigned long long)edx << 32) | eax; } int main (void) { (void) _xgetbv(0); return (0); }")
set(_AUX_INCLUDE_FLAG -I${PROJECT_SOURCE_DIR}/include)
else()
# MSVC defines an intrinsic
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv.c "#include <stdio.h> \n #include <intrin.h> \n int main() { int avxSupported = 0; \n#if (_MSC_FULL_VER >= 160040219) \nint cpuInfo[4]; __cpuid(cpuInfo, 1);\nif ((cpuInfo[2] & (1 << 27) || 0) && (cpuInfo[2] & (1 << 28) || 0)) \n{\nunsigned long long xcrFeatureMask = _xgetbv(_XCR_XFEATURE_ENABLED_MASK);\n avxSupported = (xcrFeatureMask & 0x6) == 6;}\n#endif \n return 1- avxSupported; }")
endif()
execute_process(COMMAND ${CMAKE_C_COMPILER} -o
execute_process(COMMAND ${CMAKE_C_COMPILER} ${_AUX_INCLUDE_FLAG} -o
${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv
${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv.c
OUTPUT_QUIET ERROR_QUIET
@ -276,9 +277,10 @@ check_c_source_compiles("#include <arm_neon.h>\nint main(){ uint8_t *dest; uint8
neon_compile_result)
if(neon_compile_result)
check_c_source_compiles("#include <volk_gnsssdr/volk_gnsssdr_common.h>\n int main(){__VOLK_ASM volatile(\"vrev32.8 q0, q0\");}"
set(CMAKE_REQUIRED_INCLUDES ${PROJECT_SOURCE_DIR}/include)
check_c_source_compiles("#include <volk_gnsssdr/volk_gnsssdr_common.h>\n int main(){__VOLK_ASM __VOLK_VOLATILE(\"vrev32.8 q0, q0\");}"
have_neonv7_result)
check_c_source_compiles("#include <volk_gnsssdr/volk_gnsssdr_common.h>\n int main(){__VOLK_ASM volatile(\"sub v1.4s,v1.4s,v1.4s\");}"
check_c_source_compiles("#include <volk_gnsssdr/volk_gnsssdr_common.h>\n int main(){__VOLK_ASM __VOLK_VOLATILE(\"sub v1.4s,v1.4s,v1.4s\");}"
have_neonv8_result)
if(NOT have_neonv7_result)