arch-independent Singeli builds

This commit is contained in:
dzaima 2023-03-31 16:45:29 +03:00
parent 0180a54207
commit dc2ac37e0a
11 changed files with 38 additions and 27 deletions

@ -1 +1 @@
Subproject commit a17f83b2db2c1e025a56af0401682c45eb883257
Subproject commit 0cb33ab7a747c4e7a22f7c5a54321e6136e2d688

View File

@ -192,8 +192,7 @@ po ← { # parsed options
singeli GetOpt "singeli"
replxx GetOpt "REPLXX"
{𝕊: "Error: Cannot use Singeli on x86-64 without explicit 'native'"}_assert_¬ (arch"x86-64") singeli @GetOpt"native"
{𝕊: "Error: Cannot use Singeli on generic arch"}_assert_¬ singeli arch"generic"
{𝕊: arch"generic" Log "Note: on x86-64, a native build will be much faster: ", compat"add an argument of 'native'""use 'make o3n-singeli' if possible"} (arch"x86-64") singeli @GetOpt"native"
pie {(¬shared)linuxarch"x86-64"? 0; 1} DOpt "pie"
@ -249,6 +248,7 @@ po ← { # parsed options
args GetOpt "CCFLAGS"
args (singeliarch "x86-64") / "-DSINGELI_X86_64"
args (singeliarch"aarch64") / "-DSINGELI_NEON"
args (singeliarch"generic") / "-DSINGELI_SIMD"
args ( wasm) / "-DWASM"
args ( wasi) / "-DWASI", "-DNO_MMAP", "-DCATCH_ERRORS=0", "-D_WASI_EMULATED_MMAN", "--target=wasm32-wasi"
args ( emcc) / "-DEMCC", "-O3"
@ -571,12 +571,12 @@ cachedBin‿linkerCache ← {
cbqnSrc cbqnSrc clangd.Files "src"
singeliMap 1¨ (´¨ (po.arch) = ¨)/
"xa""src/builtins/arithm.c""monarith",
"xa""src/core/stuff.c""equal", "xa""src/utils/mut.c""copy", "xa""src/utils/bits.c""bits"
"xa""src/builtins/arithd.c""dyarith", "xa""src/builtins/cmp.c""cmp", "xa""src/builtins/squeeze.c""squeeze"
"x.""src/builtins/select.c""select", "x.""src/builtins/fold.c""fold", "x.""src/builtins/scan.c""scan"
"x.""src/builtins/scan.c""neq", "x.""src/builtins/slash.c""slash", "x.""src/builtins/slash.c""constrep"
"xa""src/builtins/transpose.c""transpose"
"xa.""src/builtins/arithm.c""monarith",
"xa.""src/core/stuff.c""equal", "xa.""src/utils/mut.c""copy", "xa.""src/utils/bits.c""bits"
"xa.""src/builtins/arithd.c""dyarith", "xa.""src/builtins/cmp.c""cmp", "xa.""src/builtins/squeeze.c""squeeze"
"x..""src/builtins/select.c""select", "x..""src/builtins/fold.c""fold", "x..""src/builtins/scan.c""scan"
"x..""src/builtins/scan.c""neq", "x..""src/builtins/slash.c""slash", "x..""src/builtins/slash.c""constrep"
"xag""src/builtins/transpose.c""transpose"
objs
@ -610,8 +610,9 @@ cachedBin‿linkerCache ← {
singeliArgs po.singeliFlags"-l", "gen="AtRoot singeliCache.folder{
po.native? ;
"-a" {"x86-64":"X86_64"; "aarch64":"AARCH64"} po.arch
"-a" {"x86-64":"X86_64"; "aarch64":"AARCH64"; "none"} po.arch
}
{𝕊: "Singeli args: "•Repr singeliArgs} _verboseLog @
singeliObjs {MakeSingeliInv singeliArgs, {𝕊:UpdateSubmodule po.singeliDir}, singeliCache, 𝕩, "src/singeli/src/"•file.At 𝕩".singeli", (𝕩"dyarith")/gaRule}¨ 1¨singeliMap
singeliCache

View File

@ -201,7 +201,7 @@ ifeq ($(WINDOWS), 1)
endif
endif
ALL_CC_FLAGS = -std=gnu11 -Wall -Wno-unused-function -fms-extensions -ffp-contract=off -fno-math-errno -fno-strict-aliasing $(CCFLAGS) $(f) $(i_f) $(NOWARN) -DBYTECODE_DIR=$(BYTECODE_DIR) -DSINGELI=$(i_singeli) -DSINGELI_X86_64=$(i_singeli) -DFFI=$(i_FFI) $(i_LIBS_CC) $(i_CC_PIE)
ALL_CC_FLAGS = -std=gnu11 -Wall -Wno-unused-function -fms-extensions -ffp-contract=off -fno-math-errno -fno-strict-aliasing $(CCFLAGS) $(f) $(i_f) $(NOWARN) -DBYTECODE_DIR=$(BYTECODE_DIR) -DSINGELI=$(i_singeli) -DSINGELI_SIMD=$(i_singeli) -DSINGELI_X86_64=$(i_singeli) -DFFI=$(i_FFI) $(i_LIBS_CC) $(i_CC_PIE)
ALL_LD_FLAGS = $(LDFLAGS) $(lf) $(i_lf) $(i_PIE) $(i_LIBS_LD)
j=4

View File

@ -21,7 +21,7 @@ B atan2_c2(B, B, B);
typedef void (*AndBytesFn)(u8*, u8*, u64, u64);
#if SINGELI
#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
#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)

View File

@ -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
#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
#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); \

View File

@ -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
#if SINGELI_SIMD
#include "../singeli/c/cmp.c"
#else
void cmpA_init(void) { }

View File

@ -1,6 +1,6 @@
#include "../core.h"
#if SINGELI
#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
#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
#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
#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
#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
#if SINGELI_SIMD
u32 t = avx2_squeeze_chrB(xp, ia);
if (t==0) goto r_c8;
else if (t==1) goto r_c16;

View File

@ -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
#if SINGELI_SIMD
#define F(X) avx2_equal_##X
#define SINGELI_FILE equal
#include "../utils/includeSingeli.h"

View File

@ -150,6 +150,16 @@ def pair{...x} = assert{'pair not supported', show{...x}}
def cvt{...x} = assert{'cvt not supported', show{...x}}
def cvt{T, x:X & T==eltype{X}} = x
def shuf{...x} = assert{'shuf not supported', show{...x}}
def homAll{...x} = assert{'homAll not supported', show{...x}}
def homAny{...x} = assert{'homAny not supported', show{...x}}
def homMask{...x} = assert{'homMask not supported', show{...x}}
def andAllZero{...x} = assert{'andAllZero not supported', show{...x}}
def loadLow{...x} = assert{'loadLow not supported', show{...x}}
def storeLow{...x} = assert{'storeLow not supported', show{...x}}
def sel{...x} = assert{'sel not supported', show{...x}}
def make{...x} = assert{'make not supported', show{...x}}
def half{...x} = assert{'half not supported', show{...x}}
def maskstoreF{...x} = assert{'maskstoreF not supported', show{...x}}
def min{a, b & knum{a} & knum{b}} = tern{a<b, a, b}
def max{a, b & knum{a} & knum{b}} = tern{a>b, a, b}

View File

@ -2,7 +2,7 @@
#include "mut.h"
#if SINGELI
#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
#if SINGELI_SIMD
bitselFns[width](rp, bp, e0i, e1i, ia);
#else
switch(width) {

View File

@ -167,7 +167,7 @@ DEF_G(void, fill, B , (void* a, usz ms, B x, usz l), ms, x, l) {
}
#if SINGELI
#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
#if SINGELI_SIMD
static u64 loadu_u64(u64* p) { u64 v; memcpy(&v, p, 8); return v; }
#define SINGELI_FILE copy
#include "./includeSingeli.h"