#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "config.h" #include #if USE_EMBEDDED_COMPILER # include #endif namespace DB { namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; extern const int LOGICAL_ERROR; } template struct UnaryOperationImpl { using ResultType = typename Op::ResultType; using ColVecA = ColumnVectorOrDecimal; using ColVecC = ColumnVectorOrDecimal; using ArrayA = typename ColVecA::Container; using ArrayC = typename ColVecC::Container; MULTITARGET_FUNCTION_AVX512BW_AVX512F_AVX2_SSE42( MULTITARGET_FUNCTION_HEADER(static void NO_INLINE), vectorImpl, MULTITARGET_FUNCTION_BODY((const ArrayA & a, ArrayC & c) /// NOLINT { size_t size = a.size(); for (size_t i = 0; i < size; ++i) c[i] = Op::apply(a[i]); })) static void NO_INLINE vector(const ArrayA & a, ArrayC & c) { #if USE_MULTITARGET_CODE if (isArchSupported(TargetArch::AVX512BW)) { vectorImplAVX512BW(a, c); return; } if (isArchSupported(TargetArch::AVX512F)) { vectorImplAVX512F(a, c); return; } if (isArchSupported(TargetArch::AVX2)) { vectorImplAVX2(a, c); return; } if (isArchSupported(TargetArch::SSE42)) { vectorImplSSE42(a, c); return; } #endif vectorImpl(a, c); } static void constant(A a, ResultType & c) { c = Op::apply(a); } }; template struct FixedStringUnaryOperationImpl { MULTITARGET_FUNCTION_AVX512BW_AVX512F_AVX2_SSE42( MULTITARGET_FUNCTION_HEADER(static void NO_INLINE), vectorImpl, MULTITARGET_FUNCTION_BODY((const ColumnFixedString::Chars & a, /// NOLINT ColumnFixedString::Chars & c) { size_t size = a.size(); for (size_t i = 0; i < size; ++i) c[i] = Op::apply(a[i]); })) static void NO_INLINE vector(const ColumnFixedString::Chars & a, ColumnFixedString::Chars & c) { #if USE_MULTITARGET_CODE if (isArchSupported(TargetArch::AVX512BW)) { vectorImplAVX512BW(a, c); return; } if (isArchSupported(TargetArch::AVX512F)) { vectorImplAVX512F(a, c); return; } if (isArchSupported(TargetArch::AVX2)) { vectorImplAVX2(a, c); return; } if (isArchSupported(TargetArch::SSE42)) { vectorImplSSE42(a, c); return; } #endif vectorImpl(a, c); } }; template struct StringUnaryOperationReduceImpl { MULTITARGET_FUNCTION_AVX512BW_AVX512F_AVX2_SSE42( MULTITARGET_FUNCTION_HEADER(static UInt64 NO_INLINE), vectorImpl, MULTITARGET_FUNCTION_BODY((const UInt8 * start, const UInt8 * end) /// NOLINT { UInt64 res = 0; while (start < end) res += Op::apply(*start++); return res; })) static UInt64 NO_INLINE vector(const UInt8 * start, const UInt8 * end) { #if USE_MULTITARGET_CODE if (isArchSupported(TargetArch::AVX512BW)) { return vectorImplAVX512BW(start, end); } if (isArchSupported(TargetArch::AVX512F)) { return vectorImplAVX512F(start, end); } if (isArchSupported(TargetArch::AVX2)) { return vectorImplAVX2(start, end); } if (isArchSupported(TargetArch::SSE42)) { return vectorImplSSE42(start, end); } #endif return vectorImpl(start, end); } }; template struct FunctionUnaryArithmeticMonotonicity; /// Used to indicate undefined operation struct InvalidType; template