This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 8cbdbb5658 [Enhancement] a better vec version for count_zero_num (#10472) 8cbdbb5658 is described below commit 8cbdbb5658cc981d42af7f3b1c9e0eed5314f628 Author: minghong <minghong.z...@163.com> AuthorDate: Wed Jun 29 10:26:42 2022 +0800 [Enhancement] a better vec version for count_zero_num (#10472) --- be/src/util/simd/bits.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/be/src/util/simd/bits.h b/be/src/util/simd/bits.h index d15243128d..54e2a0cb2c 100644 --- a/be/src/util/simd/bits.h +++ b/be/src/util/simd/bits.h @@ -59,10 +59,28 @@ inline uint32_t bytes32_mask_to_bits32_mask(const bool* data) { return bytes32_mask_to_bits32_mask(reinterpret_cast<const uint8_t*>(data)); } -// compiler will make this SIMD automatically inline size_t count_zero_num(const int8_t* __restrict data, size_t size) { size_t num = 0; const int8_t* end = data + size; +#if defined(__SSE2__) && defined(__POPCNT__) + const __m128i zero16 = _mm_setzero_si128(); + const int8_t* end64 = data + (size / 64 * 64); + + for (; data < end64; data += 64) { + num += __builtin_popcountll( + static_cast<uint64_t>(_mm_movemask_epi8(_mm_cmpeq_epi8( + _mm_loadu_si128(reinterpret_cast<const __m128i*>(data)), zero16))) | + (static_cast<uint64_t>(_mm_movemask_epi8(_mm_cmpeq_epi8( + _mm_loadu_si128(reinterpret_cast<const __m128i*>(data + 16)), zero16))) + << 16u) | + (static_cast<uint64_t>(_mm_movemask_epi8(_mm_cmpeq_epi8( + _mm_loadu_si128(reinterpret_cast<const __m128i*>(data + 32)), zero16))) + << 32u) | + (static_cast<uint64_t>(_mm_movemask_epi8(_mm_cmpeq_epi8( + _mm_loadu_si128(reinterpret_cast<const __m128i*>(data + 48)), zero16))) + << 48u)); + } +#endif for (; data < end; ++data) { num += (*data == 0); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org