From d039562efe5fca8891d2ba2c8e0fd0593edd0c73 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sun, 6 Aug 2023 08:09:08 -0400 Subject: [PATCH] Fix disabled BMI2 boolean Compress; cleaner SIMD width system --- src/singeli/src/slash.singeli | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/singeli/src/slash.singeli b/src/singeli/src/slash.singeli index e1f9b89a..94d2349e 100644 --- a/src/singeli/src/slash.singeli +++ b/src/singeli/src/slash.singeli @@ -289,6 +289,7 @@ export{'si_2slash64', slash{1, i64}}; export{'si_thresh_2slash64', u64~~thresh{1 def scalwidth{T} = if (isvec{T}) elwidth{T} else width{T} # pext, or boolean compress +def pext_width{} = if (hasarch{'AVX2'}) 4 else 1 def pext_popc{x:T, m:T} = { def w = scalwidth{T} def scal{v} = if (isvec{T}) T**v else v @@ -345,6 +346,7 @@ def pext_popc{x:T, m:T} = { tup{pe, scal{w} - z} } +def pext_width{..._ & hasarch{'PCLMUL'} > hasarch{'AVX2'}} = 2 def pext_popc{x0:V, m0:V & hasarch{'PCLMUL'} & V==[2]u64} = { def clmul{a, b} = zipLo{...@collect (j to 2) clmul{a,b,j}} m := m0 @@ -363,6 +365,7 @@ def pext_popc{x0:V, m0:V & hasarch{'PCLMUL'} & V==[2]u64} = { tup{x, @collect (j to 2) popc{extract{m0,j}}} } +def pext_width{..._ & hasarch{'BMI2'}} = 1 def pext_popc{x:T, m:T & hasarch{'BMI2'} & T==u64} = tup{pext{x, m}, popc{m}} fn compress_bool(w:*u64, x:*u64, r:*u64, n:u64) : void = { @@ -378,8 +381,8 @@ fn compress_bool(w:*u64, x:*u64, r:*u64, n:u64) : void = { ro = ro2%64 } def extract{t, i & istup{t}} = tupsel{i,t} - if (hasarch{'PCLMUL'} or hasarch{'AVX2'}) { - def v = if (hasarch{'AVX2'}) 4 else 2 + def v = pext_width{} + if (v > 1) { def V = [v]u64 d := cdiv{n,64}; e := d/v @for (w in *V~~w, x in *V~~x over i to cdiv{d,v}) {