|
20 | 20 | #include "arrow/util/endian.h" |
21 | 21 | #include "arrow/util/simd.h" |
22 | 22 | #include "arrow/util/small_vector.h" |
| 23 | +#include "arrow/util/type_traits.h" |
23 | 24 | #include "arrow/util/ubsan.h" |
24 | 25 |
|
25 | 26 | #include <algorithm> |
@@ -112,56 +113,33 @@ void ByteStreamSplitDecodeSimd128(const uint8_t* data, int width, int64_t num_va |
112 | 113 | } |
113 | 114 | } |
114 | 115 |
|
115 | | -template <int kNumBytes> |
116 | | -struct grouped_bytes_impl; |
117 | | - |
118 | | -template <> |
119 | | -struct grouped_bytes_impl<1> { |
120 | | - using type = int8_t; |
121 | | -}; |
122 | | - |
123 | | -template <> |
124 | | -struct grouped_bytes_impl<2> { |
125 | | - using type = int16_t; |
126 | | -}; |
127 | | - |
128 | | -template <> |
129 | | -struct grouped_bytes_impl<4> { |
130 | | - using type = int32_t; |
131 | | -}; |
132 | | - |
133 | | -template <> |
134 | | -struct grouped_bytes_impl<8> { |
135 | | - using type = int64_t; |
136 | | -}; |
137 | | - |
138 | | -// Map a number of bytes to a type |
139 | | -template <int kNumBytes> |
140 | | -using grouped_bytes_t = typename grouped_bytes_impl<kNumBytes>::type; |
141 | | - |
142 | 116 | // Like xsimd::zip_lo, but zip groups of kNumBytes at once. |
143 | 117 | template <int kNumBytes, int kBatchSize = 16, |
144 | 118 | typename Batch = xsimd::make_sized_batch_t<int8_t, kBatchSize>> |
145 | 119 | auto zip_lo_n(Batch const& a, Batch const& b) -> Batch { |
| 120 | + using arrow::internal::SizedInt; |
| 121 | + |
146 | 122 | if constexpr (kNumBytes == kBatchSize) { |
147 | 123 | return a; |
148 | 124 | } else { |
149 | 125 | return xsimd::bitwise_cast<int8_t>( |
150 | | - xsimd::zip_lo(xsimd::bitwise_cast<grouped_bytes_t<kNumBytes>>(a), |
151 | | - xsimd::bitwise_cast<grouped_bytes_t<kNumBytes>>(b))); |
| 126 | + xsimd::zip_lo(xsimd::bitwise_cast<SizedInt<kNumBytes>>(a), |
| 127 | + xsimd::bitwise_cast<SizedInt<kNumBytes>>(b))); |
152 | 128 | } |
153 | 129 | } |
154 | 130 |
|
155 | 131 | // Like xsimd::zip_hi, but zip groups of kNumBytes at once. |
156 | 132 | template <int kNumBytes, int kBatchSize = 16, |
157 | 133 | typename Batch = xsimd::make_sized_batch_t<int8_t, kBatchSize>> |
158 | 134 | auto zip_hi_n(Batch const& a, Batch const& b) -> Batch { |
| 135 | + using arrow::internal::SizedInt; |
| 136 | + |
159 | 137 | if constexpr (kNumBytes == kBatchSize) { |
160 | 138 | return b; |
161 | 139 | } else { |
162 | 140 | return xsimd::bitwise_cast<int8_t>( |
163 | | - xsimd::zip_hi(xsimd::bitwise_cast<grouped_bytes_t<kNumBytes>>(a), |
164 | | - xsimd::bitwise_cast<grouped_bytes_t<kNumBytes>>(b))); |
| 141 | + xsimd::zip_hi(xsimd::bitwise_cast<SizedInt<kNumBytes>>(a), |
| 142 | + xsimd::bitwise_cast<SizedInt<kNumBytes>>(b))); |
165 | 143 | } |
166 | 144 | } |
167 | 145 |
|
|
0 commit comments