From 2c9e07f33d34513fd75109fe0be4c4b1cbe96f93 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 5 Jul 2023 21:32:41 -0400 Subject: [PATCH] 1-byte Bins up to 32 unique eleemnts by unique lookup then index --- src/singeli/src/bins.singeli | 42 ++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/src/singeli/src/bins.singeli b/src/singeli/src/bins.singeli index a7926ee3..0d5bf26a 100644 --- a/src/singeli/src/bins.singeli +++ b/src/singeli/src/bins.singeli @@ -95,7 +95,7 @@ def bin_search_vec{up, w:*i8, wn, x:*i8, n, res:*i8} = { v := pair{h,h} {i} => sel{H, v, i} } - if (hasarch{'AVX2'} and wn < 16) { + if (hasarch{'AVX2'} and wn < 8) { log := ceil_log2{wn+1} l := 1< V**0} + @collect (t in *V~~t0 over nb) addu{homMask{t > V**0}} + } + dup := promote{u64,nu} < wn + # Unique index to w index conversion + ui := undefined{V}; ui1 := undefined{V} + if (dup) { + if (nu > vl) goto{no_bittab} + # We'll subtract 1 when indexing so the initial 0 isn't needed + tui:*i8 = copy{vl, 0}; i:T = 0 + @for (tui over promote{u64,nu}) { i += load{t, load{w, i}}; tui = i } + ui = load{*V~~tui, 0} + if (nu > 16) ui1 = shuf{[4]u64, ui, 4b3232} + ui = shuf{[4]u64, ui, 4b1010} } # Popcount on 8-bit values def sums{n} = if (n==1) tup{0} else { def s=sums{n/2}; merge{s,s+1} } @@ -140,10 +153,10 @@ def bin_search_vec{up, w:*i8, wn, x:*i8, n, res:*i8} = { s{shr16{v,4}} + s{v} } # 32-byte select - vtop := U**(vl/2) + vtop := V**(vl/2) def getsel{v & width{type{v}}==256} = { hs := each{bind{shuf, [4]u64, v}, tup{4b3232, 4b1010}} - {i} => homBlend{...each{{h}=>sel{H,h,i}, hs}, i homBlend{...each{{h}=>sel{H,h,i}, hs}, V~~i 16) ind = homBlend{sel{H,ui1,i0}, ind, i0