Argon 0.1.0
Loading...
Searching...
No Matches
argon::Predicate< VectorType > Class Template Reference

A per-lane boolean for vectors of type VectorType, as returned by comparisons. More...

#include <predicate.hpp>

Public Types

using vector_type = VectorType
 The vector type the predicate applies to.
using mask_type = Bool_t<VectorType>
 The equivalent mask vector type.
using mask_scalar = simd::Scalar_t<mask_type>
 The lane type of the mask vector.
using argon_mask_type = helpers::ArgonFor_t<mask_type>
 The Argon type of the mask vector.
using storage_type = mask_type
 The native predicate representation.

Public Member Functions

ace Predicate (storage_type p)
 Construct from the native predicate representation (see storage_type).
template<typename OtherVectorType>
ace Predicate (Predicate< OtherVectorType > other)
 Convert from the predicate of another vector type with the same lanes, e.g.
ace argon_mask_type ToMask () const
 Expand the predicate into a mask vector: every bit set in active lanes, clear in inactive ones.
ace operator argon_mask_type () const
 Implicitly convert to the mask vector that comparisons used to return.
ace storage_type native () const
 The native predicate representation: a mask vector on NEON, an mve_pred16_t on MVE.
ace Predicate operator& (Predicate b) const
 Lanes active in both predicates.
ace Predicate operator| (Predicate b) const
 Lanes active in either predicate.
ace Predicate operator^ (Predicate b) const
 Lanes active in exactly one of the predicates.
ace Predicate operator~ () const
 Invert every lane.
ace Predicate operator&& (Predicate b) const
 Lanes active in both predicates; the same as &.
ace Predicate operator|| (Predicate b) const
 Lanes active in either predicate; the same as |.
ace Predicate operator! () const
 Invert every lane; the same as ~.
template<typename ArgType>
ace ArgType Select (ArgType true_value, ArgType false_value) const
 Choose each lane from true_value where the predicate is active, and from false_value otherwise.
ace bool Any () const
 Whether any lane is active.
ace bool All () const
 Whether every lane is active.
ace bool None () const
 Whether no lane is active.
ace size_t Count () const
 The number of active lanes.
ace bool Active (size_t i) const
 Whether a single lane is active.
ace std::array< bool, lanes > to_array () const
 The active state of every lane, in lane order.

Static Public Member Functions

static ace Predicate True ()
 A predicate with every lane active.
static ace Predicate False ()
 A predicate with no lanes active.
static ace Predicate FirstN (size_t n)
 A predicate with the first n lanes active, and the rest inactive.
static ace Predicate FromMask (argon_mask_type mask)
 Construct from a mask vector, treating any nonzero lane as active.

Static Public Attributes

static constexpr size_t lanes = sizeof(VectorType) / sizeof(scalar_type)
 The number of lanes the predicate covers.

Detailed Description

template<typename VectorType>
class argon::Predicate< VectorType >

A per-lane boolean for vectors of type VectorType, as returned by comparisons.

Template Parameters
VectorTypeThe vector type the predicate applies to (e.g., int32x4_t, float32x4_t).

On NEON a predicate is a mask vector, with every bit of a lane set when the lane is active. On MVE it is an mve_pred16_t, with one bit per byte of the vector, so a 32-bit lane owns four bits. The interface is the same on both, so code written against it is portable; use ToMask() where a mask vector is genuinely needed.

Constructor & Destructor Documentation

◆ Predicate()

template<typename VectorType>
template<typename OtherVectorType>
ace argon::Predicate< VectorType >::Predicate ( Predicate< OtherVectorType > other)
inline

Convert from the predicate of another vector type with the same lanes, e.g.

an int32 comparison used to mask a float32 store. The lanes mean the same thing, so the conversion is free.

Member Function Documentation

◆ Active()

template<typename VectorType>
ace bool argon::Predicate< VectorType >::Active ( size_t i) const
inline

Whether a single lane is active.

Parameters
iThe lane index.

◆ FirstN()

template<typename VectorType>
ace Predicate argon::Predicate< VectorType >::FirstN ( size_t n)
inlinestatic

A predicate with the first n lanes active, and the rest inactive.

On MVE this is vctp, the predicate that tail-predicated loops are built from.

Parameters
nThe number of active lanes; values of lanes or more activate every lane.

◆ FromMask()

template<typename VectorType>
ace Predicate argon::Predicate< VectorType >::FromMask ( argon_mask_type mask)
inlinestatic

Construct from a mask vector, treating any nonzero lane as active.

Parameters
maskThe mask vector.

◆ operator&&()

template<typename VectorType>
ace Predicate argon::Predicate< VectorType >::operator&& ( Predicate< VectorType > b) const
inline

Lanes active in both predicates; the same as &.

Note
Both operands are always evaluated: there is no short-circuit for per-lane logic.

◆ operator||()

template<typename VectorType>
ace Predicate argon::Predicate< VectorType >::operator|| ( Predicate< VectorType > b) const
inline

Lanes active in either predicate; the same as |.

Note
Both operands are always evaluated: there is no short-circuit for per-lane logic.

◆ Select()

template<typename VectorType>
template<typename ArgType>
ace ArgType argon::Predicate< VectorType >::Select ( ArgType true_value,
ArgType false_value ) const
inline

Choose each lane from true_value where the predicate is active, and from false_value otherwise.

NEON: vbsl. MVE: vpsel.

Parameters
true_valueThe lanes to take where the predicate is active.
false_valueThe lanes to take where the predicate is inactive.
Returns
A vector of the operands' type.

The documentation for this class was generated from the following file: