forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbyte_stream_split_internal.cc
More file actions
120 lines (105 loc) · 4.57 KB
/
Copy pathbyte_stream_split_internal.cc
File metadata and controls
120 lines (105 loc) · 4.57 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#include "arrow/util/byte_stream_split_internal.h"
#include "arrow/util/dispatch_internal.h"
#include <array>
namespace arrow::util::internal {
using ::arrow::internal::DispatchLevel;
using ::arrow::internal::DynamicDispatch;
/************************
* Decode dispatching *
************************/
template <int kNumStreams>
struct ByteStreamSplitDecodeDynamic {
using FunctionType = decltype(&ByteStreamSplitDecodeScalar<kNumStreams>);
using Implementation = std::pair<DispatchLevel, FunctionType>;
constexpr static auto implementations() {
return std::array{
Implementation{
DispatchLevel::NONE,
#if defined(ARROW_HAVE_NEON)
// We always expect Neon to be available on Arm64
&ByteStreamSplitDecodeSimd<xsimd::neon64, kNumStreams>,
#elif defined(ARROW_HAVE_SSE4_2)
// We always expect SSE4.2 to be available on x86_64
&ByteStreamSplitDecodeSimd<xsimd::sse4_2, kNumStreams>,
#else
&ByteStreamSplitDecodeScalar<kNumStreams>,
#endif
},
#if defined(ARROW_HAVE_RUNTIME_AVX2)
Implementation{
DispatchLevel::AVX2,
&ByteStreamSplitDecodeSimd<xsimd::avx2, kNumStreams>,
},
#endif
};
}
};
template <int kNumStreams>
void ByteStreamSplitDecodeSimdDispatch(const uint8_t* data, int width, int64_t num_values,
int64_t stride, uint8_t* out) {
static const DynamicDispatch<ByteStreamSplitDecodeDynamic<kNumStreams>> dispatch;
return dispatch.func(data, width, num_values, stride, out);
}
template void ByteStreamSplitDecodeSimdDispatch<2>(const uint8_t*, int, int64_t, int64_t,
uint8_t*);
template void ByteStreamSplitDecodeSimdDispatch<4>(const uint8_t*, int, int64_t, int64_t,
uint8_t*);
template void ByteStreamSplitDecodeSimdDispatch<8>(const uint8_t*, int, int64_t, int64_t,
uint8_t*);
/************************
* Encode dispatching *
************************/
template <int kNumStreams>
struct ByteStreamSplitEncodeDynamic {
using FunctionType = decltype(&ByteStreamSplitEncodeScalar<kNumStreams>);
using Implementation = std::pair<DispatchLevel, FunctionType>;
constexpr static auto implementations() {
return std::array{
Implementation{
DispatchLevel::NONE,
#if defined(ARROW_HAVE_NEON)
// We always expect Neon to be available on Arm64
&ByteStreamSplitEncodeSimd<xsimd::neon64, kNumStreams>,
#elif defined(ARROW_HAVE_SSE4_2)
// We always expect SSE4.2 to be available on x86_64
&ByteStreamSplitEncodeSimd<xsimd::sse4_2, kNumStreams>,
#else
&ByteStreamSplitEncodeScalar<kNumStreams>,
#endif
},
#if defined(ARROW_HAVE_RUNTIME_AVX2)
Implementation{DispatchLevel::AVX2, &ByteStreamSplitEncodeAvx2<kNumStreams>},
#endif
};
}
};
template <int kNumStreams>
void ByteStreamSplitEncodeSimdDispatch(const uint8_t* raw_values, int width,
const int64_t num_values,
uint8_t* output_buffer_raw) {
static const DynamicDispatch<ByteStreamSplitEncodeDynamic<kNumStreams>> dispatch;
return dispatch.func(raw_values, width, num_values, output_buffer_raw);
}
template void ByteStreamSplitEncodeSimdDispatch<2>(const uint8_t*, int, const int64_t,
uint8_t*);
template void ByteStreamSplitEncodeSimdDispatch<4>(const uint8_t*, int, const int64_t,
uint8_t*);
template void ByteStreamSplitEncodeSimdDispatch<8>(const uint8_t*, int, const int64_t,
uint8_t*);
} // namespace arrow::util::internal