This commit is contained in:
Robert Schulze 2023-11-16 15:17:19 +00:00
parent dd626d51cb
commit fcce5409f4
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A
4 changed files with 29 additions and 33 deletions

View File

@ -134,60 +134,60 @@ elseif (ARCH_AMD64)
# ClickHouse can be cross-compiled (e.g. on an ARM host for x86) but it is also possible to build ClickHouse on x86 w/o AVX for x86 w/ # ClickHouse can be cross-compiled (e.g. on an ARM host for x86) but it is also possible to build ClickHouse on x86 w/o AVX for x86 w/
# AVX. We only assume that the compiler can emit certain SIMD instructions, we don't care if the host system is able to run the binary. # AVX. We only assume that the compiler can emit certain SIMD instructions, we don't care if the host system is able to run the binary.
SET (HAVE_SSSE3 1) if (ENABLE_SSSE3)
SET (HAVE_SSE41 1)
SET (HAVE_SSE42 1)
SET (HAVE_PCLMULQDQ 1)
SET (HAVE_POPCNT 1)
SET (HAVE_AVX 1)
SET (HAVE_AVX2 1)
SET (HAVE_AVX512 1)
SET (HAVE_AVX512_VBMI 1)
SET (HAVE_BMI 1)
SET (HAVE_BMI2 1)
if (HAVE_SSSE3 AND ENABLE_SSSE3)
set (COMPILER_FLAGS "${COMPILER_FLAGS} -mssse3") set (COMPILER_FLAGS "${COMPILER_FLAGS} -mssse3")
endif () endif ()
if (HAVE_SSE41 AND ENABLE_SSE41)
if (ENABLE_SSE41)
set (COMPILER_FLAGS "${COMPILER_FLAGS} -msse4.1") set (COMPILER_FLAGS "${COMPILER_FLAGS} -msse4.1")
endif () endif ()
if (HAVE_SSE42 AND ENABLE_SSE42)
if (ENABLE_SSE42)
set (COMPILER_FLAGS "${COMPILER_FLAGS} -msse4.2") set (COMPILER_FLAGS "${COMPILER_FLAGS} -msse4.2")
endif () endif ()
if (HAVE_PCLMULQDQ AND ENABLE_PCLMULQDQ)
if (ENABLE_PCLMULQDQ)
set (COMPILER_FLAGS "${COMPILER_FLAGS} -mpclmul") set (COMPILER_FLAGS "${COMPILER_FLAGS} -mpclmul")
endif () endif ()
if (HAVE_POPCNT AND ENABLE_POPCNT)
if (ENABLE_POPCNT)
set (COMPILER_FLAGS "${COMPILER_FLAGS} -mpopcnt") set (COMPILER_FLAGS "${COMPILER_FLAGS} -mpopcnt")
endif () endif ()
if (HAVE_AVX AND ENABLE_AVX)
if (ENABLE_AVX)
set (COMPILER_FLAGS "${COMPILER_FLAGS} -mavx") set (COMPILER_FLAGS "${COMPILER_FLAGS} -mavx")
endif () endif ()
if (HAVE_AVX2 AND ENABLE_AVX2)
if (ENABLE_AVX2)
set (COMPILER_FLAGS "${COMPILER_FLAGS} -mavx2") set (COMPILER_FLAGS "${COMPILER_FLAGS} -mavx2")
endif () endif ()
if (HAVE_AVX512 AND ENABLE_AVX512)
if (ENABLE_AVX512)
set (COMPILER_FLAGS "${COMPILER_FLAGS} -mavx512f -mavx512bw -mavx512vl") set (COMPILER_FLAGS "${COMPILER_FLAGS} -mavx512f -mavx512bw -mavx512vl")
endif () endif ()
if (HAVE_AVX512 AND ENABLE_AVX512 AND HAVE_AVX512_VBMI AND ENABLE_AVX512_VBMI)
if (ENABLE_AVX512 AND ENABLE_AVX512_VBMI)
set (COMPILER_FLAGS "${COMPILER_FLAGS} -mavx512vbmi") set (COMPILER_FLAGS "${COMPILER_FLAGS} -mavx512vbmi")
endif () endif ()
if (HAVE_BMI AND ENABLE_BMI)
if (ENABLE_BMI)
set (COMPILER_FLAGS "${COMPILER_FLAGS} -mbmi") set (COMPILER_FLAGS "${COMPILER_FLAGS} -mbmi")
endif () endif ()
if (HAVE_BMI2 AND HAVE_AVX2 AND ENABLE_AVX2 AND ENABLE_BMI2)
if (ENABLE_AVX2 AND ENABLE_BMI2)
set (COMPILER_FLAGS "${COMPILER_FLAGS} -mbmi2") set (COMPILER_FLAGS "${COMPILER_FLAGS} -mbmi2")
endif () endif ()
if (ENABLE_AVX512_FOR_SPEC_OP) if (ENABLE_AVX512_FOR_SPEC_OP)
set (X86_INTRINSICS_FLAGS "") set (X86_INTRINSICS_FLAGS "")
if (HAVE_BMI) if (1)
set (X86_INTRINSICS_FLAGS "${X86_INTRINSICS_FLAGS} -mbmi") set (X86_INTRINSICS_FLAGS "${X86_INTRINSICS_FLAGS} -mbmi")
endif () endif ()
if (HAVE_AVX512) if (1)
set (X86_INTRINSICS_FLAGS "${X86_INTRINSICS_FLAGS} -mavx512f -mavx512bw -mavx512vl -mprefer-vector-width=256") set (X86_INTRINSICS_FLAGS "${X86_INTRINSICS_FLAGS} -mavx512f -mavx512bw -mavx512vl -mprefer-vector-width=256")
endif () endif ()
endif () endif ()
else () else ()
# RISC-V + exotic platforms # RISC-V + exotic platforms
endif () endif ()

View File

@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0. # SPDX-License-Identifier: Apache-2.0.
if (USE_CPU_EXTENSIONS) if (USE_CPU_EXTENSIONS)
if (HAVE_AVX2) if (ENABLE_AVX2)
set (AVX2_CFLAGS "-mavx -mavx2") set (AVX2_CFLAGS "-mavx -mavx2")
set (HAVE_AVX2_INTRINSICS 1) set (HAVE_AVX2_INTRINSICS 1)
set (HAVE_MM256_EXTRACT_EPI64 1) set (HAVE_MM256_EXTRACT_EPI64 1)

View File

@ -13,12 +13,10 @@ set(LIBRARY_DIR "${ClickHouse_SOURCE_DIR}/contrib/fastops")
set(SRCS "") set(SRCS "")
if(HAVE_AVX) if(ARCH_AMD64)
set (SRCS ${SRCS} "${LIBRARY_DIR}/fastops/avx/ops_avx.cpp") set (SRCS ${SRCS} "${LIBRARY_DIR}/fastops/avx/ops_avx.cpp")
set_source_files_properties("${LIBRARY_DIR}/fastops/avx/ops_avx.cpp" PROPERTIES COMPILE_FLAGS "-mavx -DNO_AVX2") set_source_files_properties("${LIBRARY_DIR}/fastops/avx/ops_avx.cpp" PROPERTIES COMPILE_FLAGS "-mavx -DNO_AVX2")
endif()
if(HAVE_AVX2)
set (SRCS ${SRCS} "${LIBRARY_DIR}/fastops/avx2/ops_avx2.cpp") set (SRCS ${SRCS} "${LIBRARY_DIR}/fastops/avx2/ops_avx2.cpp")
set_source_files_properties("${LIBRARY_DIR}/fastops/avx2/ops_avx2.cpp" PROPERTIES COMPILE_FLAGS "-mavx2 -mfma") set_source_files_properties("${LIBRARY_DIR}/fastops/avx2/ops_avx2.cpp" PROPERTIES COMPILE_FLAGS "-mavx2 -mfma")
endif() endif()

View File

@ -93,11 +93,9 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64|arm64|ARM64")
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64|arm64|ARM64") endif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64|arm64|ARM64")
if(HAVE_SSE42) if(ENABLE_AVX2 AND ENABLE_PCLMULQDQ)
add_definitions(-DHAVE_SSE42) add_definitions(-DHAVE_SSE42)
add_definitions(-DHAVE_PCLMUL) add_definitions(-DHAVE_PCLMUL)
elseif(FORCE_SSE42)
message(FATAL_ERROR "FORCE_SSE42=ON but unable to compile with SSE4.2 enabled")
endif() endif()
set (HAVE_THREAD_LOCAL 1) set (HAVE_THREAD_LOCAL 1)
@ -429,7 +427,7 @@ set(SOURCES
${ROCKSDB_SOURCE_DIR}/utilities/transactions/lock/range/range_tree/lib/util/memarena.cc ${ROCKSDB_SOURCE_DIR}/utilities/transactions/lock/range/range_tree/lib/util/memarena.cc
rocksdb_build_version.cc) rocksdb_build_version.cc)
if(HAVE_SSE42) if(ENABLE_SSE42 AND ENABLE_PCLMULQDQ)
set_source_files_properties( set_source_files_properties(
"${ROCKSDB_SOURCE_DIR}/util/crc32c.cc" "${ROCKSDB_SOURCE_DIR}/util/crc32c.cc"
PROPERTIES COMPILE_FLAGS "-msse4.2 -mpclmul") PROPERTIES COMPILE_FLAGS "-msse4.2 -mpclmul")