|
Intel xvec
Experimental C++ simd class library
|
A mask containing boolean elements. More...
#include <mask.hpp>
Public Types | |
| using | traits = detail::mask_traits<target_tag, _Bytes, _Abi::num_elements> |
| using | builtin_type = typename traits::builtin_type |
| using | abi_type = _Abi |
| The ABI type of this mask. | |
| using | value_type = bool |
| The boolean type of each mask element. | |
| using | iterator = simd_iterator<basic_mask> |
| Iterator over mask elements. | |
| using | const_iterator = simd_iterator<const basic_mask> |
| Iterator providing read-only access to mask elements. | |
Public Member Functions | |
| constexpr | basic_mask ()=default |
| Default-construct a mask. | |
| constexpr | basic_mask (const basic_mask &)=default |
| Copy-construct a mask. | |
| constexpr | basic_mask (basic_mask &&) noexcept=default |
| Move-construct a mask. | |
| constexpr basic_mask & | operator= (const basic_mask &)=default |
| Copy-assign a mask. | |
| constexpr basic_mask & | operator= (basic_mask &&) noexcept=default |
| Move-assign a mask. | |
| constexpr | basic_mask (std::same_as< value_type > auto b) noexcept |
| Build a mask from a boolean value. | |
| template<std::unsigned_integral T> requires (!std::same_as<T, value_type>) | |
| constexpr | basic_mask (T m) noexcept |
| Build a mask from the bits of an unsigned integral value. Each mask element is initialized from the corresponding input bit. Elements beyond the width of the input value are initialized to false. | |
| template<std::size_t _UBytes, typename _UAbi> requires (basic_mask<_UBytes, _UAbi>::size() == size()) | |
| constexpr | basic_mask (const basic_mask< _UBytes, _UAbi > &m) |
| Convert a mask with the same number of elements. Each output element retains the corresponding input boolean value. | |
| constexpr | basic_mask (std::invocable< std::integral_constant< simd_size_type, 0 > > auto fn) |
| Generate each mask element from its index. | |
| template<std::same_as< std::bitset< size()> > T> | |
| constexpr | basic_mask (const T &b) noexcept |
| Construct a mask from the corresponding bitset. | |
| constexpr iterator | begin () noexcept |
| Return an iterator to the first element. | |
| constexpr const_iterator | begin () const noexcept |
| Return a const iterator to the first element. | |
| constexpr const_iterator | cbegin () const noexcept |
| Return a const iterator to the first element. | |
| constexpr std::default_sentinel_t | end () const noexcept |
| Return the end sentinel. | |
| constexpr std::default_sentinel_t | cend () const noexcept |
| Return the end sentinel. | |
| constexpr | operator builtin_type () |
| constexpr | operator typename traits::signed_vec_for_mask () const |
| Convert the mask to a signed integral vector. Each output element is 1 if the corresponding mask element is true, or 0 otherwise. | |
| constexpr auto | to_builtin () const |
| Return the builtin mask value directly. | |
| constexpr auto | to_register () const noexcept |
| Convert the mask into a register which can be passed to an intrinsic. | |
| constexpr std::bitset< size()> | to_bitset () const noexcept |
| Return a bitset containing the value of each mask element. | |
| constexpr unsigned long long | to_ullong () const |
| constexpr basic_mask | operator! () const noexcept |
| Negate each boolean mask element. | |
| constexpr traits::signed_vec_for_mask | operator+ () const noexcept |
| Return a signed integral vector containing 1 for true elements and 0 otherwise. | |
| constexpr traits::signed_vec_for_mask | operator- () const noexcept |
| Return a signed integral vector containing -1 for true elements and 0 otherwise. | |
| constexpr traits::signed_vec_for_mask | operator~ () const noexcept |
| Return the element-wise bitwise complement of the vector produced by unary plus. | |
| constexpr auto | operator[] (const vec_integral auto &indexes) const |
| Select mask elements using an integral index vector. | |
| constexpr bool | operator[] (simd_size_type pos) const & |
| Return the mask element at the specified position. | |
| constexpr basic_mask & | operator&= (const basic_mask &rhs) noexcept |
| Compute the element-wise bitwise AND and assign the result. | |
| constexpr basic_mask & | operator|= (const basic_mask &rhs) noexcept |
| Compute the element-wise bitwise OR and assign the result. | |
| constexpr basic_mask & | operator^= (const basic_mask &rhs) noexcept |
| Compute the element-wise bitwise XOR and assign the result. | |
Static Public Member Functions | |
| static constexpr basic_mask | __mask_from_count (simd_size_type _n) |
| static constexpr basic_mask | from_builtin (const builtin_type &m) |
Static Public Attributes | |
| static constexpr auto | size = size_constant<_Abi::num_elements>{} |
| Return the number of elements contained in the mask. | |
Friends | |
| constexpr basic_mask | operator&& (const basic_mask &lhs, const basic_mask &rhs) noexcept |
| Compute the element-wise logical AND. | |
| constexpr basic_mask | operator|| (const basic_mask &lhs, const basic_mask &rhs) noexcept |
| Compute the element-wise logical OR. | |
| constexpr basic_mask | operator& (const basic_mask &lhs, const basic_mask &rhs) noexcept |
| Compute the element-wise bitwise AND. | |
| constexpr basic_mask | operator| (const basic_mask &lhs, const basic_mask &rhs) noexcept |
| Compute the element-wise bitwise OR. | |
| constexpr basic_mask | operator^ (const basic_mask &lhs, const basic_mask &rhs) noexcept |
| Compute the element-wise bitwise XOR. | |
| constexpr basic_mask | operator== (const basic_mask &lhs, const basic_mask &rhs) noexcept |
| Compare corresponding mask elements for equality. | |
| constexpr basic_mask | operator!= (const basic_mask &lhs, const basic_mask &rhs) noexcept |
| Compare corresponding mask elements for inequality. | |
| constexpr basic_mask | operator< (const basic_mask &lhs, const basic_mask &rhs) noexcept |
| Compare corresponding mask elements using less-than. | |
| constexpr basic_mask | operator<= (const basic_mask &lhs, const basic_mask &rhs) noexcept |
| Compare corresponding mask elements using less-than-or-equal. | |
| constexpr basic_mask | operator> (const basic_mask &lhs, const basic_mask &rhs) noexcept |
| Compare corresponding mask elements using greater-than. | |
| constexpr basic_mask | operator>= (const basic_mask &lhs, const basic_mask &rhs) noexcept |
| Compare corresponding mask elements using greater-than-or-equal. | |
| constexpr basic_mask | simd_select_impl (const basic_mask &m, const basic_mask &if_true, const basic_mask &if_false) noexcept |
| Implementation of element-wise selection between two masks. | |
| constexpr basic_mask | simd_select_impl (const basic_mask &m, std::same_as< bool > auto if_true, std::same_as< bool > auto if_false) noexcept |
| Implementation of selection between two broadcast boolean values. | |
|
template<vec_type _Tp> requires (sizeof(_Tp) == _Bytes) | |
| constexpr _Tp | simd_select_impl (const basic_mask &m, const _Tp &if_true, const _Tp &if_false) noexcept |
| Implementation of element-wise vector selection using a mask. | |
| std::ostream & | operator<< (std::ostream &stream, const basic_mask &value) |
| Output the mask to a stream as individual bits. | |
A mask containing boolean elements.
| _Bytes | The associated vector element size in bytes. |
| _Abi | The ABI determining the mask representation and element count. |
Provides a uniform interface over target-specific mask representations.
Wide masks, such as those used with Intel SSE and AVX, represent each boolean element using a vector element whose bits are all zero or all one.
Compact masks, such as those used with Intel AVX-512, represent each boolean element using a single bit.
The class hides these representation differences for logical operations, comparisons, selection, and conversion to packed-bit representations.
| using xvec::simd::basic_mask< _Bytes, _Abi >::traits = detail::mask_traits<target_tag, _Bytes, _Abi::num_elements> |
Implementation traits for this mask type.
|
inlinestaticconstexpr |
Generate a mask with the first _n elements set to true.