Skip to content

Commit

Permalink
cleanup: rename descriptor in documentation to tag.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 406102290
  • Loading branch information
jan-wassenberg authored and copybara-github committed Oct 28, 2021
1 parent 660d3db commit acc21a6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
10 changes: 5 additions & 5 deletions g3doc/design_philosophy.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ runtime dispatch.

## Overloaded function API

Most C++ vector APIs rely on class templates. However, the ARM SVE vector
type is sizeless and cannot be wrapped in a class. We instead rely on overloaded
Most C++ vector APIs rely on class templates. However, the ARM SVE vector type
is sizeless and cannot be wrapped in a class. We instead rely on overloaded
functions. Overloading based on vector types is also undesirable because SVE
vectors cannot be default-constructed. We instead use a dedicated 'descriptor'
type `Simd` for overloading, abbreviated to `D` for template arguments and
`d` in lvalues.
vectors cannot be default-constructed. We instead use a dedicated tag type
`Simd` for overloading, abbreviated to `D` for template arguments and `d` in
lvalues.

Note that generic function templates are possible (see generic_ops-inl.h).

Expand Down
2 changes: 1 addition & 1 deletion g3doc/quick_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ HWY_AFTER_NAMESPACE();
* `d` is an lvalue of type `D`, passed as a function argument e.g. to Zero;
* `V` is the type of a vector.

## Vector and descriptor types
## Vector and tag types

Highway vectors consist of one or more 'lanes' of the same built-in type
`uint##_t, int##_t` for `## = 8, 16, 32, 64`, plus `float##_t` for `## = 16, 32,
Expand Down
4 changes: 2 additions & 2 deletions hwy/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ HWY_API constexpr bool IsSame() {
// vectors of AT MOST this many bits.
//
// Note that enabling for exactly 128 bits is unnecessary because a function can
// simply be overloaded with Vec128<T> and Full128<T> descriptor. Enabling for
// other sizes (e.g. 64 bit) can be achieved with Simd<T, 8 / sizeof(T)>.
// simply be overloaded with Vec128<T> and/or Full128<T> tag. Enabling for other
// sizes (e.g. 64 bit) can be achieved via Simd<T, 8 / sizeof(T)>.
#define HWY_IF_LE128(T, N) hwy::EnableIf<N * sizeof(T) <= 16>* = nullptr
#define HWY_IF_LE64(T, N) hwy::EnableIf<N * sizeof(T) <= 8>* = nullptr
#define HWY_IF_LE32(T, N) hwy::EnableIf<N * sizeof(T) <= 4>* = nullptr
Expand Down
4 changes: 3 additions & 1 deletion hwy/highway.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ namespace hwy {
#define HWY_PATCH 2

//------------------------------------------------------------------------------
// Shorthand for descriptors (defined in shared-inl.h) used to select overloads.
// Shorthand for tags (defined in shared-inl.h) used to select overloads.
// Note that ScalableTag<T> is preferred over HWY_FULL, and CappedTag<T, N> over
// HWY_CAPPED(T, N).

// HWY_FULL(T[,LMUL=1]) is a native vector/group. LMUL is the number of
// registers in the group, and is ignored on targets that do not support groups.
Expand Down
18 changes: 9 additions & 9 deletions hwy/ops/shared-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ HWY_BEFORE_NAMESPACE();
namespace hwy {
namespace HWY_NAMESPACE {

// SIMD operations are implemented as overloaded functions selected using a
// "descriptor" D := Simd<T, N>. T is the lane type, N an opaque integer for
// internal use only. Users create D via aliases ScalableTag<T>() (a full
// vector), CappedTag<T, kLimit> or FixedTag<T, kNumLanes>. The actual number of
// lanes (always a power of two) is Lanes(D()).
// SIMD operations are implemented as overloaded functions selected using a tag
// type D := Simd<T, N>. T is the lane type, N an opaque integer for internal
// use only. Users create D via aliases ScalableTag<T>() (a full vector),
// CappedTag<T, kLimit> or FixedTag<T, kNumLanes>. The actual number of lanes
// (always a power of two) is Lanes(D()).
template <typename Lane, size_t N>
struct Simd {
constexpr Simd() = default;
using T = Lane;
static_assert((N & (N - 1)) == 0 && N != 0, "N must be a power of two");

// Widening/narrowing ops change the number of lanes and/or their type.
// To initialize such vectors, we need the corresponding descriptor types:
// To initialize such vectors, we need the corresponding tag types:

// PromoteTo/DemoteTo() with another lane type, but same number of lanes.
template <typename NewLane>
Expand Down Expand Up @@ -139,7 +139,7 @@ using FixedTag = typename detail::FixedTagChecker<T, kNumLanes>::type;
template <class D>
using TFromD = typename D::T;

// Descriptor for the same number of lanes as D, but with the LaneType T.
// Tag for the same number of lanes as D, but with the LaneType T.
template <class T, class D>
using Rebind = typename D::template Rebind<T>;

Expand All @@ -150,7 +150,7 @@ using RebindToUnsigned = Rebind<MakeUnsigned<TFromD<D>>, D>;
template <class D>
using RebindToFloat = Rebind<MakeFloat<TFromD<D>>, D>;

// Descriptor for the same total size as D, but with the LaneType T.
// Tag for the same total size as D, but with the LaneType T.
template <class T, class D>
using Repartition = typename D::template Repartition<T>;

Expand All @@ -159,7 +159,7 @@ using RepartitionToWide = Repartition<MakeWide<TFromD<D>>, D>;
template <class D>
using RepartitionToNarrow = Repartition<MakeNarrow<TFromD<D>>, D>;

// Descriptor for the same lane type as D, but half the lanes.
// Tag for the same lane type as D, but half the lanes.
template <class D>
using Half = typename D::Half;

Expand Down

0 comments on commit acc21a6

Please sign in to comment.