Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-17 08:39:05

0001 /* Copyright 2025 Joaquin M Lopez Munoz.
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * http://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * See https://www.boost.org/libs/bloom for library home page.
0007  */
0008 
0009 #ifndef BOOST_BLOOM_DETAIL_FAST_MULTIBLOCK32_AVX2_HPP
0010 #define BOOST_BLOOM_DETAIL_FAST_MULTIBLOCK32_AVX2_HPP
0011 
0012 #include <boost/bloom/detail/avx2.hpp>
0013 #include <boost/bloom/detail/multiblock_fpr_base.hpp>
0014 #include <boost/bloom/detail/mulx64.hpp>
0015 #include <boost/config.hpp>
0016 #include <boost/config/workaround.hpp>
0017 #include <cstddef>
0018 #include <cstdint>
0019 
0020 namespace boost{
0021 namespace bloom{
0022 
0023 #if defined(BOOST_MSVC)
0024 #pragma warning(push)
0025 #pragma warning(disable:4714) /* marked as __forceinline not inlined */
0026 #endif
0027 
0028 template<std::size_t K>
0029 struct fast_multiblock32:detail::multiblock_fpr_base<K>
0030 {
0031   static constexpr std::size_t k=K;
0032   using value_type=__m256i[(k+7)/8];
0033   static constexpr std::size_t used_value_size=sizeof(std::uint32_t)*k;
0034 
0035   static BOOST_FORCEINLINE void mark(value_type& x,std::uint64_t hash)
0036   {
0037     for(std::size_t i=0;i<k/8;++i){
0038       mark_m256i(x[i],hash,8);
0039       hash=detail::mulx64(hash);
0040     }
0041     if(k%8){
0042       mark_m256i(x[k/8],hash,k%8);
0043     }
0044   }
0045 
0046   static BOOST_FORCEINLINE bool check(const value_type& x,std::uint64_t hash)
0047   {
0048     bool res=true;
0049     for(std::size_t i=0;i<k/8;++i){
0050       res&=check_m256i(x[i],hash,8);
0051       hash=detail::mulx64(hash);
0052     }
0053     if(k%8){
0054       res&=check_m256i(x[k/8],hash,k%8);
0055     }
0056     return res;
0057   }
0058 
0059 private:
0060   static BOOST_FORCEINLINE __m256i make_m256i(
0061     std::uint64_t hash,std::size_t kp)
0062   {
0063     const __m256i ones[8]={
0064       _mm256_set_epi32(0,0,0,0,0,0,0,1),
0065       _mm256_set_epi32(0,0,0,0,0,0,1,1),
0066       _mm256_set_epi32(0,0,0,0,0,1,1,1),
0067       _mm256_set_epi32(0,0,0,0,1,1,1,1),
0068       _mm256_set_epi32(0,0,0,1,1,1,1,1),
0069       _mm256_set_epi32(0,0,1,1,1,1,1,1),
0070       _mm256_set_epi32(0,1,1,1,1,1,1,1),
0071       _mm256_set_epi32(1,1,1,1,1,1,1,1),
0072     };
0073 
0074     __m256i h=_mm256_set1_epi64x(hash);
0075     h=_mm256_sllv_epi64(h,_mm256_set_epi64x(15,10,5,0));
0076     h=_mm256_srli_epi32(h,32-5);
0077     return _mm256_sllv_epi32(ones[kp-1],h);
0078   }
0079 
0080   static BOOST_FORCEINLINE void mark_m256i(
0081     __m256i& x,std::uint64_t hash,std::size_t kp)
0082   {
0083     __m256i h=make_m256i(hash,kp);
0084     x=_mm256_or_si256(x,h);
0085   }
0086 
0087 #if BOOST_WORKAROUND(BOOST_MSVC,<=1900)
0088 /* 'int': forcing value to bool 'true' or 'false' */
0089 #pragma warning(push)
0090 #pragma warning(disable:4800)
0091 #endif
0092 
0093   static BOOST_FORCEINLINE bool check_m256i(
0094     const __m256i& x,std::uint64_t hash,std::size_t kp)
0095   {
0096     __m256i h=make_m256i(hash,kp);
0097     return _mm256_testc_si256(x,h);
0098   }
0099 
0100 #if BOOST_WORKAROUND(BOOST_MSVC,<=1900)
0101 #pragma warning(pop) /* C4800 */
0102 #endif
0103 };
0104 
0105 #if defined(BOOST_MSVC)
0106 #pragma warning(pop) /* C4714 */
0107 #endif
0108 
0109 } /* namespace bloom */
0110 } /* namespace boost */
0111 
0112 #endif