From 7f7e04117d1094240def5f34bb7e44d5f1ba8762 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 15 Apr 2021 01:27:53 +0300 Subject: [PATCH] Arcadia, ARM, PowerPC --- src/Functions/divide/CMakeLists.txt | 26 +++++++++++++++++++------- src/Functions/divide/divide.cpp | 4 ++++ src/Functions/divide/divideImpl.cpp | 6 +++++- src/Functions/ya.make | 2 ++ 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/Functions/divide/CMakeLists.txt b/src/Functions/divide/CMakeLists.txt index 2bdd7e4c5ef..e5a10f0817c 100644 --- a/src/Functions/divide/CMakeLists.txt +++ b/src/Functions/divide/CMakeLists.txt @@ -1,10 +1,22 @@ -add_library(divide_impl_sse2 divideImpl.cpp) -target_compile_options(divide_impl_sse2 PRIVATE -msse2 -DNAMESPACE=SSE2) -target_link_libraries(divide_impl_sse2 libdivide) +# A library for integer division by constant with CPU dispatching. -add_library(divide_impl_avx2 divideImpl.cpp) -target_compile_options(divide_impl_avx2 PRIVATE -mavx2 -DNAMESPACE=AVX2) -target_link_libraries(divide_impl_avx2 libdivide) +if (ARCH_AMD64) + add_library(divide_impl_sse2 divideImpl.cpp) + target_compile_options(divide_impl_sse2 PRIVATE -msse2 -DNAMESPACE=SSE2) + target_link_libraries(divide_impl_sse2 libdivide) + + add_library(divide_impl_avx2 divideImpl.cpp) + target_compile_options(divide_impl_avx2 PRIVATE -mavx2 -DNAMESPACE=AVX2) + target_link_libraries(divide_impl_avx2 libdivide) + + set(IMPLEMENTATIONS divide_impl_sse2 divide_impl_avx2) +else () + add_library(divide_impl_generic divideImpl.cpp) + target_compile_options(divide_impl_generic PRIVATE -DNAMESPACE=Generic) + target_link_libraries(divide_impl_generic libdivide) + + set(IMPLEMENTATIONS divide_impl_generic) +endif () add_library(divide_impl divide.cpp) -target_link_libraries(divide_impl divide_impl_sse2 divide_impl_avx2 clickhouse_common_io) +target_link_libraries(divide_impl ${IMPLEMENTATIONS} clickhouse_common_io) diff --git a/src/Functions/divide/divide.cpp b/src/Functions/divide/divide.cpp index 1c3c11af312..7676c2cb02b 100644 --- a/src/Functions/divide/divide.cpp +++ b/src/Functions/divide/divide.cpp @@ -18,10 +18,14 @@ namespace AVX2 template void divideImpl(const A * __restrict a_pos, B b, ResultType * __restrict c_pos, size_t size) { +#if defined(__x86_64__) && !defined(ARCADIA_BUILD) if (DB::Cpu::CpuFlagsCache::have_AVX2) AVX2::divideImpl(a_pos, b, c_pos, size); else if (DB::Cpu::CpuFlagsCache::have_SSE2) SSE2::divideImpl(a_pos, b, c_pos, size); +#else + Generic::divideImpl(a_pos, b, c_pos, size); +#endif } diff --git a/src/Functions/divide/divideImpl.cpp b/src/Functions/divide/divideImpl.cpp index a62ce8126e2..f4c1a97d3ad 100644 --- a/src/Functions/divide/divideImpl.cpp +++ b/src/Functions/divide/divideImpl.cpp @@ -2,7 +2,11 @@ /// with different values of NAMESPACE and machine flags (sse2, avx2). #if !defined(NAMESPACE) -#error "NAMESPACE macro must be defined" + #if defined(ARCADIA_BUILD) + #define NAMESPACE Generic + #else + #error "NAMESPACE macro must be defined" + #endif #endif #if defined(__AVX2__) diff --git a/src/Functions/ya.make b/src/Functions/ya.make index 52ed54ec64f..660f7b115bf 100644 --- a/src/Functions/ya.make +++ b/src/Functions/ya.make @@ -229,6 +229,8 @@ SRCS( defaultValueOfTypeName.cpp demange.cpp divide.cpp + divide/divide.cpp + divide/divideImpl.cpp dumpColumnStructure.cpp e.cpp empty.cpp