DPC++ Runtime
Runtime libraries for oneAPI DPC++
cl::__ESIMD_DNS::simd_mask_impl< T, N > Class Template Reference

This class is a simd_obj_impl specialization representing a simd mask, which is basically a simd_obj_impl with fixed element type and limited set of APIs. More...

#include <sycl/ext/intel/esimd/detail/simd_mask_impl.hpp>

Inheritance diagram for cl::__ESIMD_DNS::simd_mask_impl< T, N >:
Collaboration diagram for cl::__ESIMD_DNS::simd_mask_impl< T, N >:

Public Types

using raw_element_type = T
 Raw element type actually used for storage. More...
 
using element_type = T
 Element type, same as raw. More...
 
using raw_vector_type = typename base_type::raw_vector_type
 Underlying storage type for the entire vector. More...
 

Public Member Functions

 simd_mask_impl ()=default
 Compiler-generated default constructor. More...
 
 simd_mask_impl (const simd_mask_impl &other)
 Copy constructor. More...
 
template<class T1 , class = std::enable_if_t<std::is_integral_v<T1>>>
 simd_mask_impl (T1 Val)
 Broadcast constructor with conversion. More...
 
 simd_mask_impl (const raw_vector_type &Val)
 Implicit conversion constructor from a raw vector object. More...
 
template<int N1, class = std::enable_if_t<N1 == N>>
 simd_mask_impl (const raw_element_type(&&Arr)[N1])
 Construct from an array. To allow e.g. simd_mask<N> m({1,0,0,1,...}). More...
 
 simd_mask_impl (const simd< T, N > &Val)
 Implicit conversion from simd. More...
 
template<typename T1 , typename = std::enable_if_t<mask_size_ok_for_mem_io() && std::is_same_v<T1, element_type>>>
 simd_mask_impl (const T1 *ptr)
 Load constructor. More...
 
simd_mask_imploperator= (element_type val) noexcept
 Broadcast assignment operator to support simd_mask_impl<N> n = a > b;. More...
 
template<class T1 = simd_mask_impl, class = std::enable_if_t<T1::length == 1>>
 operator bool () const
 Conversion to boolean. More...
 

Detailed Description

template<typename T, int N>
class cl::__ESIMD_DNS::simd_mask_impl< T, N >

This class is a simd_obj_impl specialization representing a simd mask, which is basically a simd_obj_impl with fixed element type and limited set of APIs.

E.g. arithmetic operations (+, -, etc.) are not defined for masks, but bit operations like ^, & are. Masks are used in many ESIMD APIs to enable/disable specific lanes - for example, to disable certain lanes when writing to a memory via the scatter operation. Each mask element may thus be interpreted in one of two ways - by ESIMD ops - "lane enaled" or "lane disabled". They can be produced in a number of ways:

  • using per-element simd object comparison operations, in which case the result is true / false per lane, and true means "enabled" in the resulting mask lane, false - "disabled".
  • reading from memory, for example:
    using simd_mask_elem_t = typename simd_mask<1>::element_type;
    simd_mask_elem_t *arr;
    ...
    simd_mask<8> m(arr + 8*i);
    In this and all other cases below lanes with non-zero value are treated as "enabled", lanes with zero - as "disabled".
  • constructing from an array or using broadcast constructor:
    simd_mask<8> m1({1,0,1,0,1,0,1,0});
    simd_mask<8> m2(1); // all "enabled"
  • constructing from a simd object. User code should use simd_mask<1>::element_type<code> when the mask element type needs to be used - for example, to declare a pointer to memory where mask elements can be written to/read from. Yet it must not assume it to be of any specific type (which is unsigned 16-bit integer in fact).
    Template Parameters
    TFixed element type, must be simd_mask_elem_type.
    NNumber of elements (per-lane predicates) in the mask.

Definition at line 55 of file simd_mask_impl.hpp.

Member Typedef Documentation

◆ element_type

template<typename T , int N>
using cl::__ESIMD_DNS::simd_mask_impl< T, N >::element_type = T

Element type, same as raw.

Definition at line 67 of file simd_mask_impl.hpp.

◆ raw_element_type

template<typename T , int N>
using cl::__ESIMD_DNS::simd_mask_impl< T, N >::raw_element_type = T

Raw element type actually used for storage.

Definition at line 65 of file simd_mask_impl.hpp.

◆ raw_vector_type

template<typename T , int N>
using cl::__ESIMD_DNS::simd_mask_impl< T, N >::raw_vector_type = typename base_type::raw_vector_type

Underlying storage type for the entire vector.

Definition at line 69 of file simd_mask_impl.hpp.

Constructor & Destructor Documentation

◆ simd_mask_impl() [1/7]

template<typename T , int N>
cl::__ESIMD_DNS::simd_mask_impl< T, N >::simd_mask_impl ( )
default

Compiler-generated default constructor.

◆ simd_mask_impl() [2/7]

template<typename T , int N>
cl::__ESIMD_DNS::simd_mask_impl< T, N >::simd_mask_impl ( const simd_mask_impl< T, N > &  other)
inline

Copy constructor.

Definition at line 77 of file simd_mask_impl.hpp.

◆ simd_mask_impl() [3/7]

template<typename T , int N>
template<class T1 , class = std::enable_if_t<std::is_integral_v<T1>>>
cl::__ESIMD_DNS::simd_mask_impl< T, N >::simd_mask_impl ( T1  Val)
inline

Broadcast constructor with conversion.

See also
simd_obj_impl::simd_obj_impl(T)

Definition at line 82 of file simd_mask_impl.hpp.

◆ simd_mask_impl() [4/7]

template<typename T , int N>
cl::__ESIMD_DNS::simd_mask_impl< T, N >::simd_mask_impl ( const raw_vector_type Val)
inline

Implicit conversion constructor from a raw vector object.

Definition at line 86 of file simd_mask_impl.hpp.

◆ simd_mask_impl() [5/7]

template<typename T , int N>
template<int N1, class = std::enable_if_t<N1 == N>>
cl::__ESIMD_DNS::simd_mask_impl< T, N >::simd_mask_impl ( const raw_element_type(&&)  Arr[N1])
inline

Construct from an array. To allow e.g. simd_mask<N> m({1,0,0,1,...}).

Definition at line 90 of file simd_mask_impl.hpp.

◆ simd_mask_impl() [6/7]

template<typename T , int N>
cl::__ESIMD_DNS::simd_mask_impl< T, N >::simd_mask_impl ( const simd< T, N > &  Val)
inline

Implicit conversion from simd.

Definition at line 95 of file simd_mask_impl.hpp.

◆ simd_mask_impl() [7/7]

template<typename T , int N>
template<typename T1 , typename = std::enable_if_t<mask_size_ok_for_mem_io() && std::is_same_v<T1, element_type>>>
cl::__ESIMD_DNS::simd_mask_impl< T, N >::simd_mask_impl ( const T1 *  ptr)
inlineexplicit

Load constructor.

Definition at line 118 of file simd_mask_impl.hpp.

Member Function Documentation

◆ operator bool()

template<typename T , int N>
template<class T1 = simd_mask_impl, class = std::enable_if_t<T1::length == 1>>
cl::__ESIMD_DNS::simd_mask_impl< T, N >::operator bool ( ) const
inline

Conversion to boolean.

Available only when the number of elements is 1.

Returns
true if the element is non-zero, false otherwise.

Definition at line 132 of file simd_mask_impl.hpp.

◆ operator=()

template<typename T , int N>
simd_mask_impl& cl::__ESIMD_DNS::simd_mask_impl< T, N >::operator= ( element_type  val)
inlinenoexcept

Broadcast assignment operator to support simd_mask_impl<N> n = a > b;.

Definition at line 123 of file simd_mask_impl.hpp.


The documentation for this class was generated from the following file:
simd_mask
Definition: simd.hpp:1029