diff options
author | Ashkan Aliabadi <ashkanaliabadi@fb.com> | 2020-01-21 14:15:03 -0800 |
---|---|---|
committer | Ashkan Aliabadi <ashkanaliabadi@fb.com> | 2020-01-21 16:28:18 -0800 |
commit | 0e6bde92b343c5fbcfe34ecd41abf9515d54b4a7 (patch) | |
tree | c6e450a5ee5a86c335f4e7de7e7eed9db4fac155 | |
parent | 97785054145da55cfef2ddc23babce455bbf90f9 (diff) | |
download | cpuinfo-0e6bde92b343c5fbcfe34ecd41abf9515d54b4a7.tar.gz |
Upstream the cpuinfo updates in XNNPACK/third_party/cpuinfo.patch. Author: The XNNPACK Team.
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | CMakeLists.txt.orig | 819 | ||||
-rw-r--r-- | LICENSE | 1 | ||||
-rw-r--r-- | include/cpuinfo.h | 112 | ||||
-rw-r--r-- | src/api.c | 8 | ||||
-rw-r--r-- | src/arm/api.h | 3 | ||||
-rw-r--r-- | src/arm/cache.c | 255 | ||||
-rw-r--r-- | src/arm/linux/init.c | 2 | ||||
-rw-r--r-- | src/arm/linux/midr.c | 8 | ||||
-rw-r--r-- | src/arm/mach/init.c | 2 | ||||
-rw-r--r-- | src/arm/midr.h | 29 | ||||
-rw-r--r-- | src/arm/uarch.c | 53 | ||||
-rw-r--r-- | src/cache.c | 18 | ||||
-rw-r--r-- | src/cpuinfo/internal-api.h | 3 | ||||
-rw-r--r-- | src/x86/isa.c | 144 | ||||
-rw-r--r-- | src/x86/linux/init.c | 2 | ||||
-rw-r--r-- | src/x86/mach/init.c | 2 | ||||
-rw-r--r-- | src/x86/uarch.c | 44 | ||||
-rw-r--r-- | src/x86/windows/init.c | 2 | ||||
-rw-r--r-- | tools/cache-info.c | 2 | ||||
-rw-r--r-- | tools/cpu-info.c | 50 | ||||
-rw-r--r-- | tools/isa-info.c | 2 |
22 files changed, 1419 insertions, 145 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a71aede..de319ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,7 +121,8 @@ ENDIF() # ---[ cpuinfo library SET(CPUINFO_SRCS src/init.c - src/api.c) + src/api.c + src/cache.c) IF(CPUINFO_SUPPORTED_PLATFORM) IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86(_64)?)$" OR IOS_ARCH MATCHES "^(i386|x86_64)$") diff --git a/CMakeLists.txt.orig b/CMakeLists.txt.orig new file mode 100644 index 0000000..a71aede --- /dev/null +++ b/CMakeLists.txt.orig @@ -0,0 +1,819 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR) + +INCLUDE(GNUInstallDirs) + +# ---[ Project and semantic versioning. +PROJECT(cpuinfo C CXX) + +# ---[ Options. +SET(CPUINFO_LIBRARY_TYPE "default" CACHE STRING "Type of cpuinfo library (shared, static, or default) to build") +SET_PROPERTY(CACHE CPUINFO_LIBRARY_TYPE PROPERTY STRINGS default static shared) +SET(CPUINFO_RUNTIME_TYPE "default" CACHE STRING "Type of runtime library (shared, static, or default) to use") +SET_PROPERTY(CACHE CPUINFO_RUNTIME_TYPE PROPERTY STRINGS default static shared) +SET(CPUINFO_LOG_LEVEL "default" CACHE STRING "Minimum logging level (info with lower severity will be ignored)") +SET_PROPERTY(CACHE CPUINFO_LOG_LEVEL PROPERTY STRINGS default debug info warning error fatal none) +OPTION(CPUINFO_BUILD_TOOLS "Build command-line tools" ON) +OPTION(CPUINFO_BUILD_UNIT_TESTS "Build cpuinfo unit tests" ON) +OPTION(CPUINFO_BUILD_MOCK_TESTS "Build cpuinfo mock tests" ON) +OPTION(CPUINFO_BUILD_BENCHMARKS "Build cpuinfo micro-benchmarks" ON) + +# ---[ CMake options +IF(CPUINFO_BUILD_UNIT_TESTS OR CPUINFO_BUILD_MOCK_TESTS) + ENABLE_TESTING() +ENDIF() + +MACRO(CPUINFO_TARGET_ENABLE_C99 target) + IF(${CMAKE_VERSION} VERSION_LESS "3.1") + IF(NOT MSVC) + TARGET_COMPILE_OPTIONS(${target} PRIVATE -std=c99) + ENDIF() + ELSE() + SET_TARGET_PROPERTIES(${target} PROPERTIES + C_STANDARD 99 + C_EXTENSIONS NO) + ENDIF() +ENDMACRO() + +MACRO(CPUINFO_TARGET_ENABLE_CXX11 target) + IF(${CMAKE_VERSION} VERSION_LESS "3.1") + IF(NOT MSVC) + TARGET_COMPILE_OPTIONS(${target} PRIVATE -std=c++11) + ENDIF() + ELSE() + SET_TARGET_PROPERTIES(${target} PROPERTIES + CXX_STANDARD 11 + CXX_EXTENSIONS NO) + ENDIF() +ENDMACRO() + +MACRO(CPUINFO_TARGET_RUNTIME_LIBRARY target) + IF(MSVC AND NOT CPUINFO_RUNTIME_TYPE STREQUAL "default") + IF(CPUINFO_RUNTIME_TYPE STREQUAL "shared") + TARGET_COMPILE_OPTIONS(${target} PRIVATE + "/MD$<$<CONFIG:Debug>:d>") + ELSEIF(CPUINFO_RUNTIME_TYPE STREQUAL "static") + TARGET_COMPILE_OPTIONS(${target} PRIVATE + "/MT$<$<CONFIG:Debug>:d>") + ENDIF() + ENDIF() +ENDMACRO() + +# ---[ Build flags +SET(CPUINFO_SUPPORTED_PLATFORM TRUE) +IF(NOT CMAKE_SYSTEM_PROCESSOR) + IF(NOT IOS) + MESSAGE(WARNING + "Target processor architecture is not specified. " + "cpuinfo will compile, but cpuinfo_initialize() will always fail.") + SET(CPUINFO_SUPPORTED_PLATFORM FALSE) + ENDIF() +ELSEIF(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86(_64)?|armv[5-8].*|aarch64)$") + MESSAGE(WARNING + "Target processor architecture \"${CMAKE_SYSTEM_PROCESSOR}\" is not supported in cpuinfo. " + "cpuinfo will compile, but cpuinfo_initialize() will always fail.") + SET(CPUINFO_SUPPORTED_PLATFORM FALSE) +ENDIF() + +IF(NOT CMAKE_SYSTEM_NAME) + MESSAGE(WARNING + "Target operating system is not specified. " + "cpuinfo will compile, but cpuinfo_initialize() will always fail.") + SET(CPUINFO_SUPPORTED_PLATFORM FALSE) +ELSEIF(NOT CMAKE_SYSTEM_NAME MATCHES "^(Windows|Darwin|Linux|Android)$") + IF(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14" AND NOT CMAKE_SYSTEM_NAME STREQUAL "iOS") + MESSAGE(WARNING + "Target operating system \"${CMAKE_SYSTEM_NAME}\" is not supported in cpuinfo. " + "cpuinfo will compile, but cpuinfo_initialize() will always fail.") + SET(CPUINFO_SUPPORTED_PLATFORM FALSE) + ENDIF() +ENDIF() + +# ---[ Download deps +SET(CONFU_DEPENDENCIES_SOURCE_DIR ${CMAKE_SOURCE_DIR}/deps + CACHE PATH "Confu-style dependencies source directory") +SET(CONFU_DEPENDENCIES_BINARY_DIR ${CMAKE_BINARY_DIR}/deps + CACHE PATH "Confu-style dependencies binary directory") + +IF(CPUINFO_BUILD_MOCK_TESTS OR CPUINFO_BUILD_UNIT_TESTS) + IF(CPUINFO_SUPPORTED_PLATFORM AND NOT DEFINED GOOGLETEST_SOURCE_DIR) + MESSAGE(STATUS "Downloading Google Test to ${CONFU_DEPENDENCIES_SOURCE_DIR}/googletest (define GOOGLETEST_SOURCE_DIR to avoid it)") + CONFIGURE_FILE(cmake/DownloadGoogleTest.cmake "${CONFU_DEPENDENCIES_BINARY_DIR}/googletest-download/CMakeLists.txt") + EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . + WORKING_DIRECTORY "${CONFU_DEPENDENCIES_BINARY_DIR}/googletest-download") + EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" --build . + WORKING_DIRECTORY "${CONFU_DEPENDENCIES_BINARY_DIR}/googletest-download") + SET(GOOGLETEST_SOURCE_DIR "${CONFU_DEPENDENCIES_SOURCE_DIR}/googletest" CACHE STRING "Google Test source directory") + ENDIF() +ENDIF() + +IF(CPUINFO_BUILD_BENCHMARKS) + IF(CPUINFO_SUPPORTED_PLATFORM AND NOT DEFINED GOOGLEBENCHMARK_SOURCE_DIR) + MESSAGE(STATUS "Downloading Google Benchmark to ${CONFU_DEPENDENCIES_SOURCE_DIR}/googlebenchmark (define GOOGLEBENCHMARK_SOURCE_DIR to avoid it)") + CONFIGURE_FILE(cmake/DownloadGoogleBenchmark.cmake "${CONFU_DEPENDENCIES_BINARY_DIR}/googlebenchmark-download/CMakeLists.txt") + EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . + WORKING_DIRECTORY "${CONFU_DEPENDENCIES_BINARY_DIR}/googlebenchmark-download") + EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" --build . + WORKING_DIRECTORY "${CONFU_DEPENDENCIES_BINARY_DIR}/googlebenchmark-download") + SET(GOOGLEBENCHMARK_SOURCE_DIR "${CONFU_DEPENDENCIES_SOURCE_DIR}/googlebenchmark" CACHE STRING "Google Benchmark source directory") + ENDIF() +ENDIF() + +# ---[ cpuinfo library +SET(CPUINFO_SRCS + src/init.c + src/api.c) + +IF(CPUINFO_SUPPORTED_PLATFORM) + IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86(_64)?)$" OR IOS_ARCH MATCHES "^(i386|x86_64)$") + LIST(APPEND CPUINFO_SRCS + src/x86/init.c + src/x86/info.c + src/x86/vendor.c + src/x86/uarch.c + src/x86/name.c + src/x86/topology.c + src/x86/isa.c + src/x86/cache/init.c + src/x86/cache/descriptor.c + src/x86/cache/deterministic.c) + IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") + LIST(APPEND CPUINFO_SRCS + src/x86/linux/init.c + src/x86/linux/cpuinfo.c) + ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS") + LIST(APPEND CPUINFO_SRCS src/x86/mach/init.c) + ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Windows") + LIST(APPEND CPUINFO_SRCS src/x86/windows/init.c) + ENDIF() + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv[5-8].*|aarch64)$" OR IOS_ARCH MATCHES "^(armv7.*|arm64.*)$") + LIST(APPEND CPUINFO_SRCS + src/arm/uarch.c + src/arm/cache.c) + IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") + LIST(APPEND CPUINFO_SRCS + src/arm/linux/init.c + src/arm/linux/cpuinfo.c + src/arm/linux/clusters.c + src/arm/linux/chipset.c + src/arm/linux/midr.c + src/arm/linux/hwcap.c) + IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^armv[5-8]") + LIST(APPEND CPUINFO_SRCS src/arm/linux/aarch32-isa.c) + IF(CMAKE_SYSTEM_NAME STREQUAL "Android" AND ANDROID_ABI STREQUAL "armeabi") + SET_SOURCE_FILES_PROPERTIES(src/arm/linux/aarch32-isa.c PROPERTIES COMPILE_FLAGS -marm) + ENDIF() + ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + LIST(APPEND CPUINFO_SRCS src/arm/linux/aarch64-isa.c) + ENDIF() + ELSEIF(IOS) + LIST(APPEND CPUINFO_SRCS src/arm/mach/init.c) + ENDIF() + IF(CMAKE_SYSTEM_NAME STREQUAL "Android") + LIST(APPEND CPUINFO_SRCS + src/arm/android/properties.c) + ENDIF() + ENDIF() + + IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") + LIST(APPEND CPUINFO_SRCS + src/linux/smallfile.c + src/linux/multiline.c + src/linux/current.c + src/linux/cpulist.c + src/linux/processors.c) + ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS") + LIST(APPEND CPUINFO_SRCS src/mach/topology.c) + ENDIF() + + IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") + SET(CMAKE_THREAD_PREFER_PTHREAD TRUE) + SET(THREADS_PREFER_PTHREAD_FLAG TRUE) + FIND_PACKAGE(Threads REQUIRED) + ENDIF() +ENDIF() + +IF(CPUINFO_LIBRARY_TYPE STREQUAL "default") + ADD_LIBRARY(cpuinfo ${CPUINFO_SRCS}) +ELSEIF(CPUINFO_LIBRARY_TYPE STREQUAL "shared") + ADD_LIBRARY(cpuinfo SHARED ${CPUINFO_SRCS}) +ELSEIF(CPUINFO_LIBRARY_TYPE STREQUAL "static") + ADD_LIBRARY(cpuinfo STATIC ${CPUINFO_SRCS}) +ELSE() + MESSAGE(FATAL_ERROR "Unsupported library type ${CPUINFO_LIBRARY_TYPE}") +ENDIF() +ADD_LIBRARY(cpuinfo_internals STATIC ${CPUINFO_SRCS}) +CPUINFO_TARGET_ENABLE_C99(cpuinfo) +CPUINFO_TARGET_ENABLE_C99(cpuinfo_internals) +CPUINFO_TARGET_RUNTIME_LIBRARY(cpuinfo) +SET_TARGET_PROPERTIES(cpuinfo PROPERTIES PUBLIC_HEADER include/cpuinfo.h) +TARGET_INCLUDE_DIRECTORIES(cpuinfo BEFORE PUBLIC include) +TARGET_INCLUDE_DIRECTORIES(cpuinfo BEFORE PRIVATE src) +TARGET_INCLUDE_DIRECTORIES(cpuinfo_internals BEFORE PUBLIC include src) +IF(CPUINFO_LOG_LEVEL STREQUAL "default") + # default logging level: error (subject to change) + TARGET_COMPILE_DEFINITIONS(cpuinfo PRIVATE CPUINFO_LOG_LEVEL=2) +ELSEIF(CPUINFO_LOG_LEVEL STREQUAL "debug") + TARGET_COMPILE_DEFINITIONS(cpuinfo PRIVATE CPUINFO_LOG_LEVEL=5) +ELSEIF(CPUINFO_LOG_LEVEL STREQUAL "info") + TARGET_COMPILE_DEFINITIONS(cpuinfo PRIVATE CPUINFO_LOG_LEVEL=4) +ELSEIF(CPUINFO_LOG_LEVEL STREQUAL "warning") + TARGET_COMPILE_DEFINITIONS(cpuinfo PRIVATE CPUINFO_LOG_LEVEL=3) +ELSEIF(CPUINFO_LOG_LEVEL STREQUAL "error") + TARGET_COMPILE_DEFINITIONS(cpuinfo PRIVATE CPUINFO_LOG_LEVEL=2) +ELSEIF(CPUINFO_LOG_LEVEL STREQUAL "fatal") + TARGET_COMPILE_DEFINITIONS(cpuinfo PRIVATE CPUINFO_LOG_LEVEL=1) +ELSEIF(CPUINFO_LOG_LEVEL STREQUAL "none") + TARGET_COMPILE_DEFINITIONS(cpuinfo PRIVATE CPUINFO_LOG_LEVEL=0) +ELSE() + MESSAGE(FATAL_ERROR "Unsupported logging level ${CPUINFO_LOG_LEVEL}") +ENDIF() +TARGET_COMPILE_DEFINITIONS(cpuinfo_internals PRIVATE CPUINFO_LOG_LEVEL=0) + +IF(CPUINFO_SUPPORTED_PLATFORM) + TARGET_COMPILE_DEFINITIONS(cpuinfo INTERFACE CPUINFO_SUPPORTED_PLATFORM=1) + IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") + TARGET_LINK_LIBRARIES(cpuinfo PUBLIC ${CMAKE_THREAD_LIBS_INIT}) + TARGET_LINK_LIBRARIES(cpuinfo_internals PUBLIC ${CMAKE_THREAD_LIBS_INIT}) + TARGET_COMPILE_DEFINITIONS(cpuinfo PRIVATE _GNU_SOURCE=1) + TARGET_COMPILE_DEFINITIONS(cpuinfo_internals PRIVATE _GNU_SOURCE=1) + ENDIF() +ELSE() + TARGET_COMPILE_DEFINITIONS(cpuinfo INTERFACE CPUINFO_SUPPORTED_PLATFORM=0) +ENDIF() + +# ---[ cpuinfo dependencies: clog +IF(NOT DEFINED CLOG_SOURCE_DIR) + SET(CLOG_SOURCE_DIR "${PROJECT_SOURCE_DIR}/deps/clog") +ENDIF() +IF(NOT TARGET clog) + SET(CLOG_BUILD_TESTS OFF CACHE BOOL "") + SET(CLOG_RUNTIME_TYPE "${CPUINFO_RUNTIME_TYPE}" CACHE STRING "") + ADD_SUBDIRECTORY( + "${CLOG_SOURCE_DIR}") + # We build static version of clog but a dynamic library may indirectly depend on it + SET_PROPERTY(TARGET clog PROPERTY POSITION_INDEPENDENT_CODE ON) +ENDIF() +TARGET_LINK_LIBRARIES(cpuinfo PRIVATE clog) +TARGET_LINK_LIBRARIES(cpuinfo_internals PRIVATE clog) + +INSTALL(TARGETS cpuinfo + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +# ---[ cpuinfo micro-benchmarks +IF(CPUINFO_SUPPORTED_PLATFORM AND CPUINFO_BUILD_BENCHMARKS) + # ---[ Build google benchmark + IF(NOT TARGET benchmark) + SET(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "") + ADD_SUBDIRECTORY( + "${GOOGLEBENCHMARK_SOURCE_DIR}" + "${CONFU_DEPENDENCIES_BINARY_DIR}/googlebenchmark") + ENDIF() + + IF(CMAKE_SYSTEM_NAME MATCHES "^(Linux|Android)$") + ADD_EXECUTABLE(get-current-bench bench/get-current.cc) + TARGET_LINK_LIBRARIES(get-current-bench cpuinfo benchmark) + ENDIF() + + ADD_EXECUTABLE(init-bench bench/init.cc) + TARGET_LINK_LIBRARIES(init-bench cpuinfo benchmark) +ENDIF() + +IF(CPUINFO_SUPPORTED_PLATFORM) + IF(CPUINFO_BUILD_MOCK_TESTS OR CPUINFO_BUILD_UNIT_TESTS) + # ---[ Build google test + IF(NOT TARGET gtest) + IF(MSVC AND NOT CPUINFO_RUNTIME_TYPE STREQUAL "static") + SET(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + ENDIF() + ADD_SUBDIRECTORY( + "${GOOGLETEST_SOURCE_DIR}" + "${CONFU_DEPENDENCIES_BINARY_DIR}/googletest") + ENDIF() + ENDIF() +ENDIF() + +# ---[ cpuinfo mock library and mock tests +IF(CPUINFO_SUPPORTED_PLATFORM AND CPUINFO_BUILD_MOCK_TESTS) + SET(CPUINFO_MOCK_SRCS "${CPUINFO_SRCS}") + IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86_64)$") + LIST(APPEND CPUINFO_MOCK_SRCS src/x86/mockcpuid.c) + ENDIF() + IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") + LIST(APPEND CPUINFO_MOCK_SRCS src/linux/mockfile.c) + ENDIF() + + ADD_LIBRARY(cpuinfo_mock STATIC ${CPUINFO_MOCK_SRCS}) + CPUINFO_TARGET_ENABLE_C99(cpuinfo_mock) + CPUINFO_TARGET_RUNTIME_LIBRARY(cpuinfo_mock) + SET_TARGET_PROPERTIES(cpuinfo_mock PROPERTIES PUBLIC_HEADER include/cpuinfo.h) + TARGET_INCLUDE_DIRECTORIES(cpuinfo_mock BEFORE PUBLIC include) + TARGET_INCLUDE_DIRECTORIES(cpuinfo_mock BEFORE PRIVATE src) + TARGET_COMPILE_DEFINITIONS(cpuinfo_mock PUBLIC CPUINFO_MOCK=1) + TARGET_COMPILE_DEFINITIONS(cpuinfo_mock PRIVATE CLOG_LOG_TO_STDIO=1) + IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") + TARGET_LINK_LIBRARIES(cpuinfo_mock PUBLIC ${CMAKE_THREAD_LIBS_INIT}) + TARGET_COMPILE_DEFINITIONS(cpuinfo_mock PRIVATE _GNU_SOURCE=1) + ENDIF() + TARGET_LINK_LIBRARIES(cpuinfo_mock PRIVATE clog) + + IF(CMAKE_SYSTEM_NAME STREQUAL "Android" AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv5te|armv7-a)$") + ADD_EXECUTABLE(atm7029b-tablet-test test/mock/atm7029b-tablet.cc) + TARGET_INCLUDE_DIRECTORIES(atm7029b-tablet-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(atm7029b-tablet-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(atm7029b-tablet-test atm7029b-tablet-test) + + ADD_EXECUTABLE(blu-r1-hd-test test/mock/blu-r1-hd.cc) + TARGET_INCLUDE_DIRECTORIES(blu-r1-hd-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(blu-r1-hd-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(blu-r1-hd-test blu-r1-hd-test) + + ADD_EXECUTABLE(galaxy-a3-2016-eu-test test/mock/galaxy-a3-2016-eu.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-a3-2016-eu-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-a3-2016-eu-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-a3-2016-eu-test galaxy-a3-2016-eu-test) + + ADD_EXECUTABLE(galaxy-a8-2016-duos-test test/mock/galaxy-a8-2016-duos.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-a8-2016-duos-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-a8-2016-duos-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-a8-2016-duos-test galaxy-a8-2016-duos-test) + + ADD_EXECUTABLE(galaxy-grand-prime-value-edition-test test/mock/galaxy-grand-prime-value-edition.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-grand-prime-value-edition-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-grand-prime-value-edition-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-grand-prime-value-edition-test galaxy-grand-prime-value-edition-test) + + ADD_EXECUTABLE(galaxy-j1-2016-test test/mock/galaxy-j1-2016.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-j1-2016-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-j1-2016-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-j1-2016-test galaxy-j1-2016-test) + + ADD_EXECUTABLE(galaxy-j5-test test/mock/galaxy-j5.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-j5-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-j5-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-j5-test galaxy-j5-test) + + ADD_EXECUTABLE(galaxy-j7-prime-test test/mock/galaxy-j7-prime.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-j7-prime-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-j7-prime-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-j7-prime-test galaxy-j7-prime-test) + + ADD_EXECUTABLE(galaxy-j7-tmobile-test test/mock/galaxy-j7-tmobile.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-j7-tmobile-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-j7-tmobile-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-j7-tmobile-test galaxy-j7-tmobile-test) + + ADD_EXECUTABLE(galaxy-j7-uae-test test/mock/galaxy-j7-uae.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-j7-uae-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-j7-uae-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-j7-uae-test galaxy-j7-uae-test) + + ADD_EXECUTABLE(galaxy-s3-us-test test/mock/galaxy-s3-us.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-s3-us-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-s3-us-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-s3-us-test galaxy-s3-us-test) + + ADD_EXECUTABLE(galaxy-s4-us-test test/mock/galaxy-s4-us.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-s4-us-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-s4-us-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-s4-us-test galaxy-s4-us-test) + + ADD_EXECUTABLE(galaxy-s5-global-test test/mock/galaxy-s5-global.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-s5-global-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-s5-global-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-s5-global-test galaxy-s5-global-test) + + ADD_EXECUTABLE(galaxy-s5-us-test test/mock/galaxy-s5-us.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-s5-us-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-s5-us-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-s5-us-test galaxy-s5-us-test) + + ADD_EXECUTABLE(galaxy-tab-3-7.0-test test/mock/galaxy-tab-3-7.0.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-tab-3-7.0-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-tab-3-7.0-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-tab-3-7.0-test galaxy-tab-3-7.0-test) + + ADD_EXECUTABLE(galaxy-tab-3-lite-test test/mock/galaxy-tab-3-lite.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-tab-3-lite-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-tab-3-lite-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-tab-3-lite-test galaxy-tab-3-lite-test) + + ADD_EXECUTABLE(galaxy-win-duos-test test/mock/galaxy-win-duos.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-win-duos-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-win-duos-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-win-duos-test galaxy-win-duos-test) + + ADD_EXECUTABLE(huawei-ascend-p7-test test/mock/huawei-ascend-p7.cc) + TARGET_INCLUDE_DIRECTORIES(huawei-ascend-p7-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(huawei-ascend-p7-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(huawei-ascend-p7-test huawei-ascend-p7-test) + + ADD_EXECUTABLE(huawei-honor-6-test test/mock/huawei-honor-6.cc) + TARGET_INCLUDE_DIRECTORIES(huawei-honor-6-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(huawei-honor-6-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(huawei-honor-6-test huawei-honor-6-test) + + ADD_EXECUTABLE(lenovo-a6600-plus-test test/mock/lenovo-a6600-plus.cc) + TARGET_INCLUDE_DIRECTORIES(lenovo-a6600-plus-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(lenovo-a6600-plus-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(lenovo-a6600-plus-test lenovo-a6600-plus-test) + + ADD_EXECUTABLE(lenovo-vibe-x2-test test/mock/lenovo-vibe-x2.cc) + TARGET_INCLUDE_DIRECTORIES(lenovo-vibe-x2-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(lenovo-vibe-x2-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(lenovo-vibe-x2-test lenovo-vibe-x2-test) + + ADD_EXECUTABLE(lg-k10-eu-test test/mock/lg-k10-eu.cc) + TARGET_INCLUDE_DIRECTORIES(lg-k10-eu-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(lg-k10-eu-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(lg-k10-eu-test lg-k10-eu-test) + + ADD_EXECUTABLE(lg-optimus-g-pro-test test/mock/lg-optimus-g-pro.cc) + TARGET_INCLUDE_DIRECTORIES(lg-optimus-g-pro-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(lg-optimus-g-pro-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(lg-optimus-g-pro-test lg-optimus-g-pro-test) + + ADD_EXECUTABLE(moto-e-gen1-test test/mock/moto-e-gen1.cc) + TARGET_INCLUDE_DIRECTORIES(moto-e-gen1-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(moto-e-gen1-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(moto-e-gen1-test moto-e-gen1-test) + + ADD_EXECUTABLE(moto-g-gen1-test test/mock/moto-g-gen1.cc) + TARGET_INCLUDE_DIRECTORIES(moto-g-gen1-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(moto-g-gen1-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(moto-g-gen1-test moto-g-gen1-test) + + ADD_EXECUTABLE(moto-g-gen2-test test/mock/moto-g-gen2.cc) + TARGET_INCLUDE_DIRECTORIES(moto-g-gen2-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(moto-g-gen2-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(moto-g-gen2-test moto-g-gen2-test) + + ADD_EXECUTABLE(moto-g-gen3-test test/mock/moto-g-gen3.cc) + TARGET_INCLUDE_DIRECTORIES(moto-g-gen3-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(moto-g-gen3-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(moto-g-gen3-test moto-g-gen3-test) + + ADD_EXECUTABLE(moto-g-gen4-test test/mock/moto-g-gen4.cc) + TARGET_INCLUDE_DIRECTORIES(moto-g-gen4-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(moto-g-gen4-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(moto-g-gen4-test moto-g-gen4-test) + + ADD_EXECUTABLE(moto-g-gen5-test test/mock/moto-g-gen5.cc) + TARGET_INCLUDE_DIRECTORIES(moto-g-gen5-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(moto-g-gen5-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(moto-g-gen5-test moto-g-gen5-test) + + ADD_EXECUTABLE(nexus-s-test test/mock/nexus-s.cc) + TARGET_INCLUDE_DIRECTORIES(nexus-s-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(nexus-s-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(nexus-s-test nexus-s-test) + + ADD_EXECUTABLE(nexus4-test test/mock/nexus4.cc) + TARGET_INCLUDE_DIRECTORIES(nexus4-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(nexus4-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(nexus4-test nexus4-test) + + ADD_EXECUTABLE(nexus6-test test/mock/nexus6.cc) + TARGET_INCLUDE_DIRECTORIES(nexus6-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(nexus6-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(nexus6-test nexus6-test) + + ADD_EXECUTABLE(nexus10-test test/mock/nexus10.cc) + TARGET_INCLUDE_DIRECTORIES(nexus10-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(nexus10-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(nexus10-test nexus10-test) + + ADD_EXECUTABLE(padcod-10.1-test test/mock/padcod-10.1.cc) + TARGET_INCLUDE_DIRECTORIES(padcod-10.1-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(padcod-10.1-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(padcod-10.1-test padcod-10.1-test) + + ADD_EXECUTABLE(xiaomi-redmi-2a-test test/mock/xiaomi-redmi-2a.cc) + TARGET_INCLUDE_DIRECTORIES(xiaomi-redmi-2a-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(xiaomi-redmi-2a-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(xiaomi-redmi-2a-test xiaomi-redmi-2a-test) + + ADD_EXECUTABLE(xperia-sl-test test/mock/xperia-sl.cc) + TARGET_INCLUDE_DIRECTORIES(xperia-sl-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(xperia-sl-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(xperia-sl-test xperia-sl-test) + ENDIF() + + IF(CMAKE_SYSTEM_NAME STREQUAL "Android" AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv5te|armv7-a|aarch64)$") + ADD_EXECUTABLE(alcatel-revvl-test test/mock/alcatel-revvl.cc) + TARGET_INCLUDE_DIRECTORIES(alcatel-revvl-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(alcatel-revvl-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(alcatel-revvl-test alcatel-revvl-test) + + ADD_EXECUTABLE(galaxy-a8-2018-test test/mock/galaxy-a8-2018.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-a8-2018-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-a8-2018-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-a8-2018-test galaxy-a8-2018-test) + + ADD_EXECUTABLE(galaxy-c9-pro-test test/mock/galaxy-c9-pro.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-c9-pro-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-c9-pro-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-c9-pro-test galaxy-c9-pro-test) + + ADD_EXECUTABLE(galaxy-s6-test test/mock/galaxy-s6.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-s6-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-s6-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-s6-test galaxy-s6-test) + + ADD_EXECUTABLE(galaxy-s7-us-test test/mock/galaxy-s7-us.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-s7-us-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-s7-us-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-s7-us-test galaxy-s7-us-test) + + ADD_EXECUTABLE(galaxy-s7-global-test test/mock/galaxy-s7-global.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-s7-global-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-s7-global-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-s7-global-test galaxy-s7-global-test) + + ADD_EXECUTABLE(galaxy-s8-us-test test/mock/galaxy-s8-us.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-s8-us-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-s8-us-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-s8-us-test galaxy-s8-us-test) + + ADD_EXECUTABLE(galaxy-s8-global-test test/mock/galaxy-s8-global.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-s8-global-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-s8-global-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-s8-global-test galaxy-s8-global-test) + + ADD_EXECUTABLE(galaxy-s9-us-test test/mock/galaxy-s9-us.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-s9-us-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-s9-us-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-s9-us-test galaxy-s9-us-test) + + ADD_EXECUTABLE(galaxy-s9-global-test test/mock/galaxy-s9-global.cc) + TARGET_INCLUDE_DIRECTORIES(galaxy-s9-global-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(galaxy-s9-global-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(galaxy-s9-global-test galaxy-s9-global-test) + + ADD_EXECUTABLE(huawei-mate-8-test test/mock/huawei-mate-8.cc) + TARGET_INCLUDE_DIRECTORIES(huawei-mate-8-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(huawei-mate-8-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(huawei-mate-8-test huawei-mate-8-test) + + ADD_EXECUTABLE(huawei-mate-9-test test/mock/huawei-mate-9.cc) + TARGET_INCLUDE_DIRECTORIES(huawei-mate-9-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(huawei-mate-9-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(huawei-mate-9-test huawei-mate-9-test) + + ADD_EXECUTABLE(huawei-mate-10-test test/mock/huawei-mate-10.cc) + TARGET_INCLUDE_DIRECTORIES(huawei-mate-10-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(huawei-mate-10-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(huawei-mate-10-test huawei-mate-10-test) + + ADD_EXECUTABLE(huawei-mate-20-test test/mock/huawei-mate-20.cc) + TARGET_INCLUDE_DIRECTORIES(huawei-mate-20-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(huawei-mate-20-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(huawei-mate-20-test huawei-mate-20-test) + + ADD_EXECUTABLE(huawei-p8-lite-test test/mock/huawei-p8-lite.cc) + TARGET_INCLUDE_DIRECTORIES(huawei-p8-lite-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(huawei-p8-lite-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(huawei-p8-lite-test huawei-p8-lite-test) + + ADD_EXECUTABLE(huawei-p9-lite-test test/mock/huawei-p9-lite.cc) + TARGET_INCLUDE_DIRECTORIES(huawei-p9-lite-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(huawei-p9-lite-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(huawei-p9-lite-test huawei-p9-lite-test) + + ADD_EXECUTABLE(huawei-p20-pro-test test/mock/huawei-p20-pro.cc) + TARGET_INCLUDE_DIRECTORIES(huawei-p20-pro-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(huawei-p20-pro-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(huawei-p20-pro-test huawei-p20-pro-test) + + ADD_EXECUTABLE(iconia-one-10-test test/mock/iconia-one-10.cc) + TARGET_INCLUDE_DIRECTORIES(iconia-one-10-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(iconia-one-10-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(iconia-one-10-test iconia-one-10-test) + + ADD_EXECUTABLE(meizu-pro-6-test test/mock/meizu-pro-6.cc) + TARGET_INCLUDE_DIRECTORIES(meizu-pro-6-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(meizu-pro-6-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(meizu-pro-6-test meizu-pro-6-test) + + ADD_EXECUTABLE(meizu-pro-6s-test test/mock/meizu-pro-6s.cc) + TARGET_INCLUDE_DIRECTORIES(meizu-pro-6s-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(meizu-pro-6s-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(meizu-pro-6s-test meizu-pro-6s-test) + + ADD_EXECUTABLE(meizu-pro-7-plus-test test/mock/meizu-pro-7-plus.cc) + TARGET_INCLUDE_DIRECTORIES(meizu-pro-7-plus-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(meizu-pro-7-plus-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(meizu-pro-7-plus-test meizu-pro-7-plus-test) + + ADD_EXECUTABLE(nexus5x-test test/mock/nexus5x.cc) + TARGET_INCLUDE_DIRECTORIES(nexus5x-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(nexus5x-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(nexus5x-test nexus5x-test) + + ADD_EXECUTABLE(nexus6p-test test/mock/nexus6p.cc) + TARGET_INCLUDE_DIRECTORIES(nexus6p-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(nexus6p-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(nexus6p-test nexus6p-test) + + ADD_EXECUTABLE(nexus9-test test/mock/nexus9.cc) + TARGET_INCLUDE_DIRECTORIES(nexus9-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(nexus9-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(nexus9-test nexus9-test) + + ADD_EXECUTABLE(oneplus-3t-test test/mock/oneplus-3t.cc) + TARGET_INCLUDE_DIRECTORIES(oneplus-3t-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(oneplus-3t-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(oneplus-3t-test oneplus-3t-test) + + ADD_EXECUTABLE(oneplus-5-test test/mock/oneplus-5.cc) + TARGET_INCLUDE_DIRECTORIES(oneplus-5-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(oneplus-5-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(oneplus-5-test oneplus-5-test) + + ADD_EXECUTABLE(oneplus-5t-test test/mock/oneplus-5t.cc) + TARGET_INCLUDE_DIRECTORIES(oneplus-5t-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(oneplus-5t-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(oneplus-5t-test oneplus-5t-test) + + ADD_EXECUTABLE(oppo-a37-test test/mock/oppo-a37.cc) + TARGET_INCLUDE_DIRECTORIES(oppo-a37-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(oppo-a37-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(oppo-a37-test oppo-a37-test) + + ADD_EXECUTABLE(oppo-r9-test test/mock/oppo-r9.cc) + TARGET_INCLUDE_DIRECTORIES(oppo-r9-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(oppo-r9-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(oppo-r9-test oppo-r9-test) + + ADD_EXECUTABLE(oppo-r15-test test/mock/oppo-r15.cc) + TARGET_INCLUDE_DIRECTORIES(oppo-r15-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(oppo-r15-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(oppo-r15-test oppo-r15-test) + + ADD_EXECUTABLE(pixel-test test/mock/pixel.cc) + TARGET_INCLUDE_DIRECTORIES(pixel-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(pixel-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(pixel-test pixel-test) + + ADD_EXECUTABLE(pixel-c-test test/mock/pixel-c.cc) + TARGET_INCLUDE_DIRECTORIES(pixel-c-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(pixel-c-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(pixel-c-test pixel-c-test) + + ADD_EXECUTABLE(pixel-xl-test test/mock/pixel-xl.cc) + TARGET_INCLUDE_DIRECTORIES(pixel-xl-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(pixel-xl-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(pixel-xl-test pixel-xl-test) + + ADD_EXECUTABLE(pixel-2-xl-test test/mock/pixel-2-xl.cc) + TARGET_INCLUDE_DIRECTORIES(pixel-2-xl-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(pixel-2-xl-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(pixel-2-xl-test pixel-2-xl-test) + + ADD_EXECUTABLE(xiaomi-mi-5c-test test/mock/xiaomi-mi-5c.cc) + TARGET_INCLUDE_DIRECTORIES(xiaomi-mi-5c-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(xiaomi-mi-5c-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(xiaomi-mi-5c-test xiaomi-mi-5c-test) + + ADD_EXECUTABLE(xiaomi-redmi-note-3-test test/mock/xiaomi-redmi-note-3.cc) + TARGET_INCLUDE_DIRECTORIES(xiaomi-redmi-note-3-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(xiaomi-redmi-note-3-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(xiaomi-redmi-note-3-test xiaomi-redmi-note-3-test) + + ADD_EXECUTABLE(xiaomi-redmi-note-4-test test/mock/xiaomi-redmi-note-4.cc) + TARGET_INCLUDE_DIRECTORIES(xiaomi-redmi-note-4-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(xiaomi-redmi-note-4-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(xiaomi-redmi-note-4-test xiaomi-redmi-note-4-test) + + ADD_EXECUTABLE(xperia-c4-dual-test test/mock/xperia-c4-dual.cc) + TARGET_INCLUDE_DIRECTORIES(xperia-c4-dual-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(xperia-c4-dual-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(xperia-c4-dual-test xperia-c4-dual-test) + ENDIF() + + IF(CMAKE_SYSTEM_NAME STREQUAL "Android" AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(i686|x86_64)$") + ADD_EXECUTABLE(alldocube-iwork8-test test/mock/alldocube-iwork8.cc) + TARGET_INCLUDE_DIRECTORIES(alldocube-iwork8-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(alldocube-iwork8-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(alldocube-iwork8-test alldocube-iwork8-test) + + ADD_EXECUTABLE(leagoo-t5c-test test/mock/leagoo-t5c.cc) + TARGET_INCLUDE_DIRECTORIES(leagoo-t5c-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(leagoo-t5c-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(leagoo-t5c-test leagoo-t5c-test) + + ADD_EXECUTABLE(memo-pad-7-test test/mock/memo-pad-7.cc) + TARGET_INCLUDE_DIRECTORIES(memo-pad-7-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(memo-pad-7-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(memo-pad-7-test memo-pad-7-test) + + ADD_EXECUTABLE(zenfone-c-test test/mock/zenfone-c.cc) + TARGET_INCLUDE_DIRECTORIES(zenfone-c-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(zenfone-c-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(zenfone-c-test zenfone-c-test) + + ADD_EXECUTABLE(zenfone-2-test test/mock/zenfone-2.cc) + TARGET_INCLUDE_DIRECTORIES(zenfone-2-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(zenfone-2-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(zenfone-2-test zenfone-2-test) + + ADD_EXECUTABLE(zenfone-2e-test test/mock/zenfone-2e.cc) + TARGET_INCLUDE_DIRECTORIES(zenfone-2e-test BEFORE PRIVATE test/mock) + TARGET_LINK_LIBRARIES(zenfone-2e-test PRIVATE cpuinfo_mock gtest) + ADD_TEST(zenfone-2e-test zenfone-2e-test) + ENDIF() +ENDIF() + +# ---[ cpuinfo unit tests +IF(CPUINFO_SUPPORTED_PLATFORM AND CPUINFO_BUILD_UNIT_TESTS) + ADD_EXECUTABLE(init-test test/init.cc) + CPUINFO_TARGET_ENABLE_CXX11(init-test) + CPUINFO_TARGET_RUNTIME_LIBRARY(init-test) + TARGET_LINK_LIBRARIES(init-test PRIVATE cpuinfo gtest gtest_main) + ADD_TEST(init-test init-test) + + IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") + ADD_EXECUTABLE(get-current-test test/get-current.cc) + CPUINFO_TARGET_ENABLE_CXX11(get-current-test) + CPUINFO_TARGET_RUNTIME_LIBRARY(get-current-test) + TARGET_LINK_LIBRARIES(get-current-test PRIVATE cpuinfo gtest gtest_main) + ADD_TEST(get-current-test get-current-test) + ENDIF() + + IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86_64)$") + ADD_EXECUTABLE(brand-string-test test/name/brand-string.cc) + CPUINFO_TARGET_ENABLE_CXX11(brand-string-test) + CPUINFO_TARGET_RUNTIME_LIBRARY(brand-string-test) + TARGET_LINK_LIBRARIES(brand-string-test PRIVATE cpuinfo_internals gtest gtest_main) + ADD_TEST(brand-string-test brand-string-test) + ENDIF() + + IF(CMAKE_SYSTEM_NAME STREQUAL "Android" AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv[5-8].*|aarch64)$") + ADD_LIBRARY(android_properties_interface STATIC test/name/android-properties-interface.c) + CPUINFO_TARGET_ENABLE_C99(android_properties_interface) + CPUINFO_TARGET_RUNTIME_LIBRARY(android_properties_interface) + TARGET_LINK_LIBRARIES(android_properties_interface PRIVATE cpuinfo_internals) + + ADD_EXECUTABLE(chipset-test + test/name/proc-cpuinfo-hardware.cc + test/name/ro-product-board.cc + test/name/ro-board-platform.cc + test/name/ro-mediatek-platform.cc + test/name/ro-arch.cc + test/name/ro-chipname.cc + test/name/android-properties.cc) + CPUINFO_TARGET_ENABLE_CXX11(chipset-test) + CPUINFO_TARGET_RUNTIME_LIBRARY(chipset-test) + TARGET_LINK_LIBRARIES(chipset-test PRIVATE android_properties_interface gtest gtest_main) + ADD_TEST(chipset-test chipset-test) + + ADD_EXECUTABLE(cache-test test/arm-cache.cc) + CPUINFO_TARGET_ENABLE_CXX11(cache-test) + CPUINFO_TARGET_RUNTIME_LIBRARY(cache-test) + TARGET_COMPILE_DEFINITIONS(cache-test PRIVATE __STDC_LIMIT_MACROS=1 __STDC_CONSTANT_MACROS=1) + TARGET_LINK_LIBRARIES(cache-test PRIVATE cpuinfo_internals gtest gtest_main) + ADD_TEST(cache-test, cache-test) + ENDIF() +ENDIF() + +# ---[ Helper and debug tools +IF(CPUINFO_SUPPORTED_PLATFORM AND CPUINFO_BUILD_TOOLS) + ADD_EXECUTABLE(isa-info tools/isa-info.c) + CPUINFO_TARGET_ENABLE_C99(isa-info) + CPUINFO_TARGET_RUNTIME_LIBRARY(isa-info) + TARGET_LINK_LIBRARIES(isa-info PRIVATE cpuinfo) + INSTALL(TARGETS isa-info RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + ADD_EXECUTABLE(cpu-info tools/cpu-info.c) + CPUINFO_TARGET_ENABLE_C99(cpu-info) + CPUINFO_TARGET_RUNTIME_LIBRARY(cpu-info) + TARGET_LINK_LIBRARIES(cpu-info PRIVATE cpuinfo) + INSTALL(TARGETS cpu-info RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + ADD_EXECUTABLE(cache-info tools/cache-info.c) + CPUINFO_TARGET_ENABLE_C99(cache-info) + CPUINFO_TARGET_RUNTIME_LIBRARY(cache-info) + TARGET_LINK_LIBRARIES(cache-info PRIVATE cpuinfo) + INSTALL(TARGETS cache-info RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + IF(CMAKE_SYSTEM_NAME MATCHES "^(Android|Linux)$" AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv[5-8].*|aarch64)$") + ADD_EXECUTABLE(auxv-dump tools/auxv-dump.c) + CPUINFO_TARGET_ENABLE_C99(auxv-dump) + CPUINFO_TARGET_RUNTIME_LIBRARY(auxv-dump) + TARGET_LINK_LIBRARIES(auxv-dump PRIVATE ${CMAKE_DL_LIBS} cpuinfo) + + ADD_EXECUTABLE(cpuinfo-dump tools/cpuinfo-dump.c) + CPUINFO_TARGET_ENABLE_C99(cpuinfo-dump) + CPUINFO_TARGET_RUNTIME_LIBRARY(cpuinfo-dump) + ENDIF() + + IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86_64)$") + ADD_EXECUTABLE(cpuid-dump tools/cpuid-dump.c) + CPUINFO_TARGET_ENABLE_C99(cpuid-dump) + CPUINFO_TARGET_RUNTIME_LIBRARY(cpuid-dump) + TARGET_INCLUDE_DIRECTORIES(cpuid-dump BEFORE PRIVATE src) + TARGET_INCLUDE_DIRECTORIES(cpuid-dump BEFORE PRIVATE include) + INSTALL(TARGETS cpuid-dump RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + ENDIF() +ENDIF() @@ -1,3 +1,4 @@ +Copyright (c) 2019 Google LLC Copyright (c) 2017-2018 Facebook Inc. Copyright (C) 2012-2017 Georgia Institute of Technology Copyright (C) 2010-2012 Marat Dukhan diff --git a/include/cpuinfo.h b/include/cpuinfo.h index 7d5833f..9938d2b 100644 --- a/include/cpuinfo.h +++ b/include/cpuinfo.h @@ -38,10 +38,18 @@ #define CPUINFO_ARCH_PNACL 1 #endif -#if defined(EMSCRIPTEN) +#if defined(__asmjs__) #define CPUINFO_ARCH_ASMJS 1 #endif +#if defined(__wasm__) + #if defined(__wasm_simd128__) + #define CPUINFO_ARCH_WASMSIMD 1 + #else + #define CPUINFO_ARCH_WASM 1 + #endif +#endif + #if CPUINFO_ARCH_X86 && defined(_MSC_VER) #define CPUINFO_ABI __cdecl #elif CPUINFO_ARCH_X86 && defined(__GNUC__) @@ -80,6 +88,14 @@ #define CPUINFO_ARCH_ASMJS 0 #endif +#ifndef CPUINFO_ARCH_WASM + #define CPUINFO_ARCH_WASM 0 +#endif + +#ifndef CPUINFO_ARCH_WASMSIMD + #define CPUINFO_ARCH_WASMSIMD 0 +#endif + #define CPUINFO_CACHE_UNIFIED 0x00000001 #define CPUINFO_CACHE_INCLUSIVE 0x00000002 #define CPUINFO_CACHE_COMPLEX_INDEXING 0x00000004 @@ -278,10 +294,14 @@ enum cpuinfo_uarch { cpuinfo_uarch_haswell = 0x00100208, /** Intel Broadwell microarchitecture. */ cpuinfo_uarch_broadwell = 0x00100209, - /** Intel Sky Lake microarchitecture. */ + /** Intel Sky Lake microarchitecture (14 nm, including Kaby/Coffee/Whiskey/Amber/Comet/Cascade/Cooper Lake). */ cpuinfo_uarch_sky_lake = 0x0010020A, - /** Intel Kaby Lake microarchitecture. */ - cpuinfo_uarch_kaby_lake = 0x0010020B, + /** DEPRECATED (Intel Kaby Lake microarchitecture). */ + cpuinfo_uarch_kaby_lake = 0x0010020A, + /** Intel Palm Cove microarchitecture (10 nm, Cannon Lake). */ + cpuinfo_uarch_palm_cove = 0x0010020B, + /** Intel Sunny Cove microarchitecture (10 nm, Ice Lake). */ + cpuinfo_uarch_sunny_cove = 0x0010020C, /** Pentium 4 with Willamette, Northwood, or Foster cores. */ cpuinfo_uarch_willamette = 0x00100300, @@ -289,13 +309,17 @@ enum cpuinfo_uarch { cpuinfo_uarch_prescott = 0x00100301, /** Intel Atom on 45 nm process. */ - cpuinfo_uarch_bonnell = 0x00100400, + cpuinfo_uarch_bonnell = 0x00100400, /** Intel Atom on 32 nm process. */ - cpuinfo_uarch_saltwell = 0x00100401, + cpuinfo_uarch_saltwell = 0x00100401, /** Intel Silvermont microarchitecture (22 nm out-of-order Atom). */ - cpuinfo_uarch_silvermont = 0x00100402, + cpuinfo_uarch_silvermont = 0x00100402, /** Intel Airmont microarchitecture (14 nm out-of-order Atom). */ - cpuinfo_uarch_airmont = 0x00100403, + cpuinfo_uarch_airmont = 0x00100403, + /** Intel Goldmont microarchitecture (Denverton, Apollo Lake). */ + cpuinfo_uarch_goldmont = 0x00100404, + /** Intel Goldmont Plus microarchitecture (Gemini Lake). */ + cpuinfo_uarch_goldmont_plus = 0x00100405, /** Intel Knights Ferry HPC boards. */ cpuinfo_uarch_knights_ferry = 0x00100500, @@ -335,8 +359,10 @@ enum cpuinfo_uarch { cpuinfo_uarch_steamroller = 0x00200107, /** AMD Excavator microarchitecture (Carizzo APUs). */ cpuinfo_uarch_excavator = 0x00200108, - /** AMD Zen microarchitecture (Ryzen CPUs). */ + /** AMD Zen microarchitecture (12/14 nm Ryzen and EPYC CPUs). */ cpuinfo_uarch_zen = 0x00200109, + /** AMD Zen 2 microarchitecture (7 nm Ryzen and EPYC CPUs). */ + cpuinfo_uarch_zen2 = 0x0020010A, /** NSC Geode and AMD Geode GX and LX. */ cpuinfo_uarch_geode = 0x00200200, @@ -370,23 +396,34 @@ enum cpuinfo_uarch { cpuinfo_uarch_cortex_a17 = 0x00300217, /** ARM Cortex-A32. */ - cpuinfo_uarch_cortex_a32 = 0x00300332, + cpuinfo_uarch_cortex_a32 = 0x00300332, /** ARM Cortex-A35. */ - cpuinfo_uarch_cortex_a35 = 0x00300335, + cpuinfo_uarch_cortex_a35 = 0x00300335, /** ARM Cortex-A53. */ - cpuinfo_uarch_cortex_a53 = 0x00300353, + cpuinfo_uarch_cortex_a53 = 0x00300353, /** ARM Cortex-A55. */ - cpuinfo_uarch_cortex_a55 = 0x00300355, + cpuinfo_uarch_cortex_a55 = 0x00300355, /** ARM Cortex-A57. */ - cpuinfo_uarch_cortex_a57 = 0x00300357, + cpuinfo_uarch_cortex_a57 = 0x00300357, + /** ARM Cortex-A65. */ + cpuinfo_uarch_cortex_a65 = 0x00300365, /** ARM Cortex-A72. */ - cpuinfo_uarch_cortex_a72 = 0x00300372, + cpuinfo_uarch_cortex_a72 = 0x00300372, /** ARM Cortex-A73. */ - cpuinfo_uarch_cortex_a73 = 0x00300373, + cpuinfo_uarch_cortex_a73 = 0x00300373, /** ARM Cortex-A75. */ - cpuinfo_uarch_cortex_a75 = 0x00300375, + cpuinfo_uarch_cortex_a75 = 0x00300375, /** ARM Cortex-A76. */ - cpuinfo_uarch_cortex_a76 = 0x00300376, + cpuinfo_uarch_cortex_a76 = 0x00300376, + /** ARM Cortex-A76AE. */ + cpuinfo_uarch_cortex_a76ae = 0x00300378, + /** ARM Cortex-A77. */ + cpuinfo_uarch_cortex_a77 = 0x00300377, + + /** ARM Neoverse N1. */ + cpuinfo_uarch_neoverse_n1 = 0x00300400, + /** ARM Neoverse E1. */ + cpuinfo_uarch_neoverse_e1 = 0x00300401, /** Qualcomm Scorpion. */ cpuinfo_uarch_scorpion = 0x00400100, @@ -406,12 +443,22 @@ enum cpuinfo_uarch { /** Nvidia Carmel. */ cpuinfo_uarch_carmel = 0x00500102, - /** Samsung Mongoose M1 (Exynos 8890 big cores). */ + /** Samsung Exynos M1 (Exynos 8890 big cores). */ + cpuinfo_uarch_exynos_m1 = 0x00600100, + /** Samsung Exynos M2 (Exynos 8895 big cores). */ + cpuinfo_uarch_exynos_m2 = 0x00600101, + /** Samsung Exynos M3 (Exynos 9810 big cores). */ + cpuinfo_uarch_exynos_m3 = 0x00600102, + /** Samsung Exynos M4 (Exynos 9820 big cores). */ + cpuinfo_uarch_exynos_m4 = 0x00600103, + /** Samsung Exynos M5 (Exynos 9830 big cores). */ + cpuinfo_uarch_exynos_m5 = 0x00600104, + + /* Old names for Exynos. */ cpuinfo_uarch_mongoose_m1 = 0x00600100, - /** Samsung Mongoose M2 (Exynos 8895 big cores). */ cpuinfo_uarch_mongoose_m2 = 0x00600101, - /** Samsung Meerkat M3 (Exynos 9810 big cores). */ cpuinfo_uarch_meerkat_m3 = 0x00600102, + cpuinfo_uarch_meerkat_m4 = 0x00600103, /** Apple A6 and A6X processors. */ cpuinfo_uarch_swift = 0x00700100, @@ -640,6 +687,8 @@ void CPUINFO_ABI cpuinfo_deinitialize(void); bool avx512bitalg; bool avx512vpopcntdq; bool avx512vnni; + bool avx512bf16; + bool avx512vp2intersect; bool avx512_4vnniw; bool avx512_4fmaps; bool hle; @@ -1110,6 +1159,22 @@ static inline bool cpuinfo_has_x86_avx512vnni(void) { #endif } +static inline bool cpuinfo_has_x86_avx512bf16(void) { + #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512bf16; + #else + return false; + #endif +} + +static inline bool cpuinfo_has_x86_avx512vp2intersect(void) { + #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx512vp2intersect; + #else + return false; + #endif +} + static inline bool cpuinfo_has_x86_avx512_4vnniw(void) { #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 return cpuinfo_isa.avx512_4vnniw; @@ -1682,6 +1747,11 @@ uint32_t CPUINFO_ABI cpuinfo_get_l2_caches_count(void); uint32_t CPUINFO_ABI cpuinfo_get_l3_caches_count(void); uint32_t CPUINFO_ABI cpuinfo_get_l4_caches_count(void); +/** + * Returns upper bound on cache size. + */ +uint32_t CPUINFO_ABI cpuinfo_get_max_cache_size(void); + const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_current_processor(void); const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_current_core(void); @@ -18,6 +18,7 @@ uint32_t cpuinfo_cores_count = 0; uint32_t cpuinfo_clusters_count = 0; uint32_t cpuinfo_packages_count = 0; uint32_t cpuinfo_cache_count[cpuinfo_cache_level_max] = { 0 }; +uint32_t cpuinfo_max_cache_size = 0; const struct cpuinfo_processor* cpuinfo_get_processors(void) { @@ -244,3 +245,10 @@ uint32_t CPUINFO_ABI cpuinfo_get_l4_caches_count(void) { } return cpuinfo_cache_count[cpuinfo_cache_level_4]; } + +uint32_t CPUINFO_ABI cpuinfo_get_max_cache_size(void) { + if (!cpuinfo_is_initialized) { + cpuinfo_log_fatal("cpuinfo_get_%s called before cpuinfo is initialized", "max_cache_size"); + } + return cpuinfo_max_cache_size; +} diff --git a/src/arm/api.h b/src/arm/api.h index 11e588b..69274bc 100644 --- a/src/arm/api.h +++ b/src/arm/api.h @@ -104,6 +104,9 @@ CPUINFO_INTERNAL void cpuinfo_arm_decode_cache( struct cpuinfo_cache l1d[restrict static 1], struct cpuinfo_cache l2[restrict static 1], struct cpuinfo_cache l3[restrict static 1]); + +CPUINFO_INTERNAL uint32_t cpuinfo_arm_compute_max_cache_size( + const struct cpuinfo_processor processor[restrict static 1]); #else /* defined(__cplusplus) */ CPUINFO_INTERNAL void cpuinfo_arm_decode_cache( enum cpuinfo_uarch uarch, diff --git a/src/arm/cache.c b/src/arm/cache.c index 5ada7d9..ccadeb4 100644 --- a/src/arm/cache.c +++ b/src/arm/cache.c @@ -1,10 +1,12 @@ #include <stdint.h> #include <cpuinfo.h> +#include <cpuinfo/internal-api.h> #include <cpuinfo/log.h> #include <arm/api.h> #include <arm/midr.h> + void cpuinfo_arm_decode_cache( enum cpuinfo_uarch uarch, uint32_t cluster_cores, @@ -109,7 +111,7 @@ void cpuinfo_arm_decode_cache( * memory accesses and has been optimized for use with the Cortex-A5 processor. * 8.1.7. Exclusive L2 cache * The Cortex-A5 processor can be connected to an L2 cache that supports an exclusive cache mode. - * This mode must be activated both in the Cortex-A5 processor and in the L2 cache controller. + * This mode must be activated both in the Cortex-A5 processor and in the L2 cache controller. * * +--------------------+-----------+-----------+----------+-----------+ * | Processor model | L1D cache | L1I cache | L2 cache | Reference | @@ -698,7 +700,7 @@ void cpuinfo_arm_decode_cache( * [3] https://en.wikichip.org/wiki/hisilicon/kirin/980 */ if (midr_is_qualcomm_cortex_a55_silver(midr)) { - /* Qualcomm-modified Cortex-A55 in Snapdragon 710 / 845 */ + /* Qualcomm-modified Cortex-A55 in Snapdragon 670 / 710 / 845 */ uint32_t l3_size = 1024 * 1024; switch (chipset->series) { case cpuinfo_arm_chipset_series_qualcomm_snapdragon: @@ -827,6 +829,62 @@ void cpuinfo_arm_decode_cache( .flags = CPUINFO_CACHE_INCLUSIVE }; break; + case cpuinfo_uarch_cortex_a65: + { + /* + * ARM Cortex‑A65 Core Technical Reference Manual + * A6.1. About the L1 memory system + * The L1 memory system enhances the performance and power efficiency in the Cortex‑A65 core. + * It consists of separate instruction and data caches. You can configure instruction and data caches + * independently during implementation to sizes of 32KB or 64KB. + * + * L1 instruction-side memory system + * The L1 instruction-side memory system provides an instruction stream to the DPU. Its key features are: + * - 64-byte instruction side cache line length. + * - 4-way set associative L1 instruction cache. + * + * L1 data-side memory system + * - 64-byte data side cache line length. + * - 4-way set associative L1 data cache. + * + * A7.1 About the L2 memory system + * The Cortex‑A65 L2 memory system is required to interface the Cortex‑A65 cores to the L3 memory system. + * The L2 memory subsystem consists of: + * - An optional 4-way, set-associative L2 cache with a configurable size of 64KB, 128KB, or 256KB. + * Cache lines have a fixed length of 64 bytes. + * + * The main features of the L2 memory system are: + * - Strictly exclusive with L1 data cache. + * - Pseudo-inclusive with L1 instruction cache. + * - Private per-core unified L2 cache. + */ + const uint32_t l1_size = 32 * 1024; + const uint32_t l2_size = 128 * 1024; + const uint32_t l3_size = 512 * 1024; + *l1i = (struct cpuinfo_cache) { + .size = l1_size, + .associativity = 4, + .line_size = 64, + }; + *l1d = (struct cpuinfo_cache) { + .size = l1_size, + .associativity = 4, + .line_size = 64, + }; + *l2 = (struct cpuinfo_cache) { + .size = l2_size, + .associativity = 4, + .line_size = 64, + .flags = CPUINFO_CACHE_INCLUSIVE + }; + *l3 = (struct cpuinfo_cache) { + .size = l3_size, + /* DynamIQ */ + .associativity = 16, + .line_size = 64, + }; + break; + } case cpuinfo_uarch_cortex_a72: { /* @@ -1047,6 +1105,7 @@ void cpuinfo_arm_decode_cache( break; } case cpuinfo_uarch_cortex_a76: + case cpuinfo_uarch_cortex_a76ae: { /* * ARM Cortex-A76 Core Technical Reference Manual @@ -1119,6 +1178,57 @@ void cpuinfo_arm_decode_cache( }; break; } + case cpuinfo_uarch_cortex_a77: + { + /* + * ARM Cortex-A77 Core Technical Reference Manual + * A6.1. About the L1 memory system + * The L1 memory system consists of separate instruction and data caches. Both have a fixed size of 64KB. + * + * A6.1.1 L1 instruction-side memory system + * The L1 instruction memory system has the following key features: + * - Virtually Indexed, Physically Tagged (VIPT), which behaves as a Physically Indexed, + * Physically Tagged (PIPT) 4-way set-associative L1 data cache. + * - Fixed cache line length of 64 bytes. + * + * A6.1.2 L1 data-side memory system + * The L1 data memory system has the following features: + * - Virtually Indexed, Physically Tagged (VIPT), which behaves as a Physically Indexed, + * Physically Tagged (PIPT) 4-way set-associative L1 data cache. + * - Fixed cache line length of 64 bytes. + * - Pseudo-LRU cache replacement policy. + * + * A7.1 About the L2 memory system + * The L2 memory subsystem consist of: + * - An 8-way set associative L2 cache with a configurable size of 128KB, 256KB or 512KB. Cache lines + * have a fixed length of 64 bytes. + * - Strictly inclusive with L1 data cache. Weakly inclusive with L1 instruction cache. + */ + const uint32_t l2_size = 256 * 1024; + const uint32_t l3_size = 1024 * 1024; + *l1i = (struct cpuinfo_cache) { + .size = 64 * 1024, + .associativity = 4, + .line_size = 64, + }; + *l1d = (struct cpuinfo_cache) { + .size = 64 * 1024, + .associativity = 4, + .line_size = 64, + }; + *l2 = (struct cpuinfo_cache) { + .size = l2_size, + .associativity = 8, + .line_size = 64, + .flags = CPUINFO_CACHE_INCLUSIVE, + }; + *l3 = (struct cpuinfo_cache) { + .size = l3_size, + .associativity = 16, + .line_size = 64, + }; + break; + } #if CPUINFO_ARCH_ARM && !defined(__ARM_ARCH_8A__) case cpuinfo_uarch_scorpion: /* @@ -1248,8 +1358,8 @@ void cpuinfo_arm_decode_cache( .line_size = 64 }; break; - case cpuinfo_uarch_mongoose_m1: - case cpuinfo_uarch_mongoose_m2: + case cpuinfo_uarch_exynos_m1: + case cpuinfo_uarch_exynos_m2: /* * - "Moving past branch prediction we can see some elements of how the cache is set up for the L1 I$, * namely 64 KB split into four sets with 128-byte line sizes for 128 cache lines per set" [1] @@ -1283,7 +1393,7 @@ void cpuinfo_arm_decode_cache( .line_size = 64 }; break; - case cpuinfo_uarch_meerkat_m3: + case cpuinfo_uarch_exynos_m3: /* * +--------------------+-------+-----------+-----------+-----------+----------+------------+ * | Processor model | Cores | L1D cache | L1I cache | L2 cache | L3 cache | Reference | @@ -1294,19 +1404,19 @@ void cpuinfo_arm_decode_cache( * [1] https://www.anandtech.com/show/12478/exynos-9810-handson-awkward-first-results */ *l1i = (struct cpuinfo_cache) { - .size = 64 * 1024 /* assume same as in Mongoose cores */, - .associativity = 4 /* assume same as in Mongoose cores */, - .line_size = 128 /* assume same as in Mongoose cores */ + .size = 64 * 1024 /* assume same as in Exynos M1/M2 cores */, + .associativity = 4 /* assume same as in Exynos M1/M2 cores */, + .line_size = 128 /* assume same as in Exynos M1/M2 cores */ }; *l1d = (struct cpuinfo_cache) { .size = 64 * 1024, - .associativity = 8 /* assume same as in Mongoose cores */, - .line_size = 64 /* assume same as in Mongoose cores */, + .associativity = 8 /* assume same as in Exynos M1/M2 cores */, + .line_size = 64 /* assume same as in Exynos M1/M2 cores */, }; *l2 = (struct cpuinfo_cache) { .size = 512 * 1024, - .associativity = 16 /* assume same as in Mongoose cores */, - .line_size = 64 /* assume same as in Mongoose cores */, + .associativity = 16 /* assume same as in Exynos M1/M2 cores */, + .line_size = 64 /* assume same as in Exynos M1/M2 cores */, }; *l3 = (struct cpuinfo_cache) { .size = 4 * 1024 * 1024, @@ -1393,3 +1503,124 @@ void cpuinfo_arm_decode_cache( } } } + +uint32_t cpuinfo_arm_compute_max_cache_size(const struct cpuinfo_processor* processor) { + /* + * There is no precise way to detect cache size on ARM/ARM64, and cache size reported by cpuinfo + * may underestimate the actual cache size. Thus, we use microarchitecture-specific maximum. + */ + switch (processor->core->uarch) { + case cpuinfo_uarch_xscale: + case cpuinfo_uarch_arm11: + case cpuinfo_uarch_scorpion: + case cpuinfo_uarch_krait: + case cpuinfo_uarch_kryo: + case cpuinfo_uarch_exynos_m1: + case cpuinfo_uarch_exynos_m2: + case cpuinfo_uarch_exynos_m3: + /* cpuinfo-detected cache size always correct */ + return cpuinfo_compute_max_cache_size(processor); + case cpuinfo_uarch_cortex_a5: + /* Max observed (NXP Vybrid SoC) */ + return 512 * 1024; + case cpuinfo_uarch_cortex_a7: + /* + * Cortex-A7 MPCore Technical Reference Manual: + * 7.1. About the L2 Memory system + * The L2 memory system consists of an: + * - Optional tightly-coupled L2 cache that includes: + * - Configurable L2 cache size of 128KB, 256KB, 512KB, and 1MB. + */ + return 1024 * 1024; + case cpuinfo_uarch_cortex_a8: + /* + * Cortex-A8 Technical Reference Manual: + * 8.1. About the L2 memory system + * The key features of the L2 memory system include: + * - configurable cache size of 0KB, 128KB, 256KB, 512KB, and 1MB + */ + return 1024 * 1024; + case cpuinfo_uarch_cortex_a9: + /* Max observed (e.g. Exynos 4212) */ + return 1024 * 1024; + case cpuinfo_uarch_cortex_a12: + case cpuinfo_uarch_cortex_a17: + /* + * ARM Cortex-A17 MPCore Processor Technical Reference Manual: + * 7.1. About the L2 Memory system + * The key features of the L2 memory system include: + * - An integrated L2 cache: + * - The cache size is implemented as either 256KB, 512KB, 1MB, 2MB, 4MB or 8MB. + */ + return 8 * 1024 * 1024; + case cpuinfo_uarch_cortex_a15: + /* + * ARM Cortex-A15 MPCore Processor Technical Reference Manual: + * 7.1. About the L2 memory system + * The features of the L2 memory system include: + * - Configurable L2 cache size of 512KB, 1MB, 2MB and 4MB. + */ + return 4 * 1024 * 1024; + case cpuinfo_uarch_cortex_a35: + /* + * ARM Cortex‑A35 Processor Technical Reference Manual: + * 7.1 About the L2 memory system + * L2 cache + * - Further features of the L2 cache are: + * - Configurable size of 128KB, 256KB, 512KB, and 1MB. + */ + return 1024 * 1024; + case cpuinfo_uarch_cortex_a53: + /* + * ARM Cortex-A53 MPCore Processor Technical Reference Manual: + * 7.1. About the L2 memory system + * The L2 memory system consists of an: + * - Optional tightly-coupled L2 cache that includes: + * - Configurable L2 cache size of 128KB, 256KB, 512KB, 1MB and 2MB. + */ + return 2 * 1024 * 1024; + case cpuinfo_uarch_cortex_a57: + /* + * ARM Cortex-A57 MPCore Processor Technical Reference Manual: + * 7.1 About the L2 memory system + * The features of the L2 memory system include: + * - Configurable L2 cache size of 512KB, 1MB, and 2MB. + */ + return 2 * 1024 * 1024; + case cpuinfo_uarch_cortex_a72: + /* + * ARM Cortex-A72 MPCore Processor Technical Reference Manual: + * 7.1 About the L2 memory system + * The features of the L2 memory system include: + * - Configurable L2 cache size of 512KB, 1MB, 2MB and 4MB. + */ + return 4 * 1024 * 1024; + case cpuinfo_uarch_cortex_a73: + /* + * ARM Cortex‑A73 MPCore Processor Technical Reference Manual + * 7.1 About the L2 memory system + * The L2 memory system consists of: + * - A tightly-integrated L2 cache with: + * - A configurable size of 256KB, 512KB, 1MB, 2MB, 4MB, or 8MB. + */ + return 8 * 1024 * 1024; + case cpuinfo_uarch_cortex_a55: + case cpuinfo_uarch_cortex_a75: + case cpuinfo_uarch_cortex_a76: + case cpuinfo_uarch_exynos_m4: + default: + /* + * ARM DynamIQ Shared Unit Technical Reference Manual + * 1.3 Implementation options + * L3_CACHE_SIZE + * - 256KB + * - 512KB + * - 1024KB + * - 1536KB + * - 2048KB + * - 3072KB + * - 4096KB + */ + return 4 * 1024 * 1024; + } +} diff --git a/src/arm/linux/init.c b/src/arm/linux/init.c index a297f63..f0c432c 100644 --- a/src/arm/linux/init.c +++ b/src/arm/linux/init.c @@ -678,6 +678,8 @@ void cpuinfo_arm_linux_init(void) { cpuinfo_cache_count[cpuinfo_cache_level_2] = l2_count; cpuinfo_cache_count[cpuinfo_cache_level_3] = l3_count; + cpuinfo_max_cache_size = cpuinfo_arm_compute_max_cache_size(&processors[0]); + __sync_synchronize(); cpuinfo_is_initialized = true; diff --git a/src/arm/linux/midr.c b/src/arm/linux/midr.c index 668fc72..2c3116b 100644 --- a/src/arm/linux/midr.c +++ b/src/arm/linux/midr.c @@ -220,7 +220,7 @@ static const struct cluster_config cluster_configs[] = { .model = UINT16_C(7420), .clusters = 2, .cluster_cores = { - [0] = 4, + [0] = 4, [1] = 4, }, .cluster_midr = { @@ -229,7 +229,7 @@ static const struct cluster_config cluster_configs[] = { }, }, { - /* Exynos 8890: 4x Mongoose + 4x Cortex-A53 */ + /* Exynos 8890: 4x Exynos M1 + 4x Cortex-A53 */ .cores = 8, .series = cpuinfo_arm_chipset_series_samsung_exynos, .model = UINT16_C(8890), @@ -695,7 +695,7 @@ static void cpuinfo_arm_linux_detect_cluster_midr_by_sequential_scan( if (bitmask_all(processors[i].flags, CPUINFO_LINUX_FLAG_VALID)) { if (processors[i].package_leader_id == i) { if (bitmask_all(processors[i].flags, CPUINFO_ARM_LINUX_VALID_MIDR)) { - midr = processors[i].midr; + midr = processors[i].midr; } else { cpuinfo_log_info("assume processor %"PRIu32" to have MIDR %08"PRIx32, i, midr); /* To be consistent, we copy the MIDR entirely, rather than by parts */ @@ -836,7 +836,7 @@ uint32_t cpuinfo_arm_linux_detect_cluster_midr( * - Clusters preceeding the first reported MIDR value are assumed to have the last reported MIDR value. * - Clusters following any reported MIDR value to have that MIDR value. */ - + if (cpuinfo_arm_linux_detect_cluster_midr_by_chipset( chipset, clusters_count, cluster_leaders, usable_processors, processors, true)) { diff --git a/src/arm/mach/init.c b/src/arm/mach/init.c index 5b14b49..e64cc18 100644 --- a/src/arm/mach/init.c +++ b/src/arm/mach/init.c @@ -562,6 +562,8 @@ void cpuinfo_arm_mach_init(void) { cpuinfo_clusters_count = num_clusters; cpuinfo_packages_count = mach_topology.packages; + cpuinfo_max_cache_size = cpuinfo_compute_max_cache_size(&processors[0]); + __sync_synchronize(); cpuinfo_is_initialized = true; diff --git a/src/arm/midr.h b/src/arm/midr.h index 6363ed7..d5a28e3 100644 --- a/src/arm/midr.h +++ b/src/arm/midr.h @@ -33,31 +33,31 @@ #define CPUINFO_ARM_MIDR_KRYO_SILVER_821 UINT32_C(0x510F2010) #define CPUINFO_ARM_MIDR_KRYO_GOLD UINT32_C(0x510F2050) #define CPUINFO_ARM_MIDR_KRYO_SILVER_820 UINT32_C(0x510F2110) -#define CPUINFO_ARM_MIDR_MONGOOSE UINT32_C(0x530F0010) +#define CPUINFO_ARM_MIDR_EXYNOS_M1_M2 UINT32_C(0x530F0010) #define CPUINFO_ARM_MIDR_DENVER2 UINT32_C(0x4E0F0030) inline static uint32_t midr_set_implementer(uint32_t midr, uint32_t implementer) { - return (midr & ~CPUINFO_ARM_MIDR_IMPLEMENTER_MASK) | + return (midr & ~CPUINFO_ARM_MIDR_IMPLEMENTER_MASK) | ((implementer << CPUINFO_ARM_MIDR_IMPLEMENTER_OFFSET) & CPUINFO_ARM_MIDR_IMPLEMENTER_MASK); } inline static uint32_t midr_set_variant(uint32_t midr, uint32_t variant) { - return (midr & ~CPUINFO_ARM_MIDR_VARIANT_MASK) | + return (midr & ~CPUINFO_ARM_MIDR_VARIANT_MASK) | ((variant << CPUINFO_ARM_MIDR_VARIANT_OFFSET) & CPUINFO_ARM_MIDR_VARIANT_MASK); } inline static uint32_t midr_set_architecture(uint32_t midr, uint32_t architecture) { - return (midr & ~CPUINFO_ARM_MIDR_ARCHITECTURE_MASK) | + return (midr & ~CPUINFO_ARM_MIDR_ARCHITECTURE_MASK) | ((architecture << CPUINFO_ARM_MIDR_ARCHITECTURE_OFFSET) & CPUINFO_ARM_MIDR_ARCHITECTURE_MASK); } inline static uint32_t midr_set_part(uint32_t midr, uint32_t part) { - return (midr & ~CPUINFO_ARM_MIDR_PART_MASK) | + return (midr & ~CPUINFO_ARM_MIDR_PART_MASK) | ((part << CPUINFO_ARM_MIDR_PART_OFFSET) & CPUINFO_ARM_MIDR_PART_MASK); } inline static uint32_t midr_set_revision(uint32_t midr, uint32_t revision) { - return (midr & ~CPUINFO_ARM_MIDR_REVISION_MASK) | + return (midr & ~CPUINFO_ARM_MIDR_REVISION_MASK) | ((revision << CPUINFO_ARM_MIDR_REVISION_OFFSET) & CPUINFO_ARM_MIDR_REVISION_MASK); } @@ -171,13 +171,20 @@ inline static bool midr_is_kryo_gold(uint32_t midr) { inline static uint32_t midr_score_core(uint32_t midr) { const uint32_t core_mask = CPUINFO_ARM_MIDR_IMPLEMENTER_MASK | CPUINFO_ARM_MIDR_PART_MASK; switch (midr & core_mask) { + case UINT32_C(0x53000040): /* Exynos M5 */ + case UINT32_C(0x53000030): /* Exynos M4 */ + /* These cores are in big role w.r.t Cortex-A75 or Cortex-A76 */ + return 6; case UINT32_C(0x4E000030): /* Denver 2 */ - case UINT32_C(0x53000010): /* Mongoose */ - case UINT32_C(0x53000020): /* Meerkat */ + case UINT32_C(0x53000010): /* Exynos M1 and Exynos M2 */ + case UINT32_C(0x53000020): /* Exynos M3 */ + case UINT32_C(0x51008040): /* Kryo 485 Gold / Gold Prime */ case UINT32_C(0x51008020): /* Kryo 385 Gold */ case UINT32_C(0x51008000): /* Kryo 260 / 280 Gold */ case UINT32_C(0x51002050): /* Kryo Gold */ case UINT32_C(0x4800D400): /* Cortex-A76 (HiSilicon) */ + case UINT32_C(0x4100D0D0): /* Cortex-A77 */ + case UINT32_C(0x4100D0E0): /* Cortex-A76AE */ case UINT32_C(0x4100D0B0): /* Cortex-A76 */ case UINT32_C(0x4100D0A0): /* Cortex-A75 */ case UINT32_C(0x4100D090): /* Cortex-A73 */ @@ -191,12 +198,14 @@ inline static uint32_t midr_score_core(uint32_t midr) { case UINT32_C(0x4100D070): /* Cortex-A57 */ /* Cortex-A57 can be in LITTLE role w.r.t. Denver 2, or in big role w.r.t. Cortex-A53 */ return 4; + case UINT32_C(0x4100D060): /* Cortex-A65 */ case UINT32_C(0x4100D050): /* Cortex-A55 */ case UINT32_C(0x4100D030): /* Cortex-A53 */ /* Cortex-A53 is usually in LITTLE role, but can be in big role w.r.t. Cortex-A35 */ return 2; case UINT32_C(0x4100D040): /* Cortex-A35 */ case UINT32_C(0x4100C070): /* Cortex-A7 */ + case UINT32_C(0x51008050): /* Kryo 485 Silver */ case UINT32_C(0x51008030): /* Kryo 385 Silver */ case UINT32_C(0x51008010): /* Kryo 260 / 280 Silver */ case UINT32_C(0x51002110): /* Kryo Silver (Snapdragon 820) */ @@ -215,7 +224,7 @@ inline static uint32_t midr_score_core(uint32_t midr) { } inline static uint32_t midr_little_core_for_big(uint32_t midr) { - const uint32_t core_mask = + const uint32_t core_mask = CPUINFO_ARM_MIDR_IMPLEMENTER_MASK | CPUINFO_ARM_MIDR_ARCHITECTURE_MASK | CPUINFO_ARM_MIDR_PART_MASK; switch (midr & core_mask) { case CPUINFO_ARM_MIDR_CORTEX_A75: @@ -223,7 +232,7 @@ inline static uint32_t midr_little_core_for_big(uint32_t midr) { case CPUINFO_ARM_MIDR_CORTEX_A73: case CPUINFO_ARM_MIDR_CORTEX_A72: case CPUINFO_ARM_MIDR_CORTEX_A57: - case CPUINFO_ARM_MIDR_MONGOOSE: + case CPUINFO_ARM_MIDR_EXYNOS_M1_M2: return CPUINFO_ARM_MIDR_CORTEX_A53; case CPUINFO_ARM_MIDR_CORTEX_A17: case CPUINFO_ARM_MIDR_CORTEX_A15: diff --git a/src/arm/uarch.c b/src/arm/uarch.c index d7d2c63..a38250a 100644 --- a/src/arm/uarch.c +++ b/src/arm/uarch.c @@ -60,6 +60,9 @@ void cpuinfo_arm_decode_vendor_uarch( case 0xD05: *uarch = cpuinfo_uarch_cortex_a55; break; + case 0xD06: + *uarch = cpuinfo_uarch_cortex_a65; + break; case 0xD07: *uarch = cpuinfo_uarch_cortex_a57; break; @@ -75,6 +78,22 @@ void cpuinfo_arm_decode_vendor_uarch( case 0xD0B: *uarch = cpuinfo_uarch_cortex_a76; break; +#if CPUINFO_ARCH_ARM64 && !defined(__ANDROID__) + case 0xD0C: + *uarch = cpuinfo_uarch_neoverse_n1; + break; +#endif /* CPUINFO_ARCH_ARM64 && !defined(__ANDROID__) */ + case 0xD0D: + *uarch = cpuinfo_uarch_cortex_a77; + break; + case 0xD0E: + *uarch = cpuinfo_uarch_cortex_a76ae; + break; +#if CPUINFO_ARCH_ARM64 && !defined(__ANDROID__) + case 0xD4A: + *uarch = cpuinfo_uarch_neoverse_e1; + break; +#endif /* CPUINFO_ARCH_ARM64 && !defined(__ANDROID__) */ default: switch (midr_get_part(midr) >> 8) { #if CPUINFO_ARCH_ARM @@ -242,10 +261,14 @@ void cpuinfo_arm_decode_vendor_uarch( *vendor = cpuinfo_vendor_arm; *uarch = cpuinfo_uarch_cortex_a55; break; - case 0x804: + case 0x804: /* High-performance Kryo 485 "Gold" / "Gold Prime" -> Cortex-A76 */ *vendor = cpuinfo_vendor_arm; *uarch = cpuinfo_uarch_cortex_a76; break; + case 0x805: /* Low-performance Kryo 485 "Silver" -> Cortex-A55 */ + *vendor = cpuinfo_vendor_arm; + *uarch = cpuinfo_uarch_cortex_a55; + break; #if CPUINFO_ARCH_ARM64 && !defined(__ANDROID__) case 0xC00: *uarch = cpuinfo_uarch_falkor; @@ -263,27 +286,43 @@ void cpuinfo_arm_decode_vendor_uarch( switch (midr & (CPUINFO_ARM_MIDR_VARIANT_MASK | CPUINFO_ARM_MIDR_PART_MASK)) { case 0x00100010: /* - * Exynos 8890 MIDR = 0x531F0011, assume Mongoose M1 has: + * Exynos 8890 MIDR = 0x531F0011, assume Exynos M1 has: * - CPU variant 0x1 * - CPU part 0x001 */ - *uarch = cpuinfo_uarch_mongoose_m1; + *uarch = cpuinfo_uarch_exynos_m1; break; case 0x00400010: /* - * Exynos 8895 MIDR = 0x534F0010, assume Mongoose M2 has: + * Exynos 8895 MIDR = 0x534F0010, assume Exynos M2 has: * - CPU variant 0x4 * - CPU part 0x001 */ - *uarch = cpuinfo_uarch_mongoose_m2; + *uarch = cpuinfo_uarch_exynos_m2; break; case 0x00100020: /* - * Exynos 9810 MIDR = 0x531F0020, assume Meerkat M3 has: + * Exynos 9810 MIDR = 0x531F0020, assume Exynos M3 has: * - CPU variant 0x1 * - CPU part 0x002 */ - *uarch = cpuinfo_uarch_meerkat_m3; + *uarch = cpuinfo_uarch_exynos_m3; + break; + case 0x00100030: + /* + * Exynos 9820 MIDR = 0x531F0030, assume Exynos M4 has: + * - CPU variant 0x1 + * - CPU part 0x003 + */ + *uarch = cpuinfo_uarch_exynos_m4; + break; + case 0x00100040: + /* + * Exynos 9820 MIDR = 0x531F0040, assume Exynos M5 has: + * - CPU variant 0x1 + * - CPU part 0x004 + */ + *uarch = cpuinfo_uarch_exynos_m5; break; default: cpuinfo_log_warning("unknown Samsung CPU variant 0x%01"PRIx32" part 0x%03"PRIx32" ignored", diff --git a/src/cache.c b/src/cache.c new file mode 100644 index 0000000..b976b87 --- /dev/null +++ b/src/cache.c @@ -0,0 +1,18 @@ +#include <stddef.h> + +#include <cpuinfo.h> +#include <cpuinfo/internal-api.h> + + +uint32_t cpuinfo_compute_max_cache_size(const struct cpuinfo_processor* processor) { + if (processor->cache.l4 != NULL) { + return processor->cache.l4->size; + } else if (processor->cache.l3 != NULL) { + return processor->cache.l3->size; + } else if (processor->cache.l2 != NULL) { + return processor->cache.l2->size; + } else if (processor->cache.l1d != NULL) { + return processor->cache.l1d->size; + } + return 0; +} diff --git a/src/cpuinfo/internal-api.h b/src/cpuinfo/internal-api.h index 6045750..717b810 100644 --- a/src/cpuinfo/internal-api.h +++ b/src/cpuinfo/internal-api.h @@ -31,6 +31,7 @@ extern CPUINFO_INTERNAL uint32_t cpuinfo_cores_count; extern CPUINFO_INTERNAL uint32_t cpuinfo_clusters_count; extern CPUINFO_INTERNAL uint32_t cpuinfo_packages_count; extern CPUINFO_INTERNAL uint32_t cpuinfo_cache_count[cpuinfo_cache_level_max]; +extern CPUINFO_INTERNAL uint32_t cpuinfo_max_cache_size; CPUINFO_PRIVATE void cpuinfo_x86_mach_init(void); CPUINFO_PRIVATE void cpuinfo_x86_linux_init(void); @@ -40,4 +41,6 @@ CPUINFO_PRIVATE void cpuinfo_x86_linux_init(void); CPUINFO_PRIVATE void cpuinfo_arm_mach_init(void); CPUINFO_PRIVATE void cpuinfo_arm_linux_init(void); +CPUINFO_PRIVATE uint32_t cpuinfo_compute_max_cache_size(const struct cpuinfo_processor* processor); + typedef void (*cpuinfo_processor_callback)(uint32_t); diff --git a/src/x86/isa.c b/src/x86/isa.c index bca1ecd..d27dbca 100644 --- a/src/x86/isa.c +++ b/src/x86/isa.c @@ -42,8 +42,10 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( { struct cpuinfo_x86_isa isa = { 0 }; - const struct cpuid_regs structured_feature_info = + const struct cpuid_regs structured_feature_info0 = (max_base_index >= 7) ? cpuidex(7, 0) : (struct cpuid_regs) { 0, 0, 0, 0}; + const struct cpuid_regs structured_feature_info1 = + (max_base_index >= 7) ? cpuidex(7, 1) : (struct cpuid_regs) { 0, 0, 0, 0}; const uint32_t processor_capacity_info_index = UINT32_C(0x80000008); const struct cpuid_regs processor_capacity_info = @@ -144,9 +146,9 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( /* * CLFLUSHOPT instruction: - * - Intel: ebx[bit 23] in structured feature info. + * - Intel: ebx[bit 23] in structured feature info (ecx = 0). */ - isa.clflushopt = !!(structured_feature_info.ebx & UINT32_C(0x00800000)); + isa.clflushopt = !!(structured_feature_info0.ebx & UINT32_C(0x00800000)); /* * MWAIT/MONITOR instructions: @@ -273,9 +275,9 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( /* * PREFETCHWT1 instruction: - * - Intel: ecx[bit 0] of structured feature info. Reserved bit on AMD. + * - Intel: ecx[bit 0] of structured feature info (ecx = 0). Reserved bit on AMD. */ - isa.prefetchwt1 = !!(structured_feature_info.ecx & UINT32_C(0x00000001)); + isa.prefetchwt1 = !!(structured_feature_info0.ecx & UINT32_C(0x00000001)); #if CPUINFO_ARCH_X86 /* @@ -386,111 +388,123 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( /* * AVX2 instructions: - * - Intel: ebx[bit 5] in structured feature info. + * - Intel: ebx[bit 5] in structured feature info (ecx = 0). */ - isa.avx2 = avx_regs && !!(structured_feature_info.ebx & UINT32_C(0x00000020)); + isa.avx2 = avx_regs && !!(structured_feature_info0.ebx & UINT32_C(0x00000020)); /* * AVX512F instructions: - * - Intel: ebx[bit 16] in structured feature info. + * - Intel: ebx[bit 16] in structured feature info (ecx = 0). */ - isa.avx512f = avx512_regs && !!(structured_feature_info.ebx & UINT32_C(0x00010000)); + isa.avx512f = avx512_regs && !!(structured_feature_info0.ebx & UINT32_C(0x00010000)); /* * AVX512PF instructions: - * - Intel: ebx[bit 26] in structured feature info. + * - Intel: ebx[bit 26] in structured feature info (ecx = 0). */ - isa.avx512pf = avx512_regs && !!(structured_feature_info.ebx & UINT32_C(0x04000000)); + isa.avx512pf = avx512_regs && !!(structured_feature_info0.ebx & UINT32_C(0x04000000)); /* * AVX512ER instructions: - * - Intel: ebx[bit 27] in structured feature info. + * - Intel: ebx[bit 27] in structured feature info (ecx = 0). */ - isa.avx512er = avx512_regs && !!(structured_feature_info.ebx & UINT32_C(0x08000000)); + isa.avx512er = avx512_regs && !!(structured_feature_info0.ebx & UINT32_C(0x08000000)); /* * AVX512CD instructions: - * - Intel: ebx[bit 28] in structured feature info. + * - Intel: ebx[bit 28] in structured feature info (ecx = 0). */ - isa.avx512cd = avx512_regs && !!(structured_feature_info.ebx & UINT32_C(0x10000000)); + isa.avx512cd = avx512_regs && !!(structured_feature_info0.ebx & UINT32_C(0x10000000)); /* * AVX512DQ instructions: - * - Intel: ebx[bit 17] in structured feature info. + * - Intel: ebx[bit 17] in structured feature info (ecx = 0). */ - isa.avx512dq = avx512_regs && !!(structured_feature_info.ebx & UINT32_C(0x00020000)); + isa.avx512dq = avx512_regs && !!(structured_feature_info0.ebx & UINT32_C(0x00020000)); /* * AVX512BW instructions: - * - Intel: ebx[bit 30] in structured feature info. + * - Intel: ebx[bit 30] in structured feature info (ecx = 0). */ - isa.avx512bw = avx512_regs && !!(structured_feature_info.ebx & UINT32_C(0x40000000)); + isa.avx512bw = avx512_regs && !!(structured_feature_info0.ebx & UINT32_C(0x40000000)); /* * AVX512VL instructions: - * - Intel: ebx[bit 31] in structured feature info. + * - Intel: ebx[bit 31] in structured feature info (ecx = 0). */ - isa.avx512vl = avx512_regs && !!(structured_feature_info.ebx & UINT32_C(0x80000000)); + isa.avx512vl = avx512_regs && !!(structured_feature_info0.ebx & UINT32_C(0x80000000)); /* * AVX512IFMA instructions: - * - Intel: ebx[bit 21] in structured feature info. + * - Intel: ebx[bit 21] in structured feature info (ecx = 0). */ - isa.avx512ifma = avx512_regs && !!(structured_feature_info.ebx & UINT32_C(0x00200000)); + isa.avx512ifma = avx512_regs && !!(structured_feature_info0.ebx & UINT32_C(0x00200000)); /* * AVX512VBMI instructions: - * - Intel: ecx[bit 1] in structured feature info. + * - Intel: ecx[bit 1] in structured feature info (ecx = 0). */ - isa.avx512vbmi = avx512_regs && !!(structured_feature_info.ecx & UINT32_C(0x00000002)); + isa.avx512vbmi = avx512_regs && !!(structured_feature_info0.ecx & UINT32_C(0x00000002)); /* * AVX512VBMI2 instructions: - * - Intel: ecx[bit 6] in structured feature info. + * - Intel: ecx[bit 6] in structured feature info (ecx = 0). */ - isa.avx512vbmi2 = avx512_regs && !!(structured_feature_info.ecx & UINT32_C(0x00000040)); + isa.avx512vbmi2 = avx512_regs && !!(structured_feature_info0.ecx & UINT32_C(0x00000040)); /* * AVX512BITALG instructions: - * - Intel: ecx[bit 12] in structured feature info. + * - Intel: ecx[bit 12] in structured feature info (ecx = 0). */ - isa.avx512bitalg = avx512_regs && !!(structured_feature_info.ecx & UINT32_C(0x00001000)); + isa.avx512bitalg = avx512_regs && !!(structured_feature_info0.ecx & UINT32_C(0x00001000)); /* * AVX512VPOPCNTDQ instructions: - * - Intel: ecx[bit 14] in structured feature info. + * - Intel: ecx[bit 14] in structured feature info (ecx = 0). */ - isa.avx512vpopcntdq = avx512_regs && !!(structured_feature_info.ecx & UINT32_C(0x00004000)); + isa.avx512vpopcntdq = avx512_regs && !!(structured_feature_info0.ecx & UINT32_C(0x00004000)); /* * AVX512VNNI instructions: - * - Intel: ecx[bit 11] in structured feature info. + * - Intel: ecx[bit 11] in structured feature info (ecx = 0). */ - isa.avx512vnni = avx512_regs && !!(structured_feature_info.ecx & UINT32_C(0x00000800)); + isa.avx512vnni = avx512_regs && !!(structured_feature_info0.ecx & UINT32_C(0x00000800)); /* * AVX512_4VNNIW instructions: - * - Intel: edx[bit 2] in structured feature info. + * - Intel: edx[bit 2] in structured feature info (ecx = 0). */ - isa.avx512_4vnniw = avx512_regs && !!(structured_feature_info.edx & UINT32_C(0x00000004)); + isa.avx512_4vnniw = avx512_regs && !!(structured_feature_info0.edx & UINT32_C(0x00000004)); /* * AVX512_4FMAPS instructions: - * - Intel: edx[bit 3] in structured feature info. + * - Intel: edx[bit 3] in structured feature info (ecx = 0). */ - isa.avx512_4fmaps = avx512_regs && !!(structured_feature_info.edx & UINT32_C(0x00000008)); + isa.avx512_4fmaps = avx512_regs && !!(structured_feature_info0.edx & UINT32_C(0x00000008)); + + /* + * AVX512_VP2INTERSECT instructions: + * - Intel: edx[bit 8] in structured feature info (ecx = 0). + */ + isa.avx512vp2intersect = avx512_regs && !!(structured_feature_info0.edx & UINT32_C(0x00000100)); + + /* + * AVX512_BF16 instructions: + * - Intel: eax[bit 5] in structured feature info (ecx = 1). + */ + isa.avx512bf16 = avx512_regs && !!(structured_feature_info1.eax & UINT32_C(0x00000020)); /* * HLE instructions: - * - Intel: ebx[bit 4] in structured feature info. + * - Intel: ebx[bit 4] in structured feature info (ecx = 0). */ - isa.hle = !!(structured_feature_info.ebx & UINT32_C(0x00000010)); + isa.hle = !!(structured_feature_info0.ebx & UINT32_C(0x00000010)); /* * RTM instructions: - * - Intel: ebx[bit 11] in structured feature info. + * - Intel: ebx[bit 11] in structured feature info (ecx = 0). */ - isa.rtm = !!(structured_feature_info.ebx & UINT32_C(0x00000800)); + isa.rtm = !!(structured_feature_info0.ebx & UINT32_C(0x00000800)); /* * XTEST instruction: @@ -500,9 +514,9 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( /* * MPX registers and instructions: - * - Intel: ebx[bit 14] in structured feature info. + * - Intel: ebx[bit 14] in structured feature info (ecx = 0). */ - isa.mpx = mpx_regs && !!(structured_feature_info.ebx & UINT32_C(0x00004000)); + isa.mpx = mpx_regs && !!(structured_feature_info0.ebx & UINT32_C(0x00004000)); #if CPUINFO_ARCH_X86 /* @@ -528,9 +542,9 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( /* * CLWB instruction: - * - Intel: ebx[bit 24] in structured feature info. + * - Intel: ebx[bit 24] in structured feature info (ecx = 0). */ - isa.clwb = !!(structured_feature_info.ebx & UINT32_C(0x01000000)); + isa.clwb = !!(structured_feature_info0.ebx & UINT32_C(0x01000000)); /* * MOVBE instruction: @@ -549,9 +563,9 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( /* * RDFSBASE/RDGSBASE/WRFSBASE/WRGSBASE instructions. - * - Intel: ebx[bit 0] in structured feature info. + * - Intel: ebx[bit 0] in structured feature info (ecx = 0). */ - isa.fs_gs_base = !!(structured_feature_info.ebx & UINT32_C(0x00000001)); + isa.fs_gs_base = !!(structured_feature_info0.ebx & UINT32_C(0x00000001)); /* * LZCNT instruction: @@ -573,21 +587,21 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( /* * BMI instructions: - * - Intel, AMD: ebx[bit 3] in structured feature info. + * - Intel, AMD: ebx[bit 3] in structured feature info (ecx = 0). */ - isa.bmi = !!(structured_feature_info.ebx & UINT32_C(0x00000008)); + isa.bmi = !!(structured_feature_info0.ebx & UINT32_C(0x00000008)); /* * BMI2 instructions: - * - Intel: ebx[bit 8] in structured feature info. + * - Intel: ebx[bit 8] in structured feature info (ecx = 0). */ - isa.bmi2 = !!(structured_feature_info.ebx & UINT32_C(0x00000100)); + isa.bmi2 = !!(structured_feature_info0.ebx & UINT32_C(0x00000100)); /* * ADCX/ADOX instructions: - * - Intel: ebx[bit 19] in structured feature info. + * - Intel: ebx[bit 19] in structured feature info (ecx = 0). */ - isa.adx = !!(structured_feature_info.ebx & UINT32_C(0x00080000)); + isa.adx = !!(structured_feature_info0.ebx & UINT32_C(0x00080000)); /* * AES instructions: @@ -597,9 +611,9 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( /* * VAES instructions: - * - Intel: ecx[bit 9] in structured feature info. + * - Intel: ecx[bit 9] in structured feature info (ecx = 0). */ - isa.vaes = !!(structured_feature_info.ecx & UINT32_C(0x00000200)); + isa.vaes = !!(structured_feature_info0.ecx & UINT32_C(0x00000200)); /* * PCLMULQDQ instruction: @@ -609,15 +623,15 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( /* * VPCLMULQDQ instruction: - * - Intel: ecx[bit 10] in structured feature info. + * - Intel: ecx[bit 10] in structured feature info (ecx = 0). */ - isa.vpclmulqdq = !!(structured_feature_info.ecx & UINT32_C(0x00000400)); + isa.vpclmulqdq = !!(structured_feature_info0.ecx & UINT32_C(0x00000400)); /* * GFNI instructions: - * - Intel: ecx[bit 8] in structured feature info. + * - Intel: ecx[bit 8] in structured feature info (ecx = 0). */ - isa.gfni = !!(structured_feature_info.ecx & UINT32_C(0x00000100)); + isa.gfni = !!(structured_feature_info0.ecx & UINT32_C(0x00000100)); /* * RDRAND instruction: @@ -627,15 +641,15 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( /* * RDSEED instruction: - * - Intel: ebx[bit 18] in structured feature info. + * - Intel: ebx[bit 18] in structured feature info (ecx = 0). */ - isa.rdseed = !!(structured_feature_info.ebx & UINT32_C(0x00040000)); + isa.rdseed = !!(structured_feature_info0.ebx & UINT32_C(0x00040000)); /* * SHA instructions: - * - Intel: ebx[bit 29] in structured feature info. + * - Intel: ebx[bit 29] in structured feature info (ecx = 0). */ - isa.sha = !!(structured_feature_info.ebx & UINT32_C(0x20000000)); + isa.sha = !!(structured_feature_info0.ebx & UINT32_C(0x20000000)); if (vendor == cpuinfo_vendor_via) { const struct cpuid_regs padlock_meta_info = cpuid(UINT32_C(0xC0000000)); @@ -700,9 +714,9 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( /* * RDPID instruction: - * - Intel: ecx[bit 22] in structured feature info. + * - Intel: ecx[bit 22] in structured feature info (ecx = 0). */ - isa.rdpid = !!(structured_feature_info.ecx & UINT32_C(0x00400000)); + isa.rdpid = !!(structured_feature_info0.ecx & UINT32_C(0x00400000)); return isa; } diff --git a/src/x86/linux/init.c b/src/x86/linux/init.c index b5f74d0..c096336 100644 --- a/src/x86/linux/init.c +++ b/src/x86/linux/init.c @@ -592,6 +592,8 @@ void cpuinfo_x86_linux_init(void) { cpuinfo_cache_count[cpuinfo_cache_level_3] = l3_count; cpuinfo_cache_count[cpuinfo_cache_level_4] = l4_count; + cpuinfo_max_cache_size = cpuinfo_compute_max_cache_size(&processors[0]); + __sync_synchronize(); cpuinfo_is_initialized = true; diff --git a/src/x86/mach/init.c b/src/x86/mach/init.c index 7b41ad0..ae2be33 100644 --- a/src/x86/mach/init.c +++ b/src/x86/mach/init.c @@ -327,6 +327,8 @@ void cpuinfo_x86_mach_init(void) { cpuinfo_clusters_count = mach_topology.packages; cpuinfo_packages_count = mach_topology.packages; + cpuinfo_max_cache_size = cpuinfo_compute_max_cache_size(&processors[0]); + __sync_synchronize(); cpuinfo_is_initialized = true; diff --git a/src/x86/uarch.c b/src/x86/uarch.c index 71c899e..ba72d8a 100644 --- a/src/x86/uarch.c +++ b/src/x86/uarch.c @@ -74,13 +74,19 @@ enum cpuinfo_uarch cpuinfo_x86_decode_uarch( case 0x4F: // Broadwell-E case 0x56: // Broadwell-DE return cpuinfo_uarch_broadwell; - case 0x4E: // Skylake-U/Y - case 0x55: // Skylake Server (SKX) - case 0x5E: // Skylake-H/S + case 0x4E: // Sky Lake Client Y/U + case 0x55: // Sky/Cascade/Cooper Lake Server + case 0x5E: // Sky Lake Client DT/H/S + case 0x8E: // Kaby/Whiskey/Amber/Comet Lake Y/U + case 0x9E: // Kaby/Coffee Lake DT/H/S return cpuinfo_uarch_sky_lake; - case 0x8E: // Kaby Lake U/Y - case 0x9E: // Kaby Lake H/S - return cpuinfo_uarch_kaby_lake; + case 0x66: // Cannon Lake (Core i3-8121U) + return cpuinfo_uarch_palm_cove; + case 0x6A: // Ice Lake-DE + case 0x6C: // Ice Lake-SP + case 0x7D: // Ice Lake-Y + case 0x7E: // Ice Lake-U + return cpuinfo_uarch_sunny_cove; /* Low-power cores */ case 0x1C: // Diamondville, Silverthorne, Pineview @@ -90,18 +96,20 @@ enum cpuinfo_uarch cpuinfo_x86_decode_uarch( case 0x35: // Cloverview case 0x36: // Cedarview, Centerton return cpuinfo_uarch_saltwell; - case 0x37: - case 0x4A: - case 0x4D: + case 0x37: // Bay Trail + case 0x4A: // Merrifield + case 0x4D: // Avoton, Rangeley case 0x5A: // Moorefield case 0x5D: // SoFIA return cpuinfo_uarch_silvermont; - case 0x4C: // Braswell - case 0x5F: // Denverton + case 0x4C: // Braswell, Cherry Trail case 0x75: // Spreadtrum SC9853I-IA - case 0x7A: // Goldmont+ return cpuinfo_uarch_airmont; - + case 0x5C: // Apollo Lake + case 0x5F: // Denverton + return cpuinfo_uarch_goldmont; + case 0x7A: // Gemini Lake + return cpuinfo_uarch_goldmont_plus; /* Knights-series cores */ case 0x57: return cpuinfo_uarch_knights_landing; @@ -190,7 +198,15 @@ enum cpuinfo_uarch cpuinfo_x86_decode_uarch( return cpuinfo_uarch_jaguar; } case 0x17: - return cpuinfo_uarch_zen; + switch (model_info->model) { + case 0x01: // 14 nm Naples, Whitehaven, Summit Ridge, Snowy Owl + case 0x08: // 12 nm Pinnacle Ridge + case 0x11: // 14 nm Raven Ridge + case 0x18: // 12 nm Picasso + return cpuinfo_uarch_zen; + case 0x71: // Matisse + return cpuinfo_uarch_zen2; + } } break; default: diff --git a/src/x86/windows/init.c b/src/x86/windows/init.c index eb3498a..7a2090e 100644 --- a/src/x86/windows/init.c +++ b/src/x86/windows/init.c @@ -571,6 +571,8 @@ BOOL CALLBACK cpuinfo_x86_windows_init(PINIT_ONCE init_once, PVOID parameter, PV cpuinfo_clusters_count = packages_count; cpuinfo_packages_count = packages_count; + cpuinfo_max_cache_size = cpuinfo_compute_max_cache_size(&processors[0]); + MemoryBarrier(); cpuinfo_is_initialized = true; diff --git a/tools/cache-info.c b/tools/cache-info.c index ba0706f..05f69ee 100644 --- a/tools/cache-info.c +++ b/tools/cache-info.c @@ -60,6 +60,8 @@ int main(int argc, char** argv) { fprintf(stderr, "failed to initialize CPU information\n"); exit(EXIT_FAILURE); } + printf("Max cache size (upper bound): %"PRIu32" bytes\n", cpuinfo_get_max_cache_size()); + if (cpuinfo_get_l1i_caches_count() != 0 && (cpuinfo_get_l1i_cache(0)->flags & CPUINFO_CACHE_UNIFIED) == 0) { report_cache(cpuinfo_get_l1i_caches_count(), cpuinfo_get_l1i_cache(0), 1, "instruction"); } diff --git a/tools/cpu-info.c b/tools/cpu-info.c index caef424..7fa5187 100644 --- a/tools/cpu-info.c +++ b/tools/cpu-info.c @@ -73,8 +73,10 @@ static const char* uarch_to_string(enum cpuinfo_uarch uarch) { return "Broadwell"; case cpuinfo_uarch_sky_lake: return "Sky Lake"; - case cpuinfo_uarch_kaby_lake: - return "Kaby Lake"; + case cpuinfo_uarch_palm_cove: + return "Palm Cove"; + case cpuinfo_uarch_sunny_cove: + return "Sunny Cove"; case cpuinfo_uarch_willamette: return "Willamette"; case cpuinfo_uarch_prescott: @@ -87,6 +89,10 @@ static const char* uarch_to_string(enum cpuinfo_uarch uarch) { return "Silvermont"; case cpuinfo_uarch_airmont: return "Airmont"; + case cpuinfo_uarch_goldmont: + return "Goldmont"; + case cpuinfo_uarch_goldmont_plus: + return "Goldmont Plus"; case cpuinfo_uarch_knights_ferry: return "Knights Ferry"; case cpuinfo_uarch_knights_corner: @@ -117,6 +123,8 @@ static const char* uarch_to_string(enum cpuinfo_uarch uarch) { return "Excavator"; case cpuinfo_uarch_zen: return "Zen"; + case cpuinfo_uarch_zen2: + return "Zen 2"; case cpuinfo_uarch_geode: return "Geode"; case cpuinfo_uarch_bobcat: @@ -157,6 +165,8 @@ static const char* uarch_to_string(enum cpuinfo_uarch uarch) { return "Cortex-A55"; case cpuinfo_uarch_cortex_a57: return "Cortex-A57"; + case cpuinfo_uarch_cortex_a65: + return "Cortex-A65"; case cpuinfo_uarch_cortex_a72: return "Cortex-A72"; case cpuinfo_uarch_cortex_a73: @@ -165,6 +175,10 @@ static const char* uarch_to_string(enum cpuinfo_uarch uarch) { return "Cortex-A75"; case cpuinfo_uarch_cortex_a76: return "Cortex-A76"; + case cpuinfo_uarch_cortex_a76ae: + return "Cortex-A76AE"; + case cpuinfo_uarch_cortex_a77: + return "Cortex-A77"; case cpuinfo_uarch_scorpion: return "Scorpion"; case cpuinfo_uarch_krait: @@ -181,12 +195,16 @@ static const char* uarch_to_string(enum cpuinfo_uarch uarch) { return "Denver 2"; case cpuinfo_uarch_carmel: return "Carmel"; - case cpuinfo_uarch_mongoose_m1: - return "Mongoose M1"; - case cpuinfo_uarch_mongoose_m2: - return "Mongoose M2"; - case cpuinfo_uarch_meerkat_m3: - return "Meerkat M3"; + case cpuinfo_uarch_exynos_m1: + return "Exynos M1"; + case cpuinfo_uarch_exynos_m2: + return "Exynos M2"; + case cpuinfo_uarch_exynos_m3: + return "Exynos M3"; + case cpuinfo_uarch_exynos_m4: + return "Exynos M4"; + case cpuinfo_uarch_exynos_m5: + return "Exynos M5"; case cpuinfo_uarch_swift: return "Swift"; case cpuinfo_uarch_cyclone: @@ -258,13 +276,23 @@ int main(int argc, char** argv) { printf(", %s %s\n", vendor_string, uarch_string); } } - printf("Logical processors:\n"); + printf("Logical processors"); + #if defined(__linux__) + printf(" (System ID)"); + #endif + printf(":\n"); for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { const struct cpuinfo_processor* processor = cpuinfo_get_processor(i); + printf("\t%"PRIu32"", i); + + #if defined(__linux__) + printf(" (%"PRId32")", processor->linux_id); + #endif + #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 - printf("\t%"PRIu32": APIC ID 0x%08"PRIx32"\n", i, processor->apic_id); + printf(": APIC ID 0x%08"PRIx32"\n", processor->apic_id); #else - printf("\t%"PRIu32"\n", i); + printf("\n"); #endif } } diff --git a/tools/isa-info.c b/tools/isa-info.c index 594c46a..98ef919 100644 --- a/tools/isa-info.c +++ b/tools/isa-info.c @@ -67,6 +67,8 @@ int main(int argc, char** argv) { printf("\tAVX512BITALG: %s\n", cpuinfo_has_x86_avx512bitalg() ? "yes" : "no"); printf("\tAVX512VPOPCNTDQ: %s\n", cpuinfo_has_x86_avx512vpopcntdq() ? "yes" : "no"); printf("\tAVX512VNNI: %s\n", cpuinfo_has_x86_avx512vnni() ? "yes" : "no"); + printf("\tAVX512BF16: %s\n", cpuinfo_has_x86_avx512bf16() ? "yes" : "no"); + printf("\tAVX512VP2INTERSECT: %s\n", cpuinfo_has_x86_avx512vp2intersect() ? "yes" : "no"); printf("\tAVX512_4VNNIW: %s\n", cpuinfo_has_x86_avx512_4vnniw() ? "yes" : "no"); printf("\tAVX512_4FMAPS: %s\n", cpuinfo_has_x86_avx512_4fmaps() ? "yes" : "no"); |