exportT → export_tab

also remove exportN as it's unused
This commit is contained in:
dzaima 2025-02-01 21:37:08 +02:00
parent 70e2694f88
commit a3e33366df
10 changed files with 26 additions and 28 deletions

View File

@ -29,8 +29,7 @@ The SIMD operations listed aren't guaranteed to be supported on all targets, nor
- `reinterpret` is available as `~~` - `reinterpret` is available as `~~`
<!-- --> <!-- -->
- `exportN{f, 'name1', 'name2', ...}` - export single function under many names - `export_tab{'name', fs}` - export list of functions as the specified name
- `exportT{'name', fs}` - export list of functions as the specified name
- `iota{knum}` - tuple `tup{0,1,...,knum-1}` - `iota{knum}` - tuple `tup{0,1,...,knum-1}`
- `broadcast{knum,v}` (`knum**v`) - tuple with `knum` items, all `v` - `broadcast{knum,v}` (`knum**v`) - tuple with `knum` items, all `v`
- `tern{c, t, f}` - ternary - if `c`, return `t`, else `f` - `tern{c, t, f}` - ternary - if `c`, return `t`, else `f`

View File

@ -27,8 +27,7 @@ def any_int = match { {x:T}=>isint{T}; {x} => knum{x} and (x>>0) == x }
def elwidth{T} = width{eltype{T}} def elwidth{T} = width{eltype{T}}
def reinterpret{T, x:T} = x def reinterpret{T, x:T} = x
def exportN{f, ...ns} = each{export{.,f}, ns} def export_tab{name, fs} = { v:*oneType{fs} = fs; export{name, v} }
def exportT{name, fs} = { v:*oneType{fs} = fs; export{name, v} }
oper &~ andnot infix none 35 oper &~ andnot infix none 35
def andnot{a, b:T if any_int{a} and isprim{T}} = a & ~b def andnot{a, b:T if any_int{a} and isprim{T}} = a & ~b

View File

@ -301,11 +301,11 @@ def bin_search_vec{prim, T, w:*T, wn, x:*T, xn, rp, maxwn if hasarch{'AVX2'}} =
fn avx2_search_bin{prim, T, maxwn}(rp:*(if (prim=='∊') u64 else i8), w:*void, wn:u64, x:*void, xn:u64) : void = { fn avx2_search_bin{prim, T, maxwn}(rp:*(if (prim=='∊') u64 else i8), w:*void, wn:u64, x:*void, xn:u64) : void = {
bin_search_vec{prim, T, *T~~w, wn, *T~~x, xn, rp, maxwn} bin_search_vec{prim, T, *T~~w, wn, *T~~x, xn, rp, maxwn}
} }
exportT{ export_tab{
'avx2_member_sort', 'avx2_member_sort',
each{avx2_search_bin{'∊',.,.}, tup{i16,i32}, tup{32,16}} each{avx2_search_bin{'∊',.,.}, tup{i16,i32}, tup{32,16}}
} }
exportT{ export_tab{
'avx2_indexOf_sort', 'avx2_indexOf_sort',
each{avx2_search_bin{'⊐',.,.}, tup{i8,i16,i32}, tup{64,16,16}} each{avx2_search_bin{'⊐',.,.}, tup{i8,i16,i32}, tup{64,16,16}}
} }
@ -366,7 +366,7 @@ fn bins{T, up}(w:*void, wn:u64, x:*void, xn:u64, rp:*void, rty:u8) : void = {
} }
} }
exportT{ export_tab{
'si_bins', 'si_bins',
join{table{bins, tup{i8,i16,i32,f64}, tup{1,0}}} join{table{bins, tup{i8,i16,i32,f64}, tup{1,0}}}
} }
@ -386,7 +386,7 @@ fn saturate{F,T,...up}(dst:*void, src:*void, n:u64) : void = {
} }
} }
exportT{ export_tab{
'si_saturate', 'si_saturate',
each{{a}=>saturate{...a}, merge{ each{{a}=>saturate{...a}, merge{
tup{tup{i16,i8}, tup{i32,i8}, tup{i32,i16}}, tup{tup{i16,i8}, tup{i32,i8}, tup{i32,i16}},

View File

@ -20,7 +20,7 @@ fn bitsel_i{VL,T}(r:*void, bits:*u64, e0:u64, e1:u64, len:u64) : void = {
def table{w} = each{bitsel_i{w, .}, tup{u8, u16, u32, u64}} def table{w} = each{bitsel_i{w, .}, tup{u8, u16, u32, u64}}
exportT{'simd_bitsel', table{arch_defvw}} export_tab{'simd_bitsel', table{arch_defvw}}
fn blend_arr_scalar{E}(rp:*void, zero:*void, one0:u64, mask:*void, len:u64) : void = { fn blend_arr_scalar{E}(rp:*void, zero:*void, one0:u64, mask:*void, len:u64) : void = {
if (same{E,'!'}) { if (same{E,'!'}) {
@ -35,7 +35,7 @@ fn blend_arr_scalar{E}(rp:*void, zero:*void, one0:u64, mask:*void, len:u64) : vo
} }
} }
exportT{'si_blend_arr_scalar', each{blend_arr_scalar, tup{u1, '!', '!', u8, u16, u32, u64}}} export_tab{'si_blend_arr_scalar', each{blend_arr_scalar, tup{u1, '!', '!', u8, u16, u32, u64}}}
(if (has_sel) { (if (has_sel) {
fn bitwiden_n_8(src:*void, dst:*void, csz:ux, cam:ux) : void = { fn bitwiden_n_8(src:*void, dst:*void, csz:ux, cam:ux) : void = {

View File

@ -130,9 +130,9 @@ def tableAA{w, F, F_bit} = table{1, F, w, {} => bitAA{F_bit}, {V, u} => aa2bit{V
def tableAS{w, F } = table{0, F, w, {} => bitAS{F}, {V, u} => as2bit{V, u, F}} def tableAS{w, F } = table{0, F, w, {} => bitAS{F}, {V, u} => as2bit{V, u, F}}
exportT{'simd_eqAS', tableAS{arch_defvw, __eq}}; exportT{'simd_eqAA', tableAA{arch_defvw, __eq, {a,b}=>a ^ ~b}} export_tab{'simd_eqAS', tableAS{arch_defvw, __eq}}; export_tab{'simd_eqAA', tableAA{arch_defvw, __eq, {a,b}=>a ^ ~b}}
exportT{'simd_neAS', tableAS{arch_defvw, __ne}}; exportT{'simd_neAA', tableAA{arch_defvw, __ne, {a,b}=>a ^ b}} export_tab{'simd_neAS', tableAS{arch_defvw, __ne}}; export_tab{'simd_neAA', tableAA{arch_defvw, __ne, {a,b}=>a ^ b}}
exportT{'simd_gtAS', tableAS{arch_defvw, __gt}}; exportT{'simd_gtAA', tableAA{arch_defvw, __gt, {a,b}=>a & ~b}} export_tab{'simd_gtAS', tableAS{arch_defvw, __gt}}; export_tab{'simd_gtAA', tableAA{arch_defvw, __gt, {a,b}=>a & ~b}}
exportT{'simd_geAS', tableAS{arch_defvw, __ge}}; exportT{'simd_geAA', tableAA{arch_defvw, __ge, {a,b}=>a | ~b}} export_tab{'simd_geAS', tableAS{arch_defvw, __ge}}; export_tab{'simd_geAA', tableAA{arch_defvw, __ge, {a,b}=>a | ~b}}
exportT{'simd_ltAS', tableAS{arch_defvw, __lt}} export_tab{'simd_ltAS', tableAS{arch_defvw, __lt}}
exportT{'simd_leAS', tableAS{arch_defvw, __le}} export_tab{'simd_leAS', tableAS{arch_defvw, __le}}

View File

@ -15,4 +15,4 @@ fn absFn{T}(r:*void, x:*void, len:u64) : u64 = {
len len
} }
exportT{'simd_abs', each{absFn, tup{i8, i16, i32, f64}}} export_tab{'simd_abs', each{absFn, tup{i8, i16, i32, f64}}}

View File

@ -54,8 +54,8 @@ fn rep_by_scan{W, T}(wp:*void, xv:*void, rv:*void, s:usz) : void = {
rep_by_scan{T, *W~~wp, xv, rv, s} rep_by_scan{T, *W~~wp, xv, rv, s}
} }
exportT{'si_indices_scan_i32', each{ind_by_scan_i32, ind_types}} export_tab{'si_indices_scan_i32', each{ind_by_scan_i32, ind_types}}
exportT{'si_replicate_scan', flat_table{rep_by_scan, ind_types, dat_types}} export_tab{'si_replicate_scan', flat_table{rep_by_scan, ind_types, dat_types}}
# Constant replicate # Constant replicate
@ -284,7 +284,7 @@ fn rep_const{T}(wv:u64, x:*void, r:*void, n:u64) : void = {
} }
exportT{'si_constrep', each{rep_const, dat_types}} export_tab{'si_constrep', each{rep_const, dat_types}}

View File

@ -343,7 +343,7 @@ fn getRange{E}(x0:*void, res:*i64, n:u64) : u1 = {
1 1
} }
exportT{'simd_getRangeRaw', each{getRange, tup{i8,i16,i32,f64}}} export_tab{'simd_getRangeRaw', each{getRange, tup{i8,i16,i32,f64}}}
# Hash tables # Hash tables
@ -658,6 +658,6 @@ def try_vec_memb{T==u32, hash, sz, sh, maxh, has_maxh, swap, rp, fp, n, done
} }
def exp_hash{name} = { def exp_hash{name} = {
exportT{merge{'si_',name,'_c2_hash'}, each{hashtab{., name}, tup{u32,u64}}} export_tab{merge{'si_',name,'_c2_hash'}, each{hashtab{., name}, tup{u32,u64}}}
} }
each{exp_hash, names} each{exp_hash, names}

View File

@ -64,7 +64,7 @@ fn wrap_inds{TI if issigned{TI}}(src:*void, dst:*void, n:u64, cyc0:u64) : void =
@for (src in *TI~~src, dst in *TI~~dst over n) dst = tern{src<0, src+cyc, src} @for (src in *TI~~src, dst in *TI~~dst over n) dst = tern{src<0, src+cyc, src}
} }
} }
exportT{'si_wrap_inds', each{wrap_inds, tup{i8}}} export_tab{'si_wrap_inds', each{wrap_inds, tup{i8}}}
@ -146,7 +146,7 @@ export{'INDS_BUF_MAX_COPY', ux~~inds_buf_max}
def null_fn = select_rows_fn{void, 'BAD', 0, {..._} => { emit{void,'fatal','"bad select_rows"'}; 0 }} def null_fn = select_rows_fn{void, 'BAD', 0, {..._} => { emit{void,'fatal','"bad select_rows"'}; 0 }}
export{'null_fn', null_fn} export{'null_fn', null_fn}
export{'select_rows_tab_h', ux~~select_rows_tab_h} export{'select_rows_tab_h', ux~~select_rows_tab_h}
exportT{'select_rows_tab', join{flip{each{{row} => { export_tab{'select_rows_tab', join{flip{each{{row} => {
def a = each{select{.,0}, row} + 0 # +0 to work around findmatches bug def a = each{select{.,0}, row} + 0 # +0 to work around findmatches bug
def b = 1<<range{select_rows_tab_h} def b = 1<<range{select_rows_tab_h}
each{match { {{i}}=>select{select{row,i},2}; {{}}=>null_fn }, findmatches{a, b}} each{match { {{i}}=>select{select{row,i},2}; {{}}=>null_fn }, findmatches{a, b}}
@ -175,7 +175,7 @@ export{'INDS_BUF_MAX_COPY', ux~~inds_buf_max}
} }
sh sh
} }
exportT{'select_rows_widen', each{{t0, t1} => { export_tab{'select_rows_widen', each{{t0, t1} => {
def {S, D} = each{select{tup{u8,u16,u32,u64},.}, tup{t0, t1}} def {S, D} = each{select{tup{u8,u16,u32,u64},.}, tup{t0, t1}}
select_rows_widen{t1-t0} select_rows_widen{t1-t0}
}, select_rows_better, range{4}}} }, select_rows_better, range{4}}}
@ -259,7 +259,7 @@ fn select_fn{rw, TI, TD}(w0:*void, x0:*void, r0:*void, wl:u64, xl:u64) : u1 = {
} }
def select_fn{TI, TD} = select_fn{arch_defvw, TI, TD} def select_fn{TI, TD} = select_fn{arch_defvw, TI, TD}
exportT{'si_select_tab', join{table{select_fn, export_tab{'si_select_tab', join{table{select_fn,
tup{i8, i16, i32}, # indices tup{i8, i16, i32}, # indices
tup{u8, u16, u32, u64}}} # values tup{u8, u16, u32, u64}}} # values
} }

View File

@ -464,6 +464,6 @@ def tr_types = tup{i8, i16, i32, i64}
def tr_kernels = if (not avx2) tup{ 8, 8, 4, 0 } def tr_kernels = if (not avx2) tup{ 8, 8, 4, 0 }
else tup{16, tup{8, 16}, 8, 4 } else tup{16, tup{8, 16}, 8, 4 }
exportT{'simd_transpose', each{transpose, tr_types, tr_kernels}} export_tab{'simd_transpose', each{transpose, tr_types, tr_kernels}}
exportT{'interleave_fns', each{interleave, tr_types}} export_tab{'interleave_fns', each{interleave, tr_types}}