aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Functions/VectorExtension.h
blob: fbcbae6b0b6eacbcfde71b0c7877cedef0204754 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once

#include <base/types.h>
// Contains types declarations and wrappers for GCC vector extension.

namespace DB::VectorExtension
{

using UInt64x2 = UInt64 __attribute__ ((vector_size (sizeof(UInt64) * 2)));
using UInt64x4 = UInt64 __attribute__ ((vector_size (sizeof(UInt64) * 4)));
using UInt64x8 = UInt64 __attribute__ ((vector_size (sizeof(UInt64) * 8)));

using UInt32x2 = UInt32 __attribute__ ((vector_size (sizeof(UInt32) * 2)));
using UInt32x4 = UInt32 __attribute__ ((vector_size (sizeof(UInt32) * 4)));
using UInt32x8 = UInt32 __attribute__ ((vector_size (sizeof(UInt32) * 8)));
using UInt32x16 = UInt32 __attribute__ ((vector_size (sizeof(UInt32) * 16)));

using UInt16x2 = UInt16 __attribute__ ((vector_size (sizeof(UInt16) * 2)));
using UInt16x4 = UInt16 __attribute__ ((vector_size (sizeof(UInt16) * 4)));
using UInt16x8 = UInt16 __attribute__ ((vector_size (sizeof(UInt16) * 8)));
using UInt16x16 = UInt16 __attribute__ ((vector_size (sizeof(UInt16) * 16)));
using UInt16x32 = UInt16 __attribute__ ((vector_size (sizeof(UInt16) * 32)));

using UInt8x2 = UInt8 __attribute__ ((vector_size (sizeof(UInt8) * 2)));
using UInt8x4 = UInt8 __attribute__ ((vector_size (sizeof(UInt8) * 4)));
using UInt8x8 = UInt8  __attribute__ ((vector_size (sizeof(UInt8) * 8)));
using UInt8x16 = UInt8 __attribute__ ((vector_size (sizeof(UInt8) * 16)));
using UInt8x32 = UInt8 __attribute__ ((vector_size (sizeof(UInt8) * 32)));
using UInt8x64 = UInt8 __attribute__ ((vector_size (sizeof(UInt8) * 64)));

namespace detail
{
    template <int Size>
    struct DummyStruct;

    template <>
    struct DummyStruct<4>
    {
        using UInt8Type = UInt8x4;
        using UInt16Type = UInt16x4;
        using UInt32Type = UInt32x4;
        using UInt64Type = UInt64x4;
    };
    template <>
    struct DummyStruct<8>
    {
        using UInt8Type = UInt8x8;
        using UInt16Type = UInt16x8;
        using UInt32Type = UInt32x8;
        using UInt64Type = UInt64x8;
    };
    template <>
    struct DummyStruct<16>
    {
        using UInt8Type = UInt8x16;
        using UInt16Type = UInt16x16;
        using UInt32Type = UInt32x16;
    };
    template <>
    struct DummyStruct<32>
    {
        using UInt8Type = UInt8x32;
        using UInt16Type = UInt16x32;
    };

}

// Same as above via template, e.g. UInt64x<8>
template <int Size>
using UInt8x = typename detail::DummyStruct<Size>::UInt8Type;
template <int Size>
using UInt16x = typename detail::DummyStruct<Size>::UInt16Type;
template <int Size>
using UInt32x = typename detail::DummyStruct<Size>::UInt32Type;
template <int Size>
using UInt64x = typename detail::DummyStruct<Size>::UInt64Type;

}