You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
support_max_min
This commit is contained in:
@ -41,6 +41,7 @@ using namespace boost;
|
|||||||
#include "dataconvert.h"
|
#include "dataconvert.h"
|
||||||
#include "mcs_decimal.h"
|
#include "mcs_decimal.h"
|
||||||
#include "simd_sse.h"
|
#include "simd_sse.h"
|
||||||
|
#include "simd_arm.h"
|
||||||
#include "utils/common/columnwidth.h"
|
#include "utils/common/columnwidth.h"
|
||||||
|
|
||||||
#include "exceptclasses.h"
|
#include "exceptclasses.h"
|
||||||
@ -118,24 +119,6 @@ inline int compareBlock(const void* a, const void* b)
|
|||||||
return ((*(T*)a) - (*(T*)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
|
// this function is out-of-band, we don't need to inline it
|
||||||
void logIt(int mid, int arg1, const string& arg2 = string())
|
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,
|
template <typename T, ENUM_KIND KIND, bool HAS_INPUT_RIDS,
|
||||||
typename std::enable_if<HAS_INPUT_RIDS == false, T>::type* = nullptr>
|
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,
|
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,
|
template <typename VT, typename SIMD_WRAPPER_TYPE, bool HAS_INPUT_RIDS, typename T,
|
||||||
typename std::enable_if<HAS_INPUT_RIDS == false, T>::type* = nullptr>
|
typename std::enable_if<HAS_INPUT_RIDS == false, T>::type* = nullptr>
|
||||||
inline SIMD_WRAPPER_TYPE simdDataLoad(VT& processor, const T* srcArray, const T* origSrcArray,
|
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>
|
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)
|
SimdType& dataVec, SimdType& simdMin, SimdType& simdMax)
|
||||||
{
|
{
|
||||||
if (validMinMax)
|
if (validMinMax && nonNullOrEmptyMask)
|
||||||
{
|
{
|
||||||
simdMin = simdProcessor.blend(
|
simdMin = simdProcessor.min(simdMin, dataVec);
|
||||||
simdMin, dataVec,
|
simdMax = simdProcessor.max(simdMax, 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))));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1328,7 +1305,7 @@ void scalarUpdateMinMax(const bool validMinMax, const MT nonNullOrEmptyMask, VT&
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename VT, typename SimdType>
|
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);
|
constexpr const uint16_t size = VT::vecByteSize / sizeof(T);
|
||||||
T* simdMinVec = reinterpret_cast<T*>(&simdMin);
|
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);
|
max = *std::max_element(simdMaxVec, simdMaxVec + size);
|
||||||
min = *std::min_element(simdMinVec, simdMinVec + 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.
|
// This routine filters input block in a vectorized manner.
|
||||||
// It supports all output types, all input types.
|
// It supports all output types, all input types.
|
||||||
// It doesn't support KIND==TEXT so upper layers filters this KIND out beforehand.
|
// 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 simdMin = simdDataLoad<VT, SimdWrapperType, HAS_INPUT_RIDS, T>(simdProcessor, srcArray,
|
||||||
[[maybe_unused]] SimdType simdMax;
|
origSrcArray, ridArray, 0).v;;
|
||||||
if constexpr (KIND != KIND_TEXT)
|
[[maybe_unused]] SimdType simdMax = simdMin;
|
||||||
{
|
|
||||||
getInitialSimdMinMax(simdProcessor, simdMin, simdMax, min, max);
|
|
||||||
}
|
|
||||||
// main loop
|
// main loop
|
||||||
// writeMask tells which values must get into the result. Includes values that matches filters. Can have
|
// 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
|
// 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
|
// Syscat queries mustn't follow vectorized processing path b/c PP must return
|
||||||
// all values w/o any filter(even empty values filter) applied.
|
// 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.
|
// Don't use vectorized filtering for text based data types.
|
||||||
if (WIDTH < 16 &&
|
if (WIDTH < 16 &&
|
||||||
(KIND != KIND_TEXT || (KIND == KIND_TEXT && in->colType.strnxfrmIsValid()) ))
|
(KIND != KIND_TEXT || (KIND == KIND_TEXT && in->colType.strnxfrmIsValid()) ))
|
||||||
|
@ -22,37 +22,33 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include "datatypes/mcs_datatype.h"
|
#include "datatypes/mcs_datatype.h"
|
||||||
#include "datatypes/mcs_int128.h"
|
#include "datatypes/mcs_int128.h"
|
||||||
|
#include "simd_sse.h"
|
||||||
|
#include "simd_arm.h"
|
||||||
#if defined(__x86_64__)
|
#if defined(__x86_64__)
|
||||||
#include "simd_sse.h"
|
|
||||||
#define TESTS_USING_SSE 1
|
#define TESTS_USING_SSE 1
|
||||||
using float64_t = double;
|
using float64_t = double;
|
||||||
using float32_t = float;
|
using float32_t = float;
|
||||||
#endif
|
#endif
|
||||||
#ifdef __aarch64__
|
#ifdef __aarch64__
|
||||||
#include "simd_arm.h"
|
|
||||||
#define TESTS_USING_ARM 1
|
#define TESTS_USING_ARM 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class SimdProcessorTypedTest : public testing::Test
|
class SimdProcessorTypedTest : public testing::Test {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
using IntegralType = T;
|
using IntegralType = T;
|
||||||
#if TESTS_USING_SSE
|
#if TESTS_USING_SSE
|
||||||
using SimdType =
|
using SimdType = std::conditional_t<std::is_same<T, float>::value,
|
||||||
std::conditional_t<std::is_same<T, float>::value, simd::vi128f_wr,
|
simd::vi128f_wr,
|
||||||
std::conditional_t<std::is_same<T, double>::value, simd::vi128d_wr, simd::vi128_wr>>;
|
std::conditional_t<std::is_same<T, double>::value,
|
||||||
using Proc = typename simd::SimdFilterProcessor<SimdType, T>;
|
simd::vi128d_wr,
|
||||||
#else
|
simd::vi128_wr>>;
|
||||||
using SimdType =
|
using Proc = typename simd::SimdFilterProcessor<SimdType, T>;
|
||||||
std::conditional_t<std::is_same<T, float>::value, simd::vi128f_wr,
|
#else
|
||||||
std::conditional_t<std::is_same<T, double>::value, simd::vi128d_wr,
|
using Proc = typename simd::SimdFilterProcessor<typename simd::TypeToVecWrapperType<T>::WrapperType, T>;
|
||||||
typename simd::TypeToVecWrapperType<T>::WrapperType>>;
|
#endif
|
||||||
using Proc = typename simd::SimdFilterProcessor<SimdType, T>;
|
|
||||||
#endif
|
|
||||||
void SetUp() override
|
void SetUp() override
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user