native 0.0.1
Vectors, masks and wide register packs for C++26
Loading...
Searching...
No Matches
exports.h
1#pragma once
2// Shared export declarations, included only below a named-module declaration.
3// Primitive and array-kernel definitions are in the GMF; wide is imported.
4// SPDX-FileCopyrightText: 2026 Edward Kmett <ekmett@gmail.com>
5// SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0
6
7export namespace native {
8 using std::int8_t;
9 using std::int16_t;
10 using std::int32_t;
11 using std::int64_t;
12 using std::uint8_t;
13 using std::uint16_t;
14 using std::uint32_t;
15 using std::uint64_t;
16 using ::native::simd_traits;
17 using ::native::simd_customization;
18 using ::native::simd_custom_element;
19 using ::native::simd_integer_element;
20 using ::native::imm_t;
21 using ::native::imm;
22 using ::native::simd_access;
23 using ::native::simd_memory;
24 using ::native::load_simd;
26 using ::native::store_simd;
28 using ::native::compaction_result;
29 using ::native::compress;
30 using ::native::expand;
32
34 using ::native::operator+;
36 using ::native::operator-;
38 using ::native::operator*;
40 using ::native::operator/;
42 using ::native::operator%;
44 using ::native::operator&;
46 using ::native::operator|;
48 using ::native::operator^;
49 using ::native::operator<<;
51 using ::native::operator>>;
53 using ::native::operator!;
55 using ::native::operator~;
57 using ::native::operator==;
59 using ::native::operator!=;
60 using ::native::operator<;
61 using ::native::operator<=;
63 using ::native::operator>;
65 using ::native::operator>=;
67 using ::native::operator+=;
69 using ::native::operator-=;
71 using ::native::operator*=;
73 using ::native::operator/=;
75 using ::native::operator%=;
77 using ::native::operator&=;
79 using ::native::operator|=;
81 using ::native::operator^=;
82 using ::native::operator<<=;
84 using ::native::operator>>=;
85
86 using ::native::wide;
87 using ::native::simd;
88 using ::native::predicate;
89 using ::native::scalar;
90 using ::native::avx2;
91 using ::native::avx512;
92 using ::native::avx512_bf16;
93 using ::native::avx512_fp16;
94 using ::native::neon;
95 using ::native::neon_fp16;
96 using ::native::neon_bf16;
97 using ::native::isa;
98 using ::native::arch;
99 using ::native::mask_lane;
100 using ::native::mask8;
101 using ::native::mask16;
102 using ::native::mask32;
103 using ::native::mask64;
104 using ::native::simd_mask_element;
105 using ::native::flush_to_zero;
106 using ::native::convert;
107#if NATIVE_HOST_NEON
108 using ::native::fcvtzs;
109 using ::native::fcvtzu;
110#endif
112 using ::native::popcount;
115 using ::native::reduce_add;
116 using ::native::mask_bits;
117 using ::native::mask_cast;
118 using ::native::to_bool;
119 using ::native::to_predicate;
122 using ::native::bit_select;
123 using ::native::select;
125 using ::native::masked_add;
128 using ::native::masked_sub;
131 using ::native::masked_mul;
133 using ::native::masked_scaleb;
135 using ::native::scaleb;
136 using ::native::fma;
137 using ::native::broadcast;
138 using ::native::abs;
139 using ::native::sqrt;
140 using ::native::floor;
141 using ::native::ceil;
142 using ::native::trunc;
143 using ::native::round_even;
144
145 using ::native::narrow_concat;
146}
147
148#if NATIVE_HOST_WASM
149export namespace native {
150 using ::native::normal_pow2;
151 using ::native::shuffle;
152 using ::native::swizzle;
153 using ::native::add_sat;
154 using ::native::sub_sat;
155 using ::native::average_round;
156 using ::native::min;
157 using ::native::max;
158 using ::native::pmin;
159 using ::native::pmax;
160 using ::native::extend_low;
161 using ::native::extend_high;
164 using ::native::bitmask;
165 using ::native::any;
166 using ::native::all;
167 using ::native::narrow_sat;
168 using ::native::q15mulr_sat;
169 using ::native::dot;
170 using ::native::trunc_sat;
171 using ::native::load_splat;
172 using ::native::load_zero;
173 using ::native::load_lane;
174 using ::native::store_lane;
175 using ::native::load_widened;
176}
177#endif
constexpr simd< T, N, Arch > masked_add_zero(M m, simd< T, N, Arch > a, simd< T, N, Arch > b) noexcept
constexpr simd< T, N, Arch > masked_mul(M m, simd< T, N, Arch > prior, simd< T, N, Arch > a, simd< T, N, Arch > b) noexcept
constexpr simd< T, N, Arch > masked_mul_zero(M m, simd< T, N, Arch > a, simd< T, N, Arch > b) noexcept
constexpr simd< U, N, Arch > mask_cast(simd< T, N, Arch > value) noexcept
constexpr simd< T, N, Arch > masked_add(M m, simd< T, N, Arch > prior, simd< T, N, Arch > a, simd< T, N, Arch > b) noexcept
constexpr simd< T, N, Arch > masked_sub_zero(M m, simd< T, N, Arch > a, simd< T, N, Arch > b) noexcept
constexpr simd< T, N, Arch > masked_sub(M m, simd< T, N, Arch > prior, simd< T, N, Arch > a, simd< T, N, Arch > b) noexcept
constexpr simd< float, N, Arch > ceil(simd< float, N, Arch > x) noexcept
constexpr auto abs(simd< float, N, Arch > a) noexcept
constexpr simd< float, N, Arch > trunc(simd< float, N, Arch > x) noexcept
constexpr simd< float, N, Arch > floor(simd< float, N, Arch > x) noexcept
constexpr void store_simd(U *p, V value, simd_memory< A, Access >={}) noexcept(noexcept(value.template store_memory< A >(p)))
Definition common_body.h:58
simd_access
Definition common.h:282
constexpr V load_simd(U const *p, simd_memory< A, Access >={}) noexcept(noexcept(V::template load_memory< A >(p)))
Definition common_body.h:40
constexpr V load_simd_partial(U const *p, std::size_t count, typename V::value_type fill={}, simd_memory< A, Access >={}) noexcept(std::is_nothrow_default_constructible_v< U > &&std::is_nothrow_constructible_v< U, typename V::value_type & > &&std::is_nothrow_copy_assignable_v< U > &&noexcept(::native::load_simd< V >(p)))
Definition common_body.h:96
constexpr void store_simd_partial(U *p, V value, std::size_t count, simd_memory< A, Access >={}) noexcept(std::is_nothrow_default_constructible_v< U > &&std::is_nothrow_copy_assignable_v< U > &&noexcept(::native::store_simd(p, value)))
constexpr imm_t< K > imm
Definition common.h:82
Architecture-tagged vectors, register packs and supporting value types. Native arithmetic follows its...
constexpr simd< std::int16_t, 8, A > q15mulr_sat(simd< std::int16_t, 8, A > a, simd< std::int16_t, 8, A > b) noexcept
Multiply signed Q15 lanes, round by adding 2^14, shift by 15 and saturate.
constexpr simd< T, N, A > average_round(simd< T, N, A > a, simd< T, N, A > b) noexcept
Rounded unsigned average: (a+b+1)/2 without intermediate overflow.
constexpr auto multiply_widened_high(simd< T, N, A > a, simd< T, N, A > b) noexcept
Multiply widened upper integer lanes; the complete product fits.
constexpr simd< T, N, A > sqrt(simd< T, N, A > v) noexcept
Compute correctly rounded square roots; negative finite lanes produce NaN.
constexpr bool all(simd< T, N, A > a) noexcept
Test whether every integer lane is nonzero.
constexpr std::size_t compress_store(T *p, std::size_t capacity, typename simd< T, N, A >::mask mask, simd< T, N, A > value) noexcept
Write only the selected prefix that fits capacity; zero writes permit null.
wide(T, U...) -> wide< T, 1+sizeof...(U)>
Deduce the common element type and the number of homogeneous constructor arguments.
constexpr simd< To, N *2, A > narrow_sat(simd< From, N, A > a, simd< From, N, A > b) noexcept
Saturating concatenate from signed source lanes, including unsigned destinations.
constexpr auto to_predicate(detail::polyfill_predicate< N, A > mask) noexcept
Preserve a logical compact predicate already in canonical form.
constexpr simd< std::make_unsigned_t< T >, N, A > mask_bits(detail::polyfill_predicate< N, A > mask) noexcept
Expand each logical predicate bit into an unsigned zero/all-one lane.
constexpr simd< T, N, A > pmax(simd< T, N, A > a, simd< T, N, A > b) noexcept
Pseudo minimum/maximum selects the first operand for unordered or equal lanes.
constexpr simd< T, N, A > shuffle(simd< T, N, A > a, simd< T, N, A > b) noexcept
Select N lanes from the concatenation of two inputs, using constant indices.
constexpr simd< T, N, A > round_even(simd< T, N, A > v) noexcept
Round floating lanes to nearest integers, choosing even at ties.
constexpr simd< T, N, A > add_sat(simd< T, N, A > a, simd< T, N, A > b) noexcept
Saturate signed or unsigned byte/halfword arithmetic at the lane limits.
constexpr simd< T, N, A > broadcast(simd< T, N, A > value, imm_t< I >) noexcept
Broadcast one compile-time-selected logical lane.
constexpr auto extend_high(simd< T, N, A > a) noexcept
Widen the upper half of integer lanes, preserving signedness.
constexpr simd< T, N, A > to_vector_mask(detail::polyfill_predicate< N, A > mask) noexcept
Expand a logical compact mask into canonical full-vector lanes.
constexpr simd< T, N, A > pmin(simd< T, N, A > a, simd< T, N, A > b) noexcept
Pseudo minimum/maximum selects the first operand for unordered or equal lanes.
constexpr simd< bool, N, A > to_bool(detail::polyfill_predicate< N, A > mask) noexcept
Expand compact truth to zero-or-one Boolean data lanes.
constexpr auto multiply_widened_low(simd< T, N, A > a, simd< T, N, A > b) noexcept
Multiply widened lower integer lanes; the complete product fits.
constexpr simd< fp16, 32, Arch > fma(simd< fp16, 32, Arch > a, simd< fp16, 32, Arch > b, simd< fp16, 32, Arch > c) noexcept
constexpr simd< To, 4, A > trunc_sat(simd< From, N, A > a) noexcept
constexpr simd< float, N, A > masked_scaleb(M mask, simd< float, N, A > prior, simd< float, N, A > value, simd< float, N, A > exponent) noexcept
constexpr simd< T, N, A > bit_select(simd< U, N, A > mask, simd< T, N, A > a, simd< T, N, A > b) noexcept
Select individual representation bits without canonicalizing the bit mask.
constexpr simd< std::uint8_t, 16, A > swizzle(simd< std::uint8_t, 16, A > v, simd< std::uint8_t, 16, A > indices) noexcept
Look up byte indices 0..15; every other index produces zero.
constexpr simd< T, N, A > max(simd< T, N, A > a, simd< T, N, A > b) noexcept
Minimum/maximum; floating NaNs propagate and signed zeros follow WebAssembly rules.
constexpr simd< To, 2 *N, Arch > narrow_concat(simd< From, N, Arch > a, simd< From, N, Arch > b) noexcept
constexpr std::uint32_t bitmask(simd< T, N, A > a) noexcept
Gather each integer lane's sign bit into bit i of the scalar result.
constexpr std::array< V, N > flush_to_zero(std::array< V, N > const &x) noexcept
Replace binary32 subnormal lanes with signed zero. Both zero signs, normal values,...
Definition bits_body.h:52
constexpr auto pairwise_add_widened(simd< T, N, Arch > value) noexcept
constexpr V load_splat(typename V::value_type const *p) noexcept
Read one scalar and broadcast it; the access is exactly sizeof(T) bytes.
constexpr simd< std::int32_t, 4, A > dot(simd< std::int16_t, 8, A > a, simd< std::int16_t, 8, A > b) noexcept
Sum adjacent signed halfword products modulo 2^32.
constexpr simd< float, N, A > scaleb(simd< float, N, A > value, simd< float, N, A > exponent) noexcept
Scale every logical lane, preferring each available native scaling register.
constexpr auto reinterpret_bits(simd< From, N, Arch > value) noexcept -> simd< To, sizeof(From) *N/sizeof(To), Arch >
constexpr auto extend_low(simd< T, N, A > a) noexcept
Widen the lower half of integer lanes, preserving signedness.
constexpr simd< T, N, A > select(M mask, simd< T, N, A > a, simd< T, N, A > b) noexcept
Bridge a matching compact mask to native half's existing vector-mask selection.
constexpr simd< float, N, A > masked_scaleb_zero(M mask, simd< float, N, A > value, simd< float, N, A > exponent) noexcept
Scale active lanes and write positive zero to every inactive lane.
constexpr simd< To, 16/sizeof(To), A > load_widened(From const *p) noexcept
Read exactly eight bytes of source lanes and widen them with their signedness.
constexpr float reduce_add(simd< float, N, A > value) noexcept
Sum binary32 logical lanes in increasing order, rounding after each addition.
constexpr simd< T, N, Arch > popcount(simd< T, N, Arch > value) noexcept
constexpr void store_lane(T *p, simd< T, N, A > a) noexcept
Write only lane I to one scalar object.
constexpr V load_zero(typename V::value_type const *p) noexcept
Read one 32- or 64-bit lane and zero the other lanes.
constexpr simd< T, N, A > sub_sat(simd< T, N, A > a, simd< T, N, A > b) noexcept
Saturate signed or unsigned byte/halfword arithmetic at the lane limits.
constexpr simd< To, N, A > convert(simd< From, N, A > value) noexcept
constexpr std::uint64_t reduce_add_widened(simd< T, N, Arch > value) noexcept
constexpr simd< T, N, A > expand(typename simd< T, N, A >::mask mask, simd< T, N, A > packed, simd< T, N, A > prior) noexcept
Expand a globally packed prefix into selected logical lanes, retaining prior elsewhere.
constexpr compaction_result< simd< T, N, A > > compress(typename simd< T, N, A >::mask mask, simd< T, N, A > value, T fill={}) noexcept
Pack selected logical lanes in increasing order, filling the suffix.
constexpr bool any(simd< T, N, A > a) noexcept
Test whether at least one integer lane is nonzero.
constexpr simd< T, N, A > load_lane(T const *p, simd< T, N, A > a) noexcept
Read one scalar into lane I, preserving the other lanes.
constexpr simd< T, N, A > min(simd< T, N, A > a, simd< T, N, A > b) noexcept
Minimum/maximum; floating NaNs propagate and signed zeros follow WebAssembly rules.
isa(E) -> isa< detail::family_of< E > >
Deduce the family from a feature enum; explicit isa<> always names the host family.