Add cmake option to enable or not AVX2 instructions

This commit is contained in:
youenn lebras 2021-10-26 10:43:23 +02:00
parent 2a2eb3a27b
commit 72fb56904d
No known key found for this signature in database
GPG Key ID: E1DF98A69CABD2A5
2 changed files with 6 additions and 4 deletions

View File

@ -1,4 +1,6 @@
include("${ClickHouse_SOURCE_DIR}/cmake/dbms_glob_sources.cmake")
option(ENABLE_AVX2 "Enable AVX2 instructions (when available) when build for modern Intel CPUs" OFF)
add_headers_and_sources(clickhouse_functions_gatherutils .)
add_library(clickhouse_functions_gatherutils ${clickhouse_functions_gatherutils_sources} ${clickhouse_functions_gatherutils_headers})
target_link_libraries(clickhouse_functions_gatherutils PRIVATE dbms)
@ -19,7 +21,7 @@ if (HAVE_SSE42)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
target_compile_options(clickhouse_functions_gatherutils PRIVATE -msse4.2)
endif()
if (HAVE_AVX2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2")
if (HAVE_AVX2 AND ENABLE_AVX2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2 -DENABLE_AVX2")
target_compile_options(clickhouse_functions_gatherutils PRIVATE -mavx2)
endif()

View File

@ -85,7 +85,7 @@ bool sliceHasImplAnyAll(const FirstSliceType & first, const SecondSliceType & se
}
#if defined(__AVX2__) || defined(__SSE4_2__)
#if (defined(__AVX2__) && defined(ENABLE_AVX2)) || defined(__SSE4_2__)
namespace
{
@ -127,7 +127,7 @@ inline ALWAYS_INLINE bool hasAllIntegralLoopRemainder(
#endif
#if defined(__AVX2__)
#if defined(__AVX2__) && defined(ENABLE_AVX2)
// TODO: Discuss about
// raise an error : "error: no viable conversion from 'const NumericArraySlice<unsigned int>' to 'const NumericArraySlice<int>'"