diff --git a/CMakeLists.txt b/CMakeLists.txt index ef8c2adc0..f19f4336e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -223,13 +223,15 @@ gnsssdr_check_build_type(${CMAKE_BUILD_TYPE}) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") # Enable optimization options in GCC for Release and RelWithDebInfo build types -if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # flag -O3 enables tree vectorization - # See https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html - set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG") - set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") - set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG") +if((${CMAKE_SYSTEM_NAME} MATCHES "Linux|kFreeBSD|GNU") AND (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")) + if(NOT (${LINUX_DISTRIBUTION} MATCHES "Fedora") AND NOT (${LINUX_DISTRIBUTION} MATCHES "Gentoo")) + # flag -O3 enables tree vectorization + # See https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html + set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG") + set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG") + endif() endif() # allow 'large' files in 32 bit builds diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index 621759afa..1435e68de 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -150,6 +150,19 @@ if(NOT ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) AND NOT (CMAKE_CXX endif() endif() +# Disable complex math NaN/INFO range checking for performance +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag(-fcx-limited-range HAVE_CX_LIMITED_RANGE) +if(HAVE_CX_LIMITED_RANGE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcx-limited-range") +endif() + +include(CheckCCompilerFlag) +check_c_compiler_flag(-fcx-limited-range HAVE_C_LIMITED_RANGE) +if(HAVE_C_LIMITED_RANGE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcx-limited-range") +endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_CXX_FLAGS} -Wall") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include/volk_gnsssdr/volk_gnsssdr_common.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include/volk_gnsssdr/volk_gnsssdr_common.h index 5a46b12bf..67340410f 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include/volk_gnsssdr/volk_gnsssdr_common.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include/volk_gnsssdr/volk_gnsssdr_common.h @@ -18,15 +18,15 @@ // // Cross-platform attribute macros not included in VOLK // -#if defined __clang__ -#define __VOLK_GNSSSDR_PREFETCH(addr) __builtin_prefetch(addr) -#define __VOLK_GNSSSDR_PREFETCH_LOCALITY(addr, rw, locality) __builtin_prefetch(addr, rw, locality) -#elif defined __GNUC__ -#define __VOLK_GNSSSDR_PREFETCH(addr) __builtin_prefetch(addr) -#define __VOLK_GNSSSDR_PREFETCH_LOCALITY(addr, rw, locality) __builtin_prefetch(addr, rw, locality) -#elif _MSC_VER +#if _MSC_VER #define __VOLK_GNSSSDR_PREFETCH(addr) #define __VOLK_GNSSSDR_PREFETCH_LOCALITY(addr, rw, locality) +#elif defined(__clang__) +#define __VOLK_GNSSSDR_PREFETCH(addr) __builtin_prefetch(addr) +#define __VOLK_GNSSSDR_PREFETCH_LOCALITY(addr, rw, locality) __builtin_prefetch(addr, rw, locality) +#elif defined(__GNUC__) +#define __VOLK_GNSSSDR_PREFETCH(addr) __builtin_prefetch(addr) +#define __VOLK_GNSSSDR_PREFETCH_LOCALITY(addr, rw, locality) __builtin_prefetch(addr, rw, locality) #else #define __VOLK_GNSSSDR_PREFETCH(addr) #define __VOLK_GNSSSDR_PREFETCH_LOCALITY(addr, rw, locality) @@ -38,7 +38,17 @@ // // Cross-platform attribute macros // -#if defined(__clang__) && (!defined(_MSC_VER)) +#if _MSC_VER +#define __VOLK_ATTR_ALIGNED(x) __declspec(align(x)) +#define __VOLK_ATTR_UNUSED +#define __VOLK_ATTR_INLINE __forceinline +#define __VOLK_ATTR_DEPRECATED __declspec(deprecated) +#define __VOLK_ATTR_EXPORT __declspec(dllexport) +#define __VOLK_ATTR_IMPORT __declspec(dllimport) +#define __VOLK_PREFETCH(addr) +#define __VOLK_ASM __asm +#define __VOLK_VOLATILE +#elif defined(__clang__) // AppleClang also defines __GNUC__, so do this check first. These // will probably be the same as for __GNUC__, but let's keep them // separate just to be safe. @@ -51,7 +61,7 @@ #define __VOLK_ATTR_EXPORT __attribute__((visibility("default"))) #define __VOLK_ATTR_IMPORT __attribute__((visibility("default"))) #define __VOLK_PREFETCH(addr) __builtin_prefetch(addr) -#elif defined __GNUC__ +#elif defined(__GNUC__) #define __VOLK_ATTR_ALIGNED(x) __attribute__((aligned(x))) #define __VOLK_ATTR_UNUSED __attribute__((unused)) #define __VOLK_ATTR_INLINE __attribute__((always_inline)) @@ -66,17 +76,8 @@ #define __VOLK_ATTR_IMPORT #endif #define __VOLK_PREFETCH(addr) __builtin_prefetch(addr) -#elif _MSC_VER -#define __VOLK_ATTR_ALIGNED(x) __declspec(align(x)) -#define __VOLK_ATTR_UNUSED -#define __VOLK_ATTR_INLINE __forceinline -#define __VOLK_ATTR_DEPRECATED __declspec(deprecated) -#define __VOLK_ATTR_EXPORT __declspec(dllexport) -#define __VOLK_ATTR_IMPORT __declspec(dllimport) -#define __VOLK_PREFETCH(addr) -#define __VOLK_ASM __asm -#define __VOLK_VOLATILE #else +#warning "Unknown compiler. Using default VOLK macros, which may or not work." #define __VOLK_ATTR_ALIGNED(x) #define __VOLK_ATTR_UNUSED #define __VOLK_ATTR_INLINE @@ -88,19 +89,19 @@ #define __VOLK_VOLATILE __volatile__ #endif -// +//////////////////////////////////////////////////////////////////////// // Ignore annoying warnings in MSVC -// +//////////////////////////////////////////////////////////////////////// #if defined(_MSC_VER) -#pragma warning(disable : 4244) // 'conversion' conversion from 'type1' to 'type2', possible loss of data -#pragma warning(disable : 4305) // 'identifier' : truncation from 'type1' to 'type2' +#pragma warning(disable : 4244) //'conversion' conversion from 'type1' to 'type2', possible loss of data +#pragma warning(disable : 4305) //'identifier' : truncation from 'type1' to 'type2' #endif -// +//////////////////////////////////////////////////////////////////////// // C-linkage declaration macros // FIXME: due to the usage of complex.h, require gcc for c-linkage -// -#if defined(__cplusplus) && (__GNUC__) +//////////////////////////////////////////////////////////////////////// +#if defined(__cplusplus) && (defined(__GNUC__) || defined(__clang__)) #define __VOLK_DECL_BEGIN \ extern "C" \ {