You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
support_max_min
This commit is contained in:
@ -41,6 +41,7 @@ using namespace boost;
|
||||
#include "dataconvert.h"
|
||||
#include "mcs_decimal.h"
|
||||
#include "simd_sse.h"
|
||||
#include "simd_arm.h"
|
||||
#include "utils/common/columnwidth.h"
|
||||
|
||||
#include "exceptclasses.h"
|
||||
@ -118,24 +119,6 @@ inline int compareBlock(const void* a, const void* b)
|
||||
return ((*(T*)a) - (*(T*)b));
|
||||
}
|
||||
|
||||
template <class To, class From>
|
||||
std::enable_if_t<
|
||||
sizeof(To) == sizeof(From) &&
|
||||
std::is_trivially_copyable_v<From> &&
|
||||
std::is_trivially_copyable_v<To>,
|
||||
To>
|
||||
// constexpr support needs compiler magic
|
||||
bitCast(const From& src) noexcept
|
||||
{
|
||||
static_assert(std::is_trivially_constructible_v<To>,
|
||||
"This implementation additionally requires "
|
||||
"destination type to be trivially constructible");
|
||||
|
||||
To dst;
|
||||
std::memcpy(&dst, &src, sizeof(To));
|
||||
return dst;
|
||||
}
|
||||
|
||||
// this function is out-of-band, we don't need to inline it
|
||||
void logIt(int mid, int arg1, const string& arg2 = string())
|
||||
{
|
||||
@ -942,7 +925,7 @@ inline void writeColValue(uint8_t OutputType, ColResultHeader* out, uint16_t rid
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__x86_64__)
|
||||
#if defined(__x86_64__) || defined(__aarch64__)
|
||||
template <typename T, ENUM_KIND KIND, bool HAS_INPUT_RIDS,
|
||||
typename std::enable_if<HAS_INPUT_RIDS == false, T>::type* = nullptr>
|
||||
inline void vectUpdateMinMax(const bool validMinMax, const bool isNonNullOrEmpty, T& Min, T& Max, T curValue,
|
||||
@ -1239,7 +1222,7 @@ void scalarFiltering(
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__x86_64__)
|
||||
#if defined(__x86_64__) || defined(__aarch64__)
|
||||
template <typename VT, typename SIMD_WRAPPER_TYPE, bool HAS_INPUT_RIDS, typename T,
|
||||
typename std::enable_if<HAS_INPUT_RIDS == false, T>::type* = nullptr>
|
||||
inline SIMD_WRAPPER_TYPE simdDataLoad(VT& processor, const T* srcArray, const T* origSrcArray,
|
||||
@ -1295,19 +1278,13 @@ inline SIMD_WRAPPER_TYPE simdSwapedOrderDataLoad(const ColRequestHeaderDataType
|
||||
}
|
||||
|
||||
template <typename VT, typename SimdType>
|
||||
void vectorizedUpdateMinMax(const bool validMinMax, const MT nonNullOrEmptyMask, VT simdProcessor,
|
||||
void vectorizedUpdateMinMax(const bool validMinMax, const MT nonNullOrEmptyMask, VT& simdProcessor,
|
||||
SimdType& dataVec, SimdType& simdMin, SimdType& simdMax)
|
||||
{
|
||||
if (validMinMax)
|
||||
if (validMinMax && nonNullOrEmptyMask)
|
||||
{
|
||||
simdMin = simdProcessor.blend(
|
||||
simdMin, dataVec,
|
||||
simdProcessor.bwAnd(simdProcessor.cmpGt2(simdMin, dataVec),
|
||||
bitCast<SimdType>(simd::bitMaskToByteMask16(nonNullOrEmptyMask))));
|
||||
simdMax = simdProcessor.blend(
|
||||
simdMax, dataVec,
|
||||
simdProcessor.bwAnd(simdProcessor.cmpGt2(dataVec, simdMax),
|
||||
bitCast<SimdType>(simd::bitMaskToByteMask16(nonNullOrEmptyMask))));
|
||||
simdMin = simdProcessor.min(simdMin, dataVec);
|
||||
simdMax = simdProcessor.max(simdMax, dataVec);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1328,7 +1305,7 @@ void scalarUpdateMinMax(const bool validMinMax, const MT nonNullOrEmptyMask, VT&
|
||||
}
|
||||
|
||||
template<typename T, typename VT, typename SimdType>
|
||||
void extractMinMax(VT& simdProcessor, SimdType simdMin, SimdType simdMax, T& min, T& max)
|
||||
void extractMinMax(VT& simdProcessor, SimdType& simdMin, SimdType& simdMax, T& min, T& max)
|
||||
{
|
||||
constexpr const uint16_t size = VT::vecByteSize / sizeof(T);
|
||||
T* simdMinVec = reinterpret_cast<T*>(&simdMin);
|
||||
@ -1336,13 +1313,6 @@ void extractMinMax(VT& simdProcessor, SimdType simdMin, SimdType simdMax, T& min
|
||||
max = *std::max_element(simdMaxVec, simdMaxVec + size);
|
||||
min = *std::min_element(simdMinVec, simdMinVec + size);
|
||||
}
|
||||
|
||||
template <typename T, typename VT, typename SimdType>
|
||||
void getInitialSimdMinMax(VT& simdProcessor, SimdType& simdMin, SimdType& simdMax, T min, T max)
|
||||
{
|
||||
simdMin = simdProcessor.loadValue(min);
|
||||
simdMax = simdProcessor.loadValue(max);
|
||||
}
|
||||
// This routine filters input block in a vectorized manner.
|
||||
// It supports all output types, all input types.
|
||||
// It doesn't support KIND==TEXT so upper layers filters this KIND out beforehand.
|
||||
@ -1478,12 +1448,9 @@ void vectorizedFiltering(NewColRequestHeader* in, ColResultHeader* out, const T*
|
||||
}
|
||||
}
|
||||
}
|
||||
[[maybe_unused]] SimdType simdMin;
|
||||
[[maybe_unused]] SimdType simdMax;
|
||||
if constexpr (KIND != KIND_TEXT)
|
||||
{
|
||||
getInitialSimdMinMax(simdProcessor, simdMin, simdMax, min, max);
|
||||
}
|
||||
[[maybe_unused]] SimdType simdMin = simdDataLoad<VT, SimdWrapperType, HAS_INPUT_RIDS, T>(simdProcessor, srcArray,
|
||||
origSrcArray, ridArray, 0).v;;
|
||||
[[maybe_unused]] SimdType simdMax = simdMin;
|
||||
// main loop
|
||||
// writeMask tells which values must get into the result. Includes values that matches filters. Can have
|
||||
// NULLs. nonEmptyMask tells which vector coords are not EMPTY magics. nonNullMask tells which vector coords
|
||||
@ -1704,7 +1671,7 @@ void filterColumnData(NewColRequestHeader* in, ColResultHeader* out, uint16_t* r
|
||||
// Syscat queries mustn't follow vectorized processing path b/c PP must return
|
||||
// all values w/o any filter(even empty values filter) applied.
|
||||
|
||||
#if defined(__x86_64__)
|
||||
#if defined(__x86_64__) || defined(__aarch64__)
|
||||
// Don't use vectorized filtering for text based data types.
|
||||
if (WIDTH < 16 &&
|
||||
(KIND != KIND_TEXT || (KIND == KIND_TEXT && in->colType.strnxfrmIsValid()) ))
|
||||
|
@ -22,37 +22,33 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "datatypes/mcs_datatype.h"
|
||||
#include "datatypes/mcs_int128.h"
|
||||
|
||||
#include "simd_sse.h"
|
||||
#include "simd_arm.h"
|
||||
#if defined(__x86_64__)
|
||||
#include "simd_sse.h"
|
||||
#define TESTS_USING_SSE 1
|
||||
using float64_t = double;
|
||||
using float32_t = float;
|
||||
#endif
|
||||
#ifdef __aarch64__
|
||||
#include "simd_arm.h"
|
||||
#define TESTS_USING_ARM 1
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <typename T>
|
||||
class SimdProcessorTypedTest : public testing::Test
|
||||
{
|
||||
public:
|
||||
class SimdProcessorTypedTest : public testing::Test {
|
||||
public:
|
||||
using IntegralType = T;
|
||||
#if TESTS_USING_SSE
|
||||
using SimdType =
|
||||
std::conditional_t<std::is_same<T, float>::value, simd::vi128f_wr,
|
||||
std::conditional_t<std::is_same<T, double>::value, simd::vi128d_wr, simd::vi128_wr>>;
|
||||
using Proc = typename simd::SimdFilterProcessor<SimdType, T>;
|
||||
#else
|
||||
using SimdType =
|
||||
std::conditional_t<std::is_same<T, float>::value, simd::vi128f_wr,
|
||||
std::conditional_t<std::is_same<T, double>::value, simd::vi128d_wr,
|
||||
typename simd::TypeToVecWrapperType<T>::WrapperType>>;
|
||||
using Proc = typename simd::SimdFilterProcessor<SimdType, T>;
|
||||
#endif
|
||||
#if TESTS_USING_SSE
|
||||
using SimdType = std::conditional_t<std::is_same<T, float>::value,
|
||||
simd::vi128f_wr,
|
||||
std::conditional_t<std::is_same<T, double>::value,
|
||||
simd::vi128d_wr,
|
||||
simd::vi128_wr>>;
|
||||
using Proc = typename simd::SimdFilterProcessor<SimdType, T>;
|
||||
#else
|
||||
using Proc = typename simd::SimdFilterProcessor<typename simd::TypeToVecWrapperType<T>::WrapperType, T>;
|
||||
#endif
|
||||
void SetUp() override
|
||||
{
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user