From 5a2b7551915eb5dd4736f509f12d70c4af1b8d47 Mon Sep 17 00:00:00 2001 From: dzaima Date: Sun, 2 Apr 2023 15:55:49 +0300 Subject: [PATCH] move non-AVX2 x86-64 into SINGELI_SIMD --- build/src/build.bqn | 2 +- src/builtins/arithd.c | 4 ++-- src/builtins/arithm.c | 4 ++-- src/builtins/cmp.c | 2 +- src/builtins/squeeze.c | 12 ++++++------ src/core/stuff.c | 2 +- src/utils/bits.c | 4 ++-- src/utils/mut.c | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/build/src/build.bqn b/build/src/build.bqn index c06ef721..46468f1d 100755 --- a/build/src/build.bqn +++ b/build/src/build.bqn @@ -266,7 +266,7 @@ po ← { # parsed options args∾↩ GetOpt "CCFLAGS" args∾↩ (singeli ∧ arch≡ "x86-64") / ⟨"-DSINGELI_X86_64"⟩ ∾ avx2 / ⋈"-DSINGELI_AVX2" args∾↩ (singeli ∧ arch≡"aarch64") / ⟨"-DSINGELI_NEON"⟩ - args∾↩ (singeli ∧ avx2∨arch≡"aarch64") / ⟨"-DSINGELI_SIMD"⟩ + args∾↩ (singeli ∧ ⊑arch<⊸∊"x86-64"‿"aarch64") / ⟨"-DSINGELI_SIMD"⟩ args∾↩ ( wasm) / ⟨"-DWASM"⟩ args∾↩ ( wasi) / ⟨"-DWASI", "-DNO_MMAP", "-DCATCH_ERRORS=0", "-D_WASI_EMULATED_MMAN", "--target=wasm32-wasi"⟩ args∾↩ ( emcc) / ⟨"-DEMCC", "-O3"⟩ diff --git a/src/builtins/arithd.c b/src/builtins/arithd.c index 1722d28b..1e85f670 100644 --- a/src/builtins/arithd.c +++ b/src/builtins/arithd.c @@ -21,7 +21,7 @@ B atan2_c2(B, B, B); typedef void (*AndBytesFn)(u8*, u8*, u64, u64); -#if SINGELI_SIMD || SINGELI_X86_64 +#if SINGELI_SIMD #include "../singeli/c/arithdDispatch.c" static AndBytesFn andBytes_fn = simd_andBytes; #else @@ -217,7 +217,7 @@ static B modint_AS(B w, B xv) { return modint_AA(w, C2(shape, C1(fne, incG(w)) #undef GC2f - #if SINGELI_SIMD || SINGELI_X86_64 + #if SINGELI_SIMD #define AA_DISPATCH(NAME) FORCE_INLINE B NAME##_AA(B t, B w, B x) { return dyArith_AA(&NAME##DyTableAA, w, x); } AA_DISPATCH(add) AA_DISPATCH(or) AA_DISPATCH(sub) diff --git a/src/builtins/arithm.c b/src/builtins/arithm.c index 2922191e..7737ff53 100644 --- a/src/builtins/arithm.c +++ b/src/builtins/arithm.c @@ -29,7 +29,7 @@ B add_c1(B t, B x) { dec(eachm_fn(m_f64(0), inc(x), add_c1)); return x; } -#if SINGELI_SIMD || SINGELI_X86_64 +#if SINGELI_SIMD #define SINGELI_FILE monarith #include "../utils/includeSingeli.h" #endif @@ -60,7 +60,7 @@ B add_c1(B t, B x) { #define SIGN_EXPR(T, C) rp[i] = c>0? 1 : c==0? 0 : -1; #define SIGN_MAIN(FEXPR) LOOP_BODY(i8* rp; B r=m_i8arrc(&rp,x);, SIGN_EXPR,) -#if SINGELI_SIMD || SINGELI_X86_64 +#if SINGELI_SIMD #define STILE_BODY(FEXPR) { usz ia = IA(x); B r; retry:; \ void* rp = m_tyarrlc(&r, elWidth(xe), x, el2t(xe)); \ u64 got = simd_abs[xe-el_i8](rp, tyany_ptr(x), ia); \ diff --git a/src/builtins/cmp.c b/src/builtins/cmp.c index 23502f5f..4741630c 100644 --- a/src/builtins/cmp.c +++ b/src/builtins/cmp.c @@ -54,7 +54,7 @@ CMP_REC(ne, ne, swapped=0;) #define FN_LUT_C(B,A,F,S) FN_LUT_T(B,F,S)[] = {CMPFN(A,F,S,u1), CMPFN(A,F,S,i8), CMPFN(A,F,S,i16), CMPFN(A,F,S,i32), CMPFN(A,F,S,f64), CMPFN(A,F,S,u8), CMPFN(A,F,S,u16), CMPFN(A,F,S,u32)} #define FN_LUT_A(B,F,S) FN_LUT_T(B,F,S)[8] -#if SINGELI_SIMD || SINGELI_X86_64 +#if SINGELI_SIMD #include "../singeli/c/cmp.c" #else void cmpA_init(void) { } diff --git a/src/builtins/squeeze.c b/src/builtins/squeeze.c index 1e69b205..f8c63592 100644 --- a/src/builtins/squeeze.c +++ b/src/builtins/squeeze.c @@ -1,6 +1,6 @@ #include "../core.h" -#if SINGELI_SIMD || SINGELI_X86_64 +#if SINGELI_SIMD #define SINGELI_FILE squeeze #include "../utils/includeSingeli.h" #endif @@ -36,14 +36,14 @@ B num_squeeze(B x) { goto r_bit; } - #if !SINGELI_SIMD && !SINGELI_X86_64 + #if !SINGELI_SIMD usz i = 0; #endif u32 or = 0; // using bitwise or as an approximate ⌈´ switch (xe) { default: UD; case el_bit: goto r_x; - #if SINGELI_SIMD || SINGELI_X86_64 + #if SINGELI_SIMD case el_i8: { or = avx2_squeeze_i8 (i8any_ptr (x), ia); if(or> 1) goto r_x; else goto mostBit; } case el_i16: { or = avx2_squeeze_i16(i16any_ptr(x), ia); if(or> I8_MAX) goto r_x; else goto mostI8; } case el_i32: { or = avx2_squeeze_i32(i32any_ptr(x), ia); if(or> I16_MAX) goto r_x; else goto mostI16; } @@ -69,7 +69,7 @@ B num_squeeze(B x) { B* xp = arr_bptr(x); if (xp==NULL) goto r_f; - #if SINGELI_SIMD || SINGELI_X86_64 + #if SINGELI_SIMD or = avx2_squeeze_numB(xp, ia); if (-2==(i32)or) goto r_x; if (-1==(i32)or) goto r_f64; @@ -117,7 +117,7 @@ B chr_squeeze(B x) { i32 or = 0; switch(xe) { default: UD; case el_c8: goto r_x; - #if SINGELI_SIMD || SINGELI_X86_64 + #if SINGELI_SIMD case el_c16: { u32 t = avx2_squeeze_c16(c16any_ptr(x), ia); if (t==0) goto r_c8; else goto r_x; } case el_c32: { u32 t = avx2_squeeze_c32(c32any_ptr(x), ia); if (t==0) goto r_c8; else if (t==1) goto r_c16; else if (t==2) goto r_x; else UD; } #else @@ -142,7 +142,7 @@ B chr_squeeze(B x) { B* xp = arr_bptr(x); if (xp!=NULL) { - #if SINGELI_SIMD || SINGELI_X86_64 + #if SINGELI_SIMD u32 t = avx2_squeeze_chrB(xp, ia); if (t==0) goto r_c8; else if (t==1) goto r_c16; diff --git a/src/core/stuff.c b/src/core/stuff.c index 013b818b..d59be283 100644 --- a/src/core/stuff.c +++ b/src/core/stuff.c @@ -420,7 +420,7 @@ u8 eqFnData[] = { // for the main diagonal, amount to shift length by; otherwise n,n,n,n,n,1,1,2, }; -#if SINGELI_SIMD || SINGELI_X86_64 +#if SINGELI_SIMD #define F(X) simd_equal_##X #define SINGELI_FILE equal #include "../utils/includeSingeli.h" diff --git a/src/utils/bits.c b/src/utils/bits.c index 66a1aab3..f2e6eb5a 100644 --- a/src/utils/bits.c +++ b/src/utils/bits.c @@ -2,7 +2,7 @@ #include "mut.h" -#if SINGELI_SIMD || SINGELI_X86_64 +#if SINGELI_SIMD #define SINGELI_FILE bits #include "../utils/includeSingeli.h" #define bitselFns simd_bitsel @@ -58,7 +58,7 @@ NOINLINE B bit_sel(B b, B e0, B e1) { sel:; void* rp = m_tyarrlc(&r, width, b, type); - #if SINGELI_SIMD || SINGELI_X86_64 + #if SINGELI_SIMD bitselFns[width](rp, bp, e0i, e1i, ia); #else switch(width) { diff --git a/src/utils/mut.c b/src/utils/mut.c index 2dfab7b0..881781a0 100644 --- a/src/utils/mut.c +++ b/src/utils/mut.c @@ -167,7 +167,7 @@ DEF_G(void, fill, B , (void* a, usz ms, B x, usz l), ms, x, l) { } -#if SINGELI_SIMD || SINGELI_X86_64 +#if SINGELI_SIMD #define DEF_COPY(T, BODY) DEF0(void, copy, T, u8 xe=TI(x,elType); u8 ne=el_or(xe,el_##T);, ne==el_##T, ne, (void* a, usz ms, B x, usz xs, usz l), ms, x, xs, l) #else #define DEF_COPY(T, BODY) DEF(void, copy, T, u8 xe=TI(x,elType); u8 ne=el_or(xe,el_##T);, ne==el_##T, ne, (void* a, usz ms, B x, usz xs, usz l), ms, x, xs, l) { u8 xt=TY(x); (void)xt; BODY } @@ -253,7 +253,7 @@ DEF_G(void, copy, B, (void* a, usz ms, B x, usz xs, usz l), ms, x, x } } -#if SINGELI_SIMD || SINGELI_X86_64 +#if SINGELI_SIMD static u64 loadu_u64(u64* p) { u64 v; memcpy(&v, p, 8); return v; } #define SINGELI_FILE copy #include "./includeSingeli.h"