Use generic boolean Compress as the sparse case with Singeli

This commit is contained in:
Marshall Lochbaum 2023-08-07 13:44:52 -04:00
parent a7908a10b0
commit 4e9745688b
2 changed files with 11 additions and 6 deletions

View File

@ -442,8 +442,10 @@ static B compress(B w, B x, usz wia, u8 xl, u8 xt) {
u64* xp = bitarr_ptr(x); u64* xp = bitarr_ptr(x);
u64* rp; r = m_bitarrv(&rp,wsum); u64* rp; r = m_bitarrv(&rp,wsum);
#if SINGELI #if SINGELI
si_compress_bool(wp, xp, rp, wia); if (wsum>=wia/si_thresh_compress_bool) {
#else si_compress_bool(wp, xp, rp, wia); break;
}
#endif
u64 o = 0; u64 o = 0;
usz j = 0; usz j = 0;
for (usz i=0; i<BIT_N(wia); i++) { for (usz i=0; i<BIT_N(wia); i++) {
@ -453,7 +455,6 @@ static B compress(B w, B x, usz wia, u8 xl, u8 xt) {
} }
} }
usz q=(-j)%64; if (q) rp[j/64] = o>>q; usz q=(-j)%64; if (q) rp[j/64] = o>>q;
#endif
break; break;
} }
#define COMPRESS_BLOCK_PREP(T, PREP) \ #define COMPRESS_BLOCK_PREP(T, PREP) \

View File

@ -289,7 +289,8 @@ export{'si_2slash64', slash{1, i64}}; export{'si_thresh_2slash64', u64~~thresh{1
def scalwidth{T} = if (isvec{T}) elwidth{T} else width{T} def scalwidth{T} = if (isvec{T}) elwidth{T} else width{T}
# pext, or boolean compress # pext, or boolean compress
def pext_width{} = if (hasarch{'AVX2'}) 4 else 1 def pext_width{} = if (hasarch{'AVX2'}) 4 else 1
def thresh_bool{} = if (hasarch{'AVX2'}) 128 else 16
def pext_popc{x:T, m:T} = { def pext_popc{x:T, m:T} = {
def w = scalwidth{T} def w = scalwidth{T}
def scal{v} = if (isvec{T}) T**v else v def scal{v} = if (isvec{T}) T**v else v
@ -354,7 +355,8 @@ def pext_popc{x:T, m:T} = {
tup{pe, scal{w} - z} tup{pe, scal{w} - z}
} }
def pext_width{..._ & hasarch{'PCLMUL'} > hasarch{'AVX2'}} = 2 def pext_width {..._ & hasarch{'PCLMUL'} > hasarch{'AVX2'}} = 2
def thresh_bool{..._ & hasarch{'PCLMUL'} > hasarch{'AVX2'}} = 32
def pext_popc{x0:V, m0:V & hasarch{'PCLMUL'} & V==[2]u64} = { 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}} def clmul{a, b} = zipLo{...@collect (j to 2) clmul{a,b,j}}
m := m0 m := m0
@ -373,7 +375,8 @@ def pext_popc{x0:V, m0:V & hasarch{'PCLMUL'} & V==[2]u64} = {
tup{x, @collect (j to 2) popc{extract{m0,j}}} tup{x, @collect (j to 2) popc{extract{m0,j}}}
} }
def pext_width{..._ & hasarch{'BMI2'}} = 1 def pext_width {..._ & hasarch{'BMI2'}} = 1
def thresh_bool{..._ & hasarch{'BMI2'}} = 512
def pext_popc{x:T, m:T & hasarch{'BMI2'} & T==u64} = tup{pext{x, m}, popc{m}} 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 = { fn compress_bool(w:*u64, x:*u64, r:*u64, n:u64) : void = {
@ -412,3 +415,4 @@ fn compress_bool(w:*u64, x:*u64, r:*u64, n:u64) : void = {
} }
export{'si_compress_bool', compress_bool} export{'si_compress_bool', compress_bool}
export{'si_thresh_compress_bool', u64~~thresh_bool{}}