From 9b17701c6684929313e74a4a53dc6aa771881c83 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sun, 11 Sep 2022 20:08:20 -0400 Subject: [PATCH] Sparse 1- and 2-byte compress, with blocking, if total sum is low enough --- src/builtins/slash.c | 46 +++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/builtins/slash.c b/src/builtins/slash.c index a0dc8ef2..1dd24b4f 100644 --- a/src/builtins/slash.c +++ b/src/builtins/slash.c @@ -262,7 +262,6 @@ static B where(B x, usz xia, u64 s) { } static B compress(B w, B x, usz wia, B xf) { - B r; u64* wp = bitarr_ptr(w); u64 we = 0; usz ie = wia/64; @@ -273,11 +272,14 @@ static B compress(B w, B x, usz wia, B xf) { } wia = 64*(ie+1) - CLZ(we); usz wsum = bit_sum(wp, wia); + + B r; u8 xe = TI(x,elType); - #ifdef __BMI2__ - switch(xe) { + switch(xe) { default: UD; case el_bit: { - u64* xp = bitarr_ptr(x); u64* rp; r = m_bitarrv(&rp,wsum+128); a(r)->ia = wsum; + u64* xp = bitarr_ptr(x); u64* rp; + #if SINGELI && defined(__BMI2__) + r = m_bitarrv(&rp,wsum+128); a(r)->ia = wsum; u64 cw = 0; // current word u64 ro = 0; // offset in word where next bit should be written; never 64 for (usz i=0; i=wia/CUTOFF) { DENSE; } \ + else { rp=m_tyarrv(&r,W/8,wsum,el2t(xe)); COMPRESS_BLOCK(i##W); } \ + break; } + #if SINGELI + case el_i8: case el_c8: WITH_SPARSE( 8, 32, rp=m_tyarrvO(&r,1,wsum,el2t(xe), 8); bmipopc_2slash8 (wp, xp, rp, wia)) + case el_i16:case el_c16: WITH_SPARSE(16, 16, rp=m_tyarrvO(&r,2,wsum,el2t(xe), 16); bmipopc_2slash16(wp, xp, rp, wia)) + #else + case el_i8: case el_c8: WITH_SPARSE( 8, 2, rp=m_tyarrv(&r,1,wsum,el2t(xe)); for (usz i=0; i