Use default bins_lookup if there's no AVX2

This commit is contained in:
Marshall Lochbaum 2023-07-07 08:05:34 -04:00
parent 1080236433
commit 7f5ba961c2

View File

@ -145,7 +145,7 @@ def bins_lookup{I, T, up, w:*T, wn:u64, x:*T, xn:u64, rp:*void} = {
tfree{t0} tfree{t0}
} }
def bins_lookup{I==i8, T==i8, up, w:*T, wn:u64, x:*T, xn:u64, rp:*void} = { def bins_lookup{I==i8, T==i8, up, w:*T, wn:u64, x:*T, xn:u64, rp:*void & hasarch{'AVX2'}} = {
assert{wn < 128} # Total must fit in i8 assert{wn < 128} # Total must fit in i8
def T = i8 def T = i8
def vl = 32 def vl = 32
@ -159,9 +159,9 @@ def bins_lookup{I==i8, T==i8, up, w:*T, wn:u64, x:*T, xn:u64, rp:*void} = {
def plus_scan{tab, len} = { def plus_scan{tab, len} = {
s:i8=0; @for_dir{up} (tab over len) { s += tab; tab = s } s:i8=0; @for_dir{up} (tab over len) { s += tab; tab = s }
} }
def no_bittab = makelabel{}; def done = makelabel{}
if (hasarch{'AVX2'}) {
# Convert to bit table # Convert to bit table
def no_bittab = makelabel{}; def done = makelabel{}
def nb = 256/vl def nb = 256/vl
nu:u8 = 0; def addu{b} = { nu+=popc{b}; b } # Number of uniques nu:u8 = 0; def addu{b} = { nu+=popc{b}; b } # Number of uniques
vb := U~~make{[nb](ty_u{vl}), vb := U~~make{[nb](ty_u{vl}),
@ -213,10 +213,10 @@ def bins_lookup{I==i8, T==i8, up, w:*T, wn:u64, x:*T, xn:u64, rp:*void} = {
} }
goto{done} goto{done}
setlabel{no_bittab} setlabel{no_bittab}
}
plus_scan{t0, 256} plus_scan{t0, 256}
@for (res, x over xn) res = load{t, x} @for (res, x over xn) res = load{t, x}
if (hasarch{'AVX2'}) setlabel{done} setlabel{done}
} }
def bin_search_vec{T, up, w:*T, wn, x:*T, xn, rp, maxwn & hasarch{'AVX2'}} = { def bin_search_vec{T, up, w:*T, wn, x:*T, xn, rp, maxwn & hasarch{'AVX2'}} = {