Different sizes of a given kernel. When integers are bit-packed, they can spread over multiple bytes. For instance, integers packed over three bits quickly spread over two bytes (on the value `C` below) despite three bits being much smaller than a single byte. ``` |A|A|A|B|B|B|C|C| |C|D|D|D|E|E|E|F| ... ``` When the spread is smaller or equal to the unsigned integer to unpack to, we classify i
| 281 | /// reduce the number of swizzles done in a kernel run. Other optimizations of interest |
| 282 | /// for small input sizes on BMI2 is to use ``_pdep_u64`` directly to perform unpacking. |
| 283 | struct KernelShape { |
| 284 | const int simd_bit_size_; |
| 285 | const int unpacked_bit_size_; |
| 286 | const int packed_bit_size_; |
| 287 | const int packed_max_spread_bytes_ = PackedMaxSpreadBytes(packed_bit_size_, 0); |
| 288 | const bool is_oversized_ = |
| 289 | PackedIsOversizedForSimd(simd_bit_size_, unpacked_bit_size_, packed_bit_size_); |
| 290 | |
| 291 | constexpr bool is_medium() const { |
| 292 | return packed_max_spread_bytes() <= unpacked_byte_size(); |
| 293 | } |
| 294 | constexpr bool is_large() const { return !is_medium() && !is_oversized(); } |
| 295 | constexpr bool is_oversized() const { return is_oversized_; } |
| 296 | |
| 297 | /// Properties of an SIMD batch |
| 298 | constexpr int simd_bit_size() const { return simd_bit_size_; } |
| 299 | constexpr int simd_byte_size() const { return simd_bit_size_ / 8; } |
| 300 | |
| 301 | /// Properties of the unpacked integers |
| 302 | constexpr int unpacked_bit_size() const { return unpacked_bit_size_; } |
| 303 | constexpr int unpacked_byte_size() const { return unpacked_bit_size_ / 8; } |
| 304 | constexpr int unpacked_per_simd() const { return simd_bit_size_ / unpacked_bit_size_; } |
| 305 | |
| 306 | /// Properties of the packed integers |
| 307 | constexpr int packed_bit_size() const { return packed_bit_size_; } |
| 308 | constexpr int packed_max_spread_bytes() const { return packed_max_spread_bytes_; } |
| 309 | }; |
| 310 | |
| 311 | /// Packing all useful and derived information about a kernel in a single type. |
| 312 | template <typename UnpackedUint, int kPackedBitSize, typename Arch> |
nothing calls this directly
no test coverage detected