Commit b68104ab authored by Alexander Gerasiov's avatar Alexander Gerasiov

d/control: Use libcpuinfo only when avaible.

Signed-off-by: Alexander Gerasiov's avatarAlexander GQ Gerasiov <gq@cs.msu.su>
parent 2d3076dc
......@@ -16,7 +16,7 @@ Build-Depends: cmake,
libboost-thread-dev,
libcapnp-dev,
libcctz-dev,
libcpuinfo-dev,
libcpuinfo-dev [amd64 arm64],
libdouble-conversion-dev,
libfarmhash-dev,
libglib2.0-dev,
......
......@@ -9,12 +9,13 @@ needs to replace cpuid with cpuinfo in the "contrib" directory.
Signed-off-by: Alexander GQ Gerasiov <gq@cs.msu.su>
---
CMakeLists.txt | 2 +-
cmake/find_cpuid.cmake | 29 ---------------
cmake/find_cpuinfo.cmake | 14 ++++++++
contrib/CMakeLists.txt | 4 ---
dbms/CMakeLists.txt | 6 +---
dbms/src/Common/getNumberOfPhysicalCPUCores.cpp | 47 +++++--------------------
6 files changed, 25 insertions(+), 77 deletions(-)
cmake/find_cpuid.cmake | 29 -------------
cmake/find_cpuinfo.cmake | 16 ++++++++
contrib/CMakeLists.txt | 4 --
dbms/CMakeLists.txt | 13 +++---
dbms/src/Common/config.h.in | 1 +
dbms/src/Common/getNumberOfPhysicalCPUCores.cpp | 54 ++++++++-----------------
7 files changed, 43 insertions(+), 76 deletions(-)
delete mode 100644 cmake/find_cpuid.cmake
create mode 100644 cmake/find_cpuinfo.cmake
......@@ -68,10 +69,10 @@ index cda8843..0000000
-message (STATUS "Using cpuid: ${CPUID_INCLUDE_DIR} : ${CPUID_LIBRARY}")
diff --git a/cmake/find_cpuinfo.cmake b/cmake/find_cpuinfo.cmake
new file mode 100644
index 0000000..f0cdfd6
index 0000000..959119f
--- /dev/null
+++ b/cmake/find_cpuinfo.cmake
@@ -0,0 +1,14 @@
@@ -0,0 +1,16 @@
+if (NOT ARCH_ARM)
+ option (USE_INTERNAL_CPUINFO_LIBRARY "Set to FALSE to use system cpuinfo library instead of bundled" ${NOT_UNBUNDLED})
+endif ()
......@@ -79,10 +80,12 @@ index 0000000..f0cdfd6
+if (NOT USE_INTERNAL_CPUINFO_LIBRARY)
+ find_library (CPUINFO_LIBRARY cpuinfo)
+ find_path (CPUINFO_INCLUDE_DIR NAMES cpuinfo.h PATHS ${CPUINFO_INCLUDE_PATHS})
+elseif (NOT MISSING_INTERNAL_CPUINFO_LIBRARY)
+ set (CPUINFO_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/libcpuinfo/include)
+ set (USE_INTERNAL_CPUINFO_LIBRARY 1)
+ set (CPUINFO_LIBRARY cpuinfo)
+endif ()
+
+if (CPUINFO_LIBRARY)
+ set(USE_CPUINFO 1)
+else()
+ set(USE_CPUINFO 0)
+endif ()
+
+message (STATUS "Using cpuinfo: ${CPUINFO_INCLUDE_DIR} : ${CPUINFO_LIBRARY}")
......@@ -102,10 +105,10 @@ index ab453b9..8941e96 100644
if (NOT MAKE_STATIC_LIBRARIES)
set (BUILD_SHARED 1)
diff --git a/dbms/CMakeLists.txt b/dbms/CMakeLists.txt
index b7f1173..a82a0c4 100644
index b7f1173..0e4a36a 100644
--- a/dbms/CMakeLists.txt
+++ b/dbms/CMakeLists.txt
@@ -142,17 +142,13 @@ if (CMAKE_BUILD_TYPE_UC STREQUAL "RELEASE" OR CMAKE_BUILD_TYPE_UC STREQUAL "RELW
@@ -142,17 +142,12 @@ if (CMAKE_BUILD_TYPE_UC STREQUAL "RELEASE" OR CMAKE_BUILD_TYPE_UC STREQUAL "RELW
PROPERTIES COMPILE_FLAGS -g0)
endif ()
......@@ -120,15 +123,38 @@ index b7f1173..a82a0c4 100644
string_utils
widechar_width
- ${LINK_LIBRARIES_ONLY_ON_X86_64}
+ ${CPUINFO_LIBRARY}
${LZ4_LIBRARY}
${ZSTD_LIBRARY}
${DOUBLE_CONVERSION_LIBRARIES}
@@ -175,6 +170,14 @@ target_link_libraries (clickhouse_common_io
${CMAKE_DL_LIBS}
)
+if (USE_CPUINFO)
+target_link_libraries (clickhouse_common_io
+ PRIVATE
+ ${CPUINFO_LIBRARY}
+)
+endif ()
+
+
target_link_libraries (dbms
PRIVATE
clickhouse_parsers
diff --git a/dbms/src/Common/config.h.in b/dbms/src/Common/config.h.in
index 302fc33..157a2d6 100644
--- a/dbms/src/Common/config.h.in
+++ b/dbms/src/Common/config.h.in
@@ -17,3 +17,4 @@
#cmakedefine01 CLICKHOUSE_SPLIT_BINARY
#cmakedefine01 USE_BASE64
#cmakedefine01 USE_HDFS
+#cmakedefine01 USE_CPUINFO
diff --git a/dbms/src/Common/getNumberOfPhysicalCPUCores.cpp b/dbms/src/Common/getNumberOfPhysicalCPUCores.cpp
index 0a686b9..ea274df 100644
index 0a686b9..9832574 100644
--- a/dbms/src/Common/getNumberOfPhysicalCPUCores.cpp
+++ b/dbms/src/Common/getNumberOfPhysicalCPUCores.cpp
@@ -1,45 +1,16 @@
@@ -1,45 +1,25 @@
#include <Common/getNumberOfPhysicalCPUCores.h>
#include <thread>
......@@ -140,7 +166,9 @@ index 0a686b9..ea274df 100644
- namespace DB { namespace ErrorCodes { extern const int CPUID_ERROR; }}
-
-#endif
-
+#include <Common/config.h>
+#if USE_CPUINFO
+#include <cpuinfo.h>
unsigned getNumberOfPhysicalCPUCores()
......@@ -183,3 +211,9 @@ index 0a686b9..ea274df 100644
+ else
+ return std::thread::hardware_concurrency();
}
+#else
+unsigned getNumberOfPhysicalCPUCores()
+{
+ return std::thread::hardware_concurrency();
+}
+#endif
......@@ -30,15 +30,14 @@ index 5c919b2..7f1869d 100644
set(PCG_RANDOM_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/libpcg-random/include)
+set(CITYHASH_CONTRIB_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/cityhash102/include)
diff --git a/dbms/CMakeLists.txt b/dbms/CMakeLists.txt
index a82a0c4..bae3f93 100644
index 0e4a36a..0cad596 100644
--- a/dbms/CMakeLists.txt
+++ b/dbms/CMakeLists.txt
@@ -148,12 +148,13 @@ target_link_libraries (clickhouse_common_io
@@ -148,11 +148,12 @@ target_link_libraries (clickhouse_common_io
PRIVATE
string_utils
widechar_width
+ PUBLIC
${CPUINFO_LIBRARY}
${LZ4_LIBRARY}
${ZSTD_LIBRARY}
${DOUBLE_CONVERSION_LIBRARIES}
......@@ -48,7 +47,7 @@ index a82a0c4..bae3f93 100644
${Poco_Net_LIBRARY}
${Poco_Util_LIBRARY}
${Poco_Foundation_LIBRARY}
@@ -173,14 +174,17 @@ target_link_libraries (clickhouse_common_io
@@ -180,14 +181,17 @@ endif ()
target_link_libraries (dbms
PRIVATE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment