diff --git a/CMakeLists.txt b/CMakeLists.txt index 45c36ea33..4fef66693 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -341,8 +341,8 @@ set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") set(GNSSSDR_GNSSTK_LOCAL_VERSION "13.4.0") set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.23") set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.12") -set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "21.3") -set(GNSSSDR_BENCHMARK_LOCAL_VERSION "1.6.2") +set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "21.4") +set(GNSSSDR_BENCHMARK_LOCAL_VERSION "1.7.0") set(GNSSSDR_MATHJAX_EXTERNAL_VERSION "2.7.7") if(CMAKE_VERSION VERSION_LESS "3.16") @@ -1528,6 +1528,11 @@ if(NOT GLOG_FOUND OR ${LOCAL_GFLAGS}) endif() message(STATUS " glog v${GNSSSDR_GLOG_LOCAL_VERSION} will be downloaded, built, and statically linked automatically") message(STATUS " when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'.") + find_package(LIBUNWIND) + set_package_properties(LIBUNWIND PROPERTIES + PURPOSE "Needed by glog." + TYPE OPTIONAL + ) if(NOT ${LOCAL_GFLAGS}) if(NOT TARGET gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}) add_library(gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} UNKNOWN IMPORTED) @@ -1776,6 +1781,9 @@ ${CMAKE_BINARY_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure endif() endif() + if(LIBUNWIND_FOUND) + target_link_libraries(Glog::glog INTERFACE Libunwind::libunwind) + endif() set(LOCAL_GLOG TRUE CACHE STRING "Glog downloaded, built, and statically linked automatically" FORCE) set_package_properties(GLOG PROPERTIES diff --git a/cmake/Modules/FindLIBUNWIND.cmake b/cmake/Modules/FindLIBUNWIND.cmake new file mode 100644 index 000000000..610c54f34 --- /dev/null +++ b/cmake/Modules/FindLIBUNWIND.cmake @@ -0,0 +1,138 @@ +# GNSS-SDR is a Global Navigation Satellite System software-defined receiver. +# This file is part of GNSS-SDR. +# +# SPDX-FileCopyrightText: 2022 C. Fernandez-Prades cfernandez(at)cttc.es +# SPDX-License-Identifier: BSD-3-Clause + +# Find the libunwind library +# +# LIBUNWIND_FOUND - True if libunwind was found. +# LIBUNWIND_LIBRARIES - The libraries needed to use libunwind +# LIBUNWIND_INCLUDE_DIR - Location of libunwind.h + +# INPUT (Optional): +# LIBUNWIND_ROOT - path where include + lib of libunwind install is located + +if(NOT COMMAND feature_summary) + include(FeatureSummary) +endif() + +find_path(LIBUNWIND_INCLUDE_DIR + NAMES + libunwind.h + unwind.h + HINTS + /usr + /usr/local + /opt/local + PATH_SUFFIXES include + PATHS "${LIBUNWIND_ROOT}/include" +) + +find_library(LIBUNWIND_GENERIC_LIBRARY + NAMES + libunwind.a + unwind + HINTS + /usr + /usr/local + /opt/local + PATH_SUFFIXES lib lib64 + PATHS + "${LIBUNWIND_ROOT}/lib" + "${LIBUNWIND_ROOT}/lib64" +) + +if(LIBUNWIND_INCLUDE_DIR) + if(LIBUNWIND_GENERIC_LIBRARY) + set(LIBUNWIND_LIBRARIES ${LIBUNWIND_GENERIC_LIBRARY}) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)") + set(LIBUNWIND_ARCH "aarch64") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") + set(LIBUNWIND_ARCH "arm") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(AMD64|amd64)|(corei7-64)") + set(LIBUNWIND_ARCH "x86_64") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") + set(LIBUNWIND_ARCH "x86") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64") + set(LIBUNWIND_ARCH "ppc64") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc") + set(LIBUNWIND_ARCH "ppc32") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips") + set(LIBUNWIND_ARCH "mips") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^hppa") + set(LIBUNWIND_ARCH "hppa") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^ia64") + set(LIBUNWIND_ARCH "ia64") + endif() + if(LIBUNWIND_ARCH) + find_library(LIBUNWIND_SPECIFIC_LIBRARY + NAMES + libunwind-${LIBUNWIND_ARCH}.a + "unwind-${LIBUNWIND_ARCH}" + HINTS + /usr + /usr/local + /opt/local + PATH_SUFFIXES lib lib64 + PATHS "${LIBUNWIND_ROOT}" + ) + if(NOT LIBUNWIND_SPECIFIC_LIBRARY) + message(STATUS " -- Failed to find unwind-${LIBUNWIND_ARCH}") + else() + set(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARIES} ${LIBUNWIND_SPECIFIC_LIBRARY}) + endif() + endif() + endif() +else() + message(STATUS " -- Could NOT find libunwind.h") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LIBUNWIND DEFAULT_MSG LIBUNWIND_INCLUDE_DIR) + +if(LIBUNWIND_FOUND) + set(_Unwind_VERSION_HEADER ${LIBUNWIND_INCLUDE_DIR}/libunwind-common.h) + if(EXISTS ${_Unwind_VERSION_HEADER}) + file(READ ${_Unwind_VERSION_HEADER} _Unwind_VERSION_CONTENTS) + string(REGEX REPLACE ".*#define UNW_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" + LIBUNWIND_VERSION_MAJOR "${_Unwind_VERSION_CONTENTS}") + string(REGEX REPLACE ".*#define UNW_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" + LIBUNWIND_VERSION_MINOR "${_Unwind_VERSION_CONTENTS}") + string(REGEX REPLACE ".*#define UNW_VERSION_EXTRA[ \t]+([0-9]+).*" "\\1" + LIBUNWIND_VERSION_PATCH "${_Unwind_VERSION_CONTENTS}") + set(LIBUNWIND_VERSION ${LIBUNWIND_VERSION_MAJOR}.${LIBUNWIND_VERSION_MINOR}) + if(CMAKE_MATCH_0) + # Third version component may be empty + set(LIBUNWIND_VERSION ${LIBUNWIND_VERSION}.${LIBUNWIND_VERSION_PATCH}) + set(LIBUNWIND_VERSION_COMPONENTS 3) + else() + set(LIBUNWIND_VERSION_COMPONENTS 2) + endif() + endif() +endif() + +if(LIBUNWIND_FOUND AND NOT TARGET Libunwind::libunwind) + add_library(Libunwind::libunwind INTERFACE IMPORTED) + set_target_properties(Libunwind::libunwind PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${LIBUNWIND_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${LIBUNWIND_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${LIBUNWIND_LIBRARIES}" + ) +endif() + +set_package_properties(LIBUNWIND PROPERTIES + URL "https://www.nongnu.org/libunwind/" +) +if(LIBUNWIND_VERSION) + set_package_properties(LIBUNWIND PROPERTIES + DESCRIPTION "Portable and efficient C programming interface to determine the call-chain of a program (found: v${LIBUNWIND_VERSION})" + ) +else() + set_package_properties(LIBUNWIND PROPERTIES + DESCRIPTION "Portable and efficient C programming interface to determine the call-chain of a program" + ) +endif() + +mark_as_advanced(LIBUNWIND_LIBRARIES LIBUNWIND_INCLUDE_DIR) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a5aaa718b..d6ba51fc6 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -56,6 +56,7 @@ All notable changes to GNSS-SDR will be documented in this file. - Fixed running time error if the binary is built with the `-Wp,-D_GLIBCXX_ASSERTIONS` compiler option. This is added by default in some GNU/Linux distributions. +- Fixed linking against libunwind when the glog library is built locally. ### Improvements in Usability: diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/CMakeLists.txt index 2bda43927..acb748a3c 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/CMakeLists.txt @@ -82,6 +82,7 @@ macro(add_cpu_features_headers_and_sources HDRS_LIST_NAME SRCS_LIST_NAME) elseif(PROCESSOR_IS_X86) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_x86.h) list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/internal/cpuid_x86.h) + list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/internal/windows_utils.h) elseif(PROCESSOR_IS_POWER) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_ppc.h) else() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpu_features_macros.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpu_features_macros.h index f587ce3dd..2eb11e264 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpu_features_macros.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpu_features_macros.h @@ -362,6 +362,8 @@ // Communicates to the compiler that the function is now deprecated #if defined(CPU_FEATURES_COMPILER_CLANG) || defined(CPU_FEATURES_COMPILER_GCC) #define CPU_FEATURES_DEPRECATED(message) __attribute__((deprecated(message))) +#elif defined(CPU_FEATURES_COMPILER_MSC) +#define CPU_FEATURES_DEPRECATED(message) __declspec(deprecated(message)) #else #define CPU_FEATURES_DEPRECATED(message) #endif diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/hwcaps.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/hwcaps.h index 43fd860b1..94f5f43e2 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/hwcaps.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/hwcaps.h @@ -164,6 +164,17 @@ CPU_FEATURES_START_CPP_NAMESPACE #define PPC_FEATURE2_HTM_NO_SUSPEND 0x00080000 #endif +// https://elixir.bootlin.com/linux/latest/source/arch/riscv/include/uapi/asm/hwcap.h +#define RISCV_HWCAP_A (1UL << ('A' - 'A')) +#define RISCV_HWCAP_C (1UL << ('C' - 'A')) +#define RISCV_HWCAP_D (1UL << ('D' - 'A')) +#define RISCV_HWCAP_E (1UL << ('E' - 'A')) +#define RISCV_HWCAP_F (1UL << ('F' - 'A')) +#define RISCV_HWCAP_I (1UL << ('I' - 'A')) +#define RISCV_HWCAP_M (1UL << ('M' - 'A')) +#define RISCV_HWCAP_V (1UL << ('V' - 'A')) +#define RISCV_HWCAP_Q (1UL << ('Q' - 'A')) + typedef struct { unsigned long hwcaps; diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/windows_utils.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/windows_utils.h new file mode 100644 index 000000000..246bb20c9 --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/windows_utils.h @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: 2022 Google LLC +// SPDX-License-Identifier: Apache-2.0 +#ifndef CPU_FEATURES_INCLUDE_INTERNAL_WINDOWS_UTILS_H_ +#define CPU_FEATURES_INCLUDE_INTERNAL_WINDOWS_UTILS_H_ + +#include // IsProcessorFeaturePresent + +// modern WinSDK winnt.h contains newer features detection definitions +#if !defined(PF_SSSE3_INSTRUCTIONS_AVAILABLE) +#define PF_SSSE3_INSTRUCTIONS_AVAILABLE 36 +#endif + +#if !defined(PF_SSE4_1_INSTRUCTIONS_AVAILABLE) +#define PF_SSE4_1_INSTRUCTIONS_AVAILABLE 37 +#endif + +#if !defined(PF_SSE4_2_INSTRUCTIONS_AVAILABLE) +#define PF_SSE4_2_INSTRUCTIONS_AVAILABLE 38 +#endif + +#endif // CPU_FEATURES_INCLUDE_INTERNAL_WINDOWS_UTILS_H_ diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_x86_windows.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_x86_windows.c index 66d47c7be..44dfde643 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_x86_windows.c +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_x86_windows.c @@ -14,7 +14,7 @@ static void OverrideOsPreserves(OsPreserves* os_preserves) // No override } -#include // IsProcessorFeaturePresent +#include "internal/windows_utils.h" #if defined(CPU_FEATURES_MOCK_CPUID_X86) extern bool GetWindowsIsProcessorFeaturePresent(DWORD); @@ -35,16 +35,15 @@ static void DetectFeaturesFromOs(X86Info* info, X86Features* features) GetWindowsIsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE); features->sse3 = GetWindowsIsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE); + features->ssse3 = + GetWindowsIsProcessorFeaturePresent(PF_SSSE3_INSTRUCTIONS_AVAILABLE); + features->sse4_1 = + GetWindowsIsProcessorFeaturePresent(PF_SSE4_1_INSTRUCTIONS_AVAILABLE); + features->sse4_2 = + GetWindowsIsProcessorFeaturePresent(PF_SSE4_2_INSTRUCTIONS_AVAILABLE); -// https://github.com/google/cpu_features/issues/200 -#if (_WIN32_WINNT >= 0x0601) // Win7+ - if (GetX86Microarchitecture(info) == INTEL_WSM) - { - features->ssse3 = true; - features->sse4_1 = true; - features->sse4_2 = true; - } -#endif + // do not bother checking PF_AVX* + // cause AVX enabled processor will have XCR0 be exposed and this function will be skipped at all } #endif // CPU_FEATURES_OS_WINDOWS diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/utils/list_cpu_features.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/utils/list_cpu_features.c index 965a8c15f..859ef6954 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/utils/list_cpu_features.c +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/utils/list_cpu_features.c @@ -392,9 +392,8 @@ static Node* CreateTree(void) char brand_string[49]; const X86Info info = GetX86Info(); const CacheInfo cache_info = GetX86CacheInfo(); - FillX86BrandString(brand_string); AddMapEntry(root, "arch", CreateString("x86")); - AddMapEntry(root, "brand", CreateString(brand_string)); + AddMapEntry(root, "brand", CreateString(info.brand_string)); AddMapEntry(root, "family", CreateInt(info.family)); AddMapEntry(root, "model", CreateInt(info.model)); AddMapEntry(root, "stepping", CreateInt(info.stepping)); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_x86_test.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_x86_test.cc index bd978399f..f12b2af2c 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_x86_test.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_x86_test.cc @@ -216,9 +216,8 @@ TEST_F(CpuidX86Test, Branding) {{0x80000003, 0}, Leaf{0x37692029, 0x3035362D, 0x43205530, 0x40205550}}, {{0x80000004, 0}, Leaf{0x352E3220, 0x7A484730, 0x00000000, 0x00000000}}, }); - char brand_string[49]; - FillX86BrandString(brand_string); - EXPECT_STREQ(brand_string, "Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz"); + const auto info = GetX86Info(); + EXPECT_STREQ(info.brand_string, "Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz"); } TEST_F(CpuidX86Test, KabyLakeCache) @@ -436,10 +435,6 @@ TEST_F(CpuidX86Test, AMD_K15_EXCAVATOR_STONEY_RIDGE) "AMD A9-9410 RADEON R5, 5 COMPUTE CORES 2C+3G "); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_EXCAVATOR); - - char brand_string[49]; - FillX86BrandString(brand_string); - EXPECT_STREQ(brand_string, "AMD A9-9410 RADEON R5, 5 COMPUTE CORES 2C+3G "); } // http://users.atw.hu/instlatx64/AuthenticAMD/AuthenticAMD0600F20_K15_AbuDhabi_CPUID0.txt @@ -465,9 +460,7 @@ TEST_F(CpuidX86Test, AMD_K15_PILEDRIVER_ABU_DHABI) EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_PILEDRIVER); - char brand_string[49]; - FillX86BrandString(brand_string); - EXPECT_STREQ(brand_string, "AMD Opteron(tm) Processor 6376 "); + EXPECT_STREQ(info.brand_string, "AMD Opteron(tm) Processor 6376 "); } // http://users.atw.hu/instlatx64/AuthenticAMD/AuthenticAMD0600F20_K15_AbuDhabi_CPUID0.txt @@ -541,10 +534,6 @@ TEST_F(CpuidX86Test, AMD_K15_BULLDOZER_INTERLAGOS) "AMD Opteron(TM) Processor 6238 "); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_BULLDOZER); - - char brand_string[49]; - FillX86BrandString(brand_string); - EXPECT_STREQ(brand_string, "AMD Opteron(TM) Processor 6238 "); } // http://users.atw.hu/instlatx64/AuthenticAMD0630F81_K15_Godavari_CPUID.txt @@ -571,10 +560,6 @@ TEST_F(CpuidX86Test, AMD_K15_STREAMROLLER_GODAVARI) "AMD A8-7670K Radeon R7, 10 Compute Cores 4C+6G "); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_STREAMROLLER); - - char brand_string[49]; - FillX86BrandString(brand_string); - EXPECT_STREQ(brand_string, "AMD A8-7670K Radeon R7, 10 Compute Cores 4C+6G "); } // http://users.atw.hu/instlatx64/AuthenticAMD/AuthenticAMD0700F01_K16_Kabini_CPUID.txt @@ -598,10 +583,6 @@ TEST_F(CpuidX86Test, AMD_K16_JAGUAR_KABINI) EXPECT_STREQ(info.brand_string, "AMD A4-5000 APU with Radeon(TM) HD Graphics "); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_JAGUAR); - - char brand_string[49]; - FillX86BrandString(brand_string); - EXPECT_STREQ(brand_string, "AMD A4-5000 APU with Radeon(TM) HD Graphics "); } // http://users.atw.hu/instlatx64/AuthenticAMD/AuthenticAMD0730F01_K16_Beema_CPUID2.txt @@ -625,10 +606,6 @@ TEST_F(CpuidX86Test, AMD_K16_PUMA_BEEMA) EXPECT_STREQ(info.brand_string, "AMD A6-6310 APU with AMD Radeon R4 Graphics "); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_PUMA); - - char brand_string[49]; - FillX86BrandString(brand_string); - EXPECT_STREQ(brand_string, "AMD A6-6310 APU with AMD Radeon R4 Graphics "); } // http://users.atw.hu/instlatx64/AuthenticAMD/AuthenticAMD0820F01_K17_Dali_CPUID.txt @@ -652,10 +629,6 @@ TEST_F(CpuidX86Test, AMD_K17_ZEN_DALI) EXPECT_STREQ(info.brand_string, "AMD 3020e with Radeon Graphics "); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN); - - char brand_string[49]; - FillX86BrandString(brand_string); - EXPECT_STREQ(brand_string, "AMD 3020e with Radeon Graphics "); } // http://users.atw.hu/instlatx64/AuthenticAMD/AuthenticAMD0800F82_K17_ZenP_CPUID.txt @@ -679,10 +652,6 @@ TEST_F(CpuidX86Test, AMD_K17_ZEN_PLUS_PINNACLE_RIDGE) EXPECT_STREQ(info.brand_string, "AMD Ryzen 7 2700X Eight-Core Processor "); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN_PLUS); - - char brand_string[49]; - FillX86BrandString(brand_string); - EXPECT_STREQ(brand_string, "AMD Ryzen 7 2700X Eight-Core Processor "); } // http://users.atw.hu/instlatx64/AuthenticAMD/AuthenticAMD0840F70_K17_CPUID.txt @@ -705,10 +674,6 @@ TEST_F(CpuidX86Test, AMD_K17_ZEN2_XBOX_SERIES_X) EXPECT_EQ(info.model, 0x47); EXPECT_STREQ(info.brand_string, "AMD 4700S 8-Core Processor Desktop Kit"); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN2); - - char brand_string[49]; - FillX86BrandString(brand_string); - EXPECT_STREQ(brand_string, "AMD 4700S 8-Core Processor Desktop Kit"); } // http://users.atw.hu/instlatx64/HygonGenuine/HygonGenuine0900F02_Hygon_CPUID3.txt @@ -732,10 +697,6 @@ TEST_F(CpuidX86Test, AMD_K18_ZEN_DHYANA) EXPECT_STREQ(info.brand_string, "Hygon C86 3185 8-core Processor "); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN); - - char brand_string[49]; - FillX86BrandString(brand_string); - EXPECT_STREQ(brand_string, "Hygon C86 3185 8-core Processor "); } // http://users.atw.hu/instlatx64/HygonGenuine/HygonGenuine0900F02_Hygon_CPUID.txt @@ -808,10 +769,6 @@ TEST_F(CpuidX86Test, AMD_K19_ZEN3_VERMEER) EXPECT_STREQ(info.brand_string, "AMD Ryzen 9 5900X 12-Core Processor "); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::AMD_ZEN3); - - char brand_string[49]; - FillX86BrandString(brand_string); - EXPECT_STREQ(brand_string, "AMD Ryzen 9 5900X 12-Core Processor "); } // http://users.atw.hu/instlatx64/AuthenticAMD/AuthenticAMD0A40F41_K19_Rembrandt_03_CPUID.txt @@ -867,6 +824,9 @@ TEST_F(CpuidX86Test, Nehalem) cpu().SetWindowsIsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE); cpu().SetWindowsIsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE); cpu().SetWindowsIsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE); + cpu().SetWindowsIsProcessorFeaturePresent(PF_SSSE3_INSTRUCTIONS_AVAILABLE); + cpu().SetWindowsIsProcessorFeaturePresent(PF_SSE4_1_INSTRUCTIONS_AVAILABLE); + cpu().SetWindowsIsProcessorFeaturePresent(PF_SSE4_2_INSTRUCTIONS_AVAILABLE); #elif defined(CPU_FEATURES_OS_MACOS) cpu().SetDarwinSysCtlByName("hw.optional.sse"); cpu().SetDarwinSysCtlByName("hw.optional.sse2"); @@ -927,20 +887,12 @@ flags : fpu mmx sse sse2 pni ssse3 sse4_1 sse4_2 "Genuine Intel(R) CPU @ 0000 @ 1.87GHz"); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::INTEL_NHM); - char brand_string[49]; - FillX86BrandString(brand_string); - EXPECT_STREQ(brand_string, "Genuine Intel(R) CPU @ 0000 @ 1.87GHz"); - EXPECT_TRUE(info.features.sse); EXPECT_TRUE(info.features.sse2); EXPECT_TRUE(info.features.sse3); -#if !defined(CPU_FEATURES_OS_WINDOWS) - // Currently disabled on Windows as IsProcessorFeaturePresent do not support - // feature detection > sse3. EXPECT_TRUE(info.features.ssse3); EXPECT_TRUE(info.features.sse4_1); EXPECT_TRUE(info.features.sse4_2); -#endif // !defined(CPU_FEATURES_OS_WINDOWS) } // https://github.com/InstLatx64/InstLatx64/blob/master/GenuineIntel/GenuineIntel0030673_Silvermont3_CPUID.txt @@ -952,6 +904,9 @@ TEST_F(CpuidX86Test, Atom) cpu().SetWindowsIsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE); cpu().SetWindowsIsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE); cpu().SetWindowsIsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE); + cpu().SetWindowsIsProcessorFeaturePresent(PF_SSSE3_INSTRUCTIONS_AVAILABLE); + cpu().SetWindowsIsProcessorFeaturePresent(PF_SSE4_1_INSTRUCTIONS_AVAILABLE); + cpu().SetWindowsIsProcessorFeaturePresent(PF_SSE4_2_INSTRUCTIONS_AVAILABLE); #elif defined(CPU_FEATURES_OS_MACOS) cpu().SetDarwinSysCtlByName("hw.optional.sse"); cpu().SetDarwinSysCtlByName("hw.optional.sse2"); @@ -1012,20 +967,12 @@ flags : fpu mmx sse sse2 pni ssse3 sse4_1 sse4_2 EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::INTEL_ATOM_SMT); - char brand_string[49]; - FillX86BrandString(brand_string); - EXPECT_STREQ(brand_string, " Intel(R) Celeron(R) CPU J1900 @ 1.99GHz"); - EXPECT_TRUE(info.features.sse); EXPECT_TRUE(info.features.sse2); EXPECT_TRUE(info.features.sse3); -#if !defined(CPU_FEATURES_OS_WINDOWS) - // Currently disabled on Windows as IsProcessorFeaturePresent do not support - // feature detection > sse3. EXPECT_TRUE(info.features.ssse3); EXPECT_TRUE(info.features.sse4_1); EXPECT_TRUE(info.features.sse4_2); -#endif // !defined(CPU_FEATURES_OS_WINDOWS) } // https://www.felixcloutier.com/x86/cpuid#example-3-1--example-of-cache-and-tlb-interpretation @@ -1120,21 +1067,13 @@ flags : fpu mmx sse EXPECT_STREQ(info.brand_string, ""); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::X86_UNKNOWN); - char brand_string[49]; - FillX86BrandString(brand_string); - EXPECT_STREQ(brand_string, ""); - EXPECT_TRUE(info.features.mmx); EXPECT_TRUE(info.features.sse); EXPECT_FALSE(info.features.sse2); EXPECT_FALSE(info.features.sse3); -#if !defined(CPU_FEATURES_OS_WINDOWS) - // Currently disabled on Windows as IsProcessorFeaturePresent do not support - // feature detection > sse3. EXPECT_FALSE(info.features.ssse3); EXPECT_FALSE(info.features.sse4_1); EXPECT_FALSE(info.features.sse4_2); -#endif // !defined(CPU_FEATURES_OS_WINDOWS) } // https://github.com/InstLatx64/InstLatx64/blob/master/GenuineIntel/GenuineIntel0000480_486_CPUID.txt @@ -1199,11 +1138,53 @@ TEST_F(CpuidX86Test, INTEL_KNIGHTS_LANDING) X86Microarchitecture::INTEL_KNIGHTS_L); } +// http://users.atw.hu/instlatx64/GenuineIntel/GenuineIntel00806EC_CometLake_CPUID2.txt +TEST_F(CpuidX86Test, INTEL_CML_U) +{ + cpu().SetLeaves({ + {{0x00000000, 0}, Leaf{0x00000016, 0x756E6547, 0x6C65746E, 0x49656E69}}, + {{0x00000001, 0}, Leaf{0x000806EC, 0x00100800, 0x7FFAFBBF, 0xBFEBFBFF}}, + }); + const auto info = GetX86Info(); + + EXPECT_STREQ(info.vendor, "GenuineIntel"); + EXPECT_EQ(info.family, 0x06); + EXPECT_EQ(info.model, 0x8E); + EXPECT_EQ(info.stepping, 0x0C); + EXPECT_EQ(GetX86Microarchitecture(&info), + X86Microarchitecture::INTEL_CML); +} + +// http://users.atw.hu/instlatx64/GenuineIntel/GenuineIntel00A0652_CometLake_CPUID1.txt +TEST_F(CpuidX86Test, INTEL_CML_H) +{ + cpu().SetLeaves({ + {{0x00000000, 0}, Leaf{0x00000016, 0x756E6547, 0x6C65746E, 0x49656E69}}, + {{0x00000001, 0}, Leaf{0x000A0652, 0x00100800, 0x7FFAFBBF, 0xBFEBFBFF}}, + }); + const auto info = GetX86Info(); + + EXPECT_STREQ(info.vendor, "GenuineIntel"); + EXPECT_EQ(info.family, 0x06); + EXPECT_EQ(info.model, 0xA5); + EXPECT_EQ(GetX86Microarchitecture(&info), + X86Microarchitecture::INTEL_CML); +} + // https://github.com/google/cpu_features/issues/200 // http://users.atw.hu/instlatx64/GenuineIntel/GenuineIntel00206F2_Eagleton_CPUID.txt #if defined(CPU_FEATURES_OS_WINDOWS) TEST_F(CpuidX86Test, WIN_INTEL_WESTMERE_EX) { + // Pre AVX cpus don't have xsave + cpu().SetOsBackupsExtendedRegisters(false); + cpu().SetWindowsIsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE); + cpu().SetWindowsIsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE); + cpu().SetWindowsIsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE); + cpu().SetWindowsIsProcessorFeaturePresent(PF_SSSE3_INSTRUCTIONS_AVAILABLE); + cpu().SetWindowsIsProcessorFeaturePresent(PF_SSE4_1_INSTRUCTIONS_AVAILABLE); + cpu().SetWindowsIsProcessorFeaturePresent(PF_SSE4_2_INSTRUCTIONS_AVAILABLE); + cpu().SetLeaves({ {{0x00000000, 0}, Leaf{0x0000000B, 0x756E6547, 0x6C65746E, 0x49656E69}}, {{0x00000001, 0}, Leaf{0x000206F2, 0x00400800, 0x02BEE3FF, 0xBFEBFBFF}}, @@ -1214,15 +1195,12 @@ TEST_F(CpuidX86Test, WIN_INTEL_WESTMERE_EX) EXPECT_EQ(info.model, 0x2F); EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::INTEL_WSM); -#if (_WIN32_WINNT < 0x0601) // before Win7 - EXPECT_FALSE(info.features.ssse3); - EXPECT_FALSE(info.features.sse4_1); - EXPECT_FALSE(info.features.sse4_2); -#else + EXPECT_TRUE(info.features.sse); + EXPECT_TRUE(info.features.sse2); + EXPECT_TRUE(info.features.sse3); EXPECT_TRUE(info.features.ssse3); EXPECT_TRUE(info.features.sse4_1); EXPECT_TRUE(info.features.sse4_2); -#endif } #endif // CPU_FEATURES_OS_WINDOWS diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index cebfd2305..1ec9e49a6 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -307,12 +307,17 @@ if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA) if(CMAKE_GENERATOR STREQUAL Xcode) set(GNSS_SIM_BUILD_COMMAND "xcodebuild" "-configuration" "${CMAKE_BUILD_TYPE}" "-target" "gnss_sim") endif() + if(TOOLCHAIN_ARG) + set(TOOLCHAIN_ARG_GNSS_SIM "-DCMAKE_NO_SYSTEM_FROM_IMPORTED=ON") + else() + set(TOOLCHAIN_ARG_GNSS_SIM "") + endif() ExternalProject_Add(gnss-sim GIT_REPOSITORY https://bitbucket.org/jarribas/gnss-simulator GIT_TAG ${GNSSSDR_GNSS_SIM_LOCAL_VERSION} SOURCE_DIR ${CMAKE_BINARY_DIR}/thirdparty/gnss-sim BINARY_DIR ${CMAKE_BINARY_DIR}/gnss-sim - CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} ${CROSS_INSTALL_DIR} + CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} ${CROSS_INSTALL_DIR} ${TOOLCHAIN_ARG_GNSS_SIM} BUILD_COMMAND ${GNSS_SIM_BUILD_COMMAND} UPDATE_COMMAND "" PATCH_COMMAND "" diff --git a/src/tests/benchmarks/CMakeLists.txt b/src/tests/benchmarks/CMakeLists.txt index e0078d387..0ac1456c4 100644 --- a/src/tests/benchmarks/CMakeLists.txt +++ b/src/tests/benchmarks/CMakeLists.txt @@ -50,7 +50,6 @@ if(NOT benchmark_FOUND) add_library(benchmark::benchmark STATIC IMPORTED) add_dependencies(benchmark::benchmark google-benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/thirdparty/benchmark/include) - file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/include) set_target_properties(benchmark::benchmark PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" IMPORTED_CONFIGURATIONS "None;Debug;Release;RelWithDebInfo;MinSizeRel" @@ -64,7 +63,7 @@ if(NOT benchmark_FOUND) IMPORTED_LOCATION_RELEASE ${CMAKE_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_RELWITHDEBINFO ${CMAKE_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_MINSIZEREL ${CMAKE_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX} - INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}/thirdparty/benchmark/include;${CMAKE_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/include" + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}/thirdparty/benchmark/include" INTERFACE_LINK_LIBRARIES "${CMAKE_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX};${CMAKE_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark_main${CMAKE_STATIC_LIBRARY_SUFFIX}" ) if((CMAKE_GENERATOR STREQUAL Xcode) OR MSVC)