k/bool cleanup and implementation comments

This commit is contained in:
Marshall Lochbaum 2024-08-14 09:34:19 -04:00
parent bf69705c82
commit b2758d355c
3 changed files with 12 additions and 7 deletions

View File

@ -38,8 +38,13 @@
// COULD consolidate refcount updates for nested 𝕩
// Replicate by constant
// Boolean uses pdep, ≠`, or overwriting
// SHOULD make a shift/mask replacement for pdep
// Boolean uses specialized small-𝕨 methods, ≠`, or overwriting
// 𝕨≤64: Singeli generic and SIMD methods
// 𝕨=2,4,8: Various shift, shuffle, and zip-based loops
// odd 𝕨: Modular permutation
// COULD use pdep or similar to avoid overhead on small results
// Otherwise, factor into power of 2 times odd
// COULD fuse 2×odd, since 2/odd/ has a larger intermediate
// Other typed 𝕩 uses +`, or lots of Singeli
// Fixed shuffles, factorization, partial shuffles, self-overlapping
// Otherwise, cell-by-cell copying

View File

@ -394,9 +394,9 @@ def rep_const_bool_div8{wv, x, r, nw if hasarch{'SSE2'}} = {
def __shl{x:(V), a} = V~~(H~~x << a)
def __shr{x:(V), a} = V~~(H~~x >> a)
def {output, done, flush} = get_boolvec_writer{V, r, nw}
def {output, check_done, flush} = get_boolvec_writer{V, r, nw}
def run24{x, get_halves} = {
i:usz = 0; while (1) {
i:usz = 0; while (1) { check_done{}
xv := load{*V~~(x+i)}; ++i
def getr = zip128{...get_halves{xv}, .}
output{V~~getr{0}}
@ -407,7 +407,7 @@ def rep_const_bool_div8{wv, x, r, nw if hasarch{'SSE2'}} = {
{xv} => { p := pre{xv}; tup{exh{p}, exh{p>>sh}} }
}
def run8{rep_bytes} = {
i:usz = 0; while (1) {
i:usz = 0; while (1) { check_done{}
xh := load{*[16]u8~~(*ty_u{vl}~~x + i)}; ++i
xv := if (avx2) pair{xh, xh} else xh
xe := rep_bytes{xv}
@ -472,8 +472,6 @@ def sel_imm{V=([16]u8), x:X, {...inds}} = {
sel{V, x, make{I, cycle{n, inds}}}
}
def advance_spaced_mask{k, m, sh} = m<<(k-sh) | m>>sh
# Data for the permutation that sends bit i to k*i % width{T}
def modperm_dat{T, k} = {
def w = width{T}

View File

@ -12,3 +12,5 @@ def unaligned_spaced_mask_mod{l:T} = {
def d = cast_i{T, ctz{m}} # = 64%l
tup{m>>d | m<<(l-d), d}
}
def advance_spaced_mask{k, m, sh} = m<<(k-sh) | m>>sh