66#ifndef ADS_SIMD_SCALAR
67 #define ADS_SIMD_SCALAR 0
72#if defined( ADS_WITH_HIGHWAY ) && ! ADS_SIMD_SCALAR
87 #include <type_traits>
97inline void prefetchLine(
const void * p ,
Locality l )
noexcept;
101 #undef HWY_TARGET_INCLUDE
102 #define HWY_TARGET_INCLUDE "ADS/impl/Simd.tpp"
103 #include <hwy/foreach_target.h>
105 #include <hwy/highway.h>
107 #include "ADS/impl/Simd.tpp"
113namespace ADS::detail::simd
116HWY_EXPORT( popcountWords );
117HWY_EXPORT( popcountAndWords );
118HWY_EXPORT( combineWords );
119HWY_EXPORT( blocksCommonI32 );
120HWY_EXPORT( blocksCommonU32 );
121HWY_EXPORT( windowsCommonI32 );
122HWY_EXPORT( windowsCommonU32 );
123HWY_EXPORT( intersectBlocks16 );
124HWY_EXPORT( differenceBlocks16 );
125HWY_EXPORT( unionBlocks16 );
126HWY_EXPORT( hashStripes );
127HWY_EXPORT( vbyteEncode );
128HWY_EXPORT( vbyteDecode );
130HWY_EXPORT( bpUnpack );
133inline std::uint64_t
popcount(
const std::uint64_t * w , std::size_t n )
135 return( HWY_DYNAMIC_DISPATCH( popcountWords )( w , n ) );
139inline std::uint64_t
popcountAnd(
const std::uint64_t * a ,
140 const std::uint64_t * b , std::size_t n )
142 return( HWY_DYNAMIC_DISPATCH( popcountAndWords )( a , b , n ) );
148inline std::uint64_t combine(
const std::uint64_t * a ,
149 const std::uint64_t * b ,
150 std::uint64_t * c , std::size_t n ,
int o )
152 return( HWY_DYNAMIC_DISPATCH( combineWords )( a , b , c , n , o ) );
160inline std::size_t blocksCommon(
const T * a , std::size_t n ,
const T * b ,
161 std::size_t m , T * out , std::size_t * i ,
164 if constexpr( std::is_signed_v< T > )
165 return( HWY_DYNAMIC_DISPATCH( blocksCommonI32 )(
166 reinterpret_cast< const std::int32_t *
>( a ) , n ,
167 reinterpret_cast< const std::int32_t *
>( b ) , m ,
168 reinterpret_cast< std::int32_t *
>( out ) , i , j ) );
170 return( HWY_DYNAMIC_DISPATCH( blocksCommonU32 )(
171 reinterpret_cast< const std::uint32_t *
>( a ) , n ,
172 reinterpret_cast< const std::uint32_t *
>( b ) , m ,
173 reinterpret_cast< std::uint32_t *
>( out ) , i , j ) );
182inline std::size_t windowsCommon(
const T * s , std::size_t m ,
const T * l ,
183 std::size_t n , T * out , std::size_t * q ,
186 if constexpr( std::is_signed_v< T > )
187 return( HWY_DYNAMIC_DISPATCH( windowsCommonI32 )(
188 reinterpret_cast< const std::int32_t *
>( s ) , m ,
189 reinterpret_cast< const std::int32_t *
>( l ) , n ,
190 reinterpret_cast< std::int32_t *
>( out ) , q , p ) );
192 return( HWY_DYNAMIC_DISPATCH( windowsCommonU32 )(
193 reinterpret_cast< const std::uint32_t *
>( s ) , m ,
194 reinterpret_cast< const std::uint32_t *
>( l ) , n ,
195 reinterpret_cast< std::uint32_t *
>( out ) , q , p ) );
202inline std::size_t intersectBlocks16(
const std::uint16_t * a ,
204 const std::uint16_t * b ,
206 std::uint16_t * out , std::size_t * i ,
210 HWY_DYNAMIC_DISPATCH( intersectBlocks16 )( a , na , b , nb , out , i ,
218inline std::size_t differenceBlocks16(
const std::uint16_t * a ,
220 const std::uint16_t * b ,
222 std::uint16_t * out , std::size_t * i ,
223 std::size_t * j ,
unsigned * found )
225 return( HWY_DYNAMIC_DISPATCH( differenceBlocks16 )( a , na , b , nb , out ,
234inline std::size_t unionBlocks16(
const std::uint16_t * a , std::size_t na ,
235 const std::uint16_t * b , std::size_t nb ,
236 std::uint16_t * out )
238 return( HWY_DYNAMIC_DISPATCH( unionBlocks16 )( a , na , b , nb , out ) );
244inline void hashStripes(
const unsigned char * s , std::size_t n ,
245 std::uint64_t seed ,
const std::uint64_t * k ,
246 std::uint64_t * out )
248 HWY_DYNAMIC_DISPATCH( hashStripes )( s , n , seed , k , out );
255inline std::size_t vbyteEncode(
const std::uint32_t * x , std::size_t n ,
256 std::uint8_t * keys , std::uint8_t ** d ,
257 const std::uint8_t * pack ,
258 const std::uint8_t * len )
260 return( HWY_DYNAMIC_DISPATCH( vbyteEncode )( x , n , keys , d , pack ,
269vbyteDecode(
const std::uint8_t * keys ,
const std::uint8_t ** d ,
270 const std::uint8_t * end , std::size_t n , std::uint32_t * x ,
271 const std::uint8_t * shuffle ,
const std::uint8_t * len )
274 HWY_DYNAMIC_DISPATCH( vbyteDecode )( keys , d , end , n , x , shuffle ,
281inline void bpPack(
const std::uint32_t * in , std::uint8_t * out ,
int b )
283 HWY_DYNAMIC_DISPATCH( bpPack )( in , out , b );
290inline void bpUnpack(
const std::uint8_t * in , std::uint32_t * out ,
int b ,
291 bool sorted , std::uint32_t * prev )
293 HWY_DYNAMIC_DISPATCH( bpUnpack )( in , out , b , sorted , prev );
The prefetch of a line of the cache, beyond the book: ADS::prefetch( p ) asks the processor to bring ...
std::uint64_t popcountAnd(const Word *a, const Word *b, std::size_t n)
the 1 bits of the words of
std::uint64_t popcount(const Word *w, std::size_t n)
the 1 bits of the words from
Locality
how soon and how often a prefetched line is read again: None once (keep it out of the caches it would...
Definition Prefetch.h:64