use void* instead of u8* for singeli function arguments
This commit is contained in:
parent
1710b43966
commit
8d6172126c
@ -67,11 +67,11 @@ B select_c2(B t, B w, B x) {
|
|||||||
u8 xe = TI(x,elType);
|
u8 xe = TI(x,elType);
|
||||||
u8 we = TI(w,elType);
|
u8 we = TI(w,elType);
|
||||||
#if SINGELI
|
#if SINGELI
|
||||||
// if (we==el_i8 && xe==el_i32) { i32* rp; r = m_i32arrc(&rp, w); if (!avx2_select_i8_32 ((u8*)i8any_ptr (w), (u8*)i32any_ptr(x), (u8*)rp, wia, xia)) thrM("⊏: Indexing out-of-bounds"); goto dec_ret; }
|
// if (we==el_i8 && xe==el_i32) { i32* rp; r = m_i32arrc(&rp, w); if (!avx2_select_i8_32 (i8any_ptr (w), i32any_ptr(x), rp, wia, xia)) thrM("⊏: Indexing out-of-bounds"); goto dec_ret; }
|
||||||
// if (we==el_i16 && xe==el_i32) { i32* rp; r = m_i32arrc(&rp, w); if (!avx2_select_i16_32((u8*)i16any_ptr(w), (u8*)i32any_ptr(x), (u8*)rp, wia, xia)) thrM("⊏: Indexing out-of-bounds"); goto dec_ret; }
|
// if (we==el_i16 && xe==el_i32) { i32* rp; r = m_i32arrc(&rp, w); if (!avx2_select_i16_32(i16any_ptr(w), i32any_ptr(x), rp, wia, xia)) thrM("⊏: Indexing out-of-bounds"); goto dec_ret; }
|
||||||
// if (we==el_i32 && xe==el_i8 ) { i8* rp; r = m_i8arrc (&rp, w); if (!avx2_select_i32_8 ((u8*)i32any_ptr(w), (u8*)i8any_ptr (x), (u8*)rp, wia, xia)) thrM("⊏: Indexing out-of-bounds"); goto dec_ret; }
|
// if (we==el_i32 && xe==el_i8 ) { i8* rp; r = m_i8arrc (&rp, w); if (!avx2_select_i32_8 (i32any_ptr(w), i8any_ptr (x), rp, wia, xia)) thrM("⊏: Indexing out-of-bounds"); goto dec_ret; }
|
||||||
// if (we==el_i32 && xe==el_i32) { i32* rp; r = m_i32arrc(&rp, w); if (!avx2_select_i32_32((u8*)i32any_ptr(w), (u8*)i32any_ptr(x), (u8*)rp, wia, xia)) thrM("⊏: Indexing out-of-bounds"); goto dec_ret; }
|
// if (we==el_i32 && xe==el_i32) { i32* rp; r = m_i32arrc(&rp, w); if (!avx2_select_i32_32(i32any_ptr(w), i32any_ptr(x), rp, wia, xia)) thrM("⊏: Indexing out-of-bounds"); goto dec_ret; }
|
||||||
// if (we==el_i32 && xe==el_f64) { f64* rp; r = m_f64arrc(&rp, w); if (!avx2_select_i32_64((u8*)i32any_ptr(w), (u8*)f64any_ptr(x), (u8*)rp, wia, xia)) thrM("⊏: Indexing out-of-bounds"); goto dec_ret; }
|
// if (we==el_i32 && xe==el_f64) { f64* rp; r = m_f64arrc(&rp, w); if (!avx2_select_i32_64(i32any_ptr(w), f64any_ptr(x), rp, wia, xia)) thrM("⊏: Indexing out-of-bounds"); goto dec_ret; }
|
||||||
#endif
|
#endif
|
||||||
#define CASE(S, E) case S: for (usz i=i0; i<i1; i++) ((E*)rp)[i] = ((E*)xp+off)[ip[i]]; break
|
#define CASE(S, E) case S: for (usz i=i0; i<i1; i++) ((E*)rp)[i] = ((E*)xp+off)[ip[i]]; break
|
||||||
#define CASEW(S, E) case S: for (usz i=0; i<wia; i++) ((E*)rp)[i] = ((E*)xp)[WRAP(wp[i], xia, thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", wp[i], xia))]; break
|
#define CASEW(S, E) case S: for (usz i=0; i<wia; i++) ((E*)rp)[i] = ((E*)xp)[WRAP(wp[i], xia, thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", wp[i], xia))]; break
|
||||||
|
|||||||
@ -44,10 +44,10 @@ B num_squeeze(B x) {
|
|||||||
switch (xe) { default: UD;
|
switch (xe) { default: UD;
|
||||||
case el_bit: goto r_x;
|
case el_bit: goto r_x;
|
||||||
#if SINGELI
|
#if SINGELI
|
||||||
case el_i8: { or = avx2_squeeze_i8 ((u8*)i8any_ptr (x), ia); if(or> 1) goto r_x; else goto mostBit; }
|
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((u8*)i16any_ptr(x), ia); if(or> I8_MAX) goto r_x; else goto mostI8; }
|
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((u8*)i32any_ptr(x), ia); if(or> I16_MAX) goto r_x; else goto mostI16; }
|
case el_i32: { or = avx2_squeeze_i32(i32any_ptr(x), ia); if(or> I16_MAX) goto r_x; else goto mostI16; }
|
||||||
case el_f64: { or = avx2_squeeze_f64((u8*)f64any_ptr(x), ia); if(-1==(u32)or) goto r_x; else goto mostI32; }
|
case el_f64: { or = avx2_squeeze_f64(f64any_ptr(x), ia); if(-1==(u32)or) goto r_x; else goto mostI32; }
|
||||||
#else
|
#else
|
||||||
case el_i8: { i8* xp = i8any_ptr (x); for (; i < ia; i++) { i32 c = xp[i]; or|= (u8)c; } if(or> 1) goto r_x; goto mostBit; }
|
case el_i8: { i8* xp = i8any_ptr (x); for (; i < ia; i++) { i32 c = xp[i]; or|= (u8)c; } if(or> 1) goto r_x; goto mostBit; }
|
||||||
case el_i16: { i16* xp = i16any_ptr(x); for (; i < ia; i++) { i32 c = xp[i]; or|= ((u32)c & ~1) ^ (u32)(c>>31); } if(or> I8_MAX) goto r_x; goto mostI8; }
|
case el_i16: { i16* xp = i16any_ptr(x); for (; i < ia; i++) { i32 c = xp[i]; or|= ((u32)c & ~1) ^ (u32)(c>>31); } if(or> I8_MAX) goto r_x; goto mostI8; }
|
||||||
@ -70,7 +70,7 @@ B num_squeeze(B x) {
|
|||||||
if (xp==NULL) goto r_f;
|
if (xp==NULL) goto r_f;
|
||||||
|
|
||||||
#if SINGELI
|
#if SINGELI
|
||||||
or = avx2_squeeze_numB((u8*)xp, ia);
|
or = avx2_squeeze_numB(xp, ia);
|
||||||
if (-2==(i32)or) goto r_x;
|
if (-2==(i32)or) goto r_x;
|
||||||
if (-1==(i32)or) goto r_f64;
|
if (-1==(i32)or) goto r_f64;
|
||||||
goto mostI32;
|
goto mostI32;
|
||||||
@ -114,8 +114,8 @@ B chr_squeeze(B x) {
|
|||||||
switch(xe) { default: UD;
|
switch(xe) { default: UD;
|
||||||
case el_c8: goto r_x;
|
case el_c8: goto r_x;
|
||||||
#if SINGELI
|
#if SINGELI
|
||||||
case el_c16: { u32 t = avx2_squeeze_c16((u8*)c16any_ptr(x), ia); if (t==0) goto r_c8; else goto r_x; }
|
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((u8*)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; }
|
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
|
#else
|
||||||
case el_c16: {
|
case el_c16: {
|
||||||
u16* xp = c16any_ptr(x);
|
u16* xp = c16any_ptr(x);
|
||||||
@ -139,7 +139,7 @@ B chr_squeeze(B x) {
|
|||||||
B* xp = arr_bptr(x);
|
B* xp = arr_bptr(x);
|
||||||
if (xp!=NULL) {
|
if (xp!=NULL) {
|
||||||
#if SINGELI
|
#if SINGELI
|
||||||
u32 t = avx2_squeeze_chrB((u8*)xp, ia);
|
u32 t = avx2_squeeze_chrB(xp, ia);
|
||||||
if (t==0) goto r_c8;
|
if (t==0) goto r_c8;
|
||||||
else if (t==1) goto r_c16;
|
else if (t==1) goto r_c16;
|
||||||
else if (t==2) goto r_c32;
|
else if (t==2) goto r_c32;
|
||||||
|
|||||||
@ -426,8 +426,8 @@ NOINLINE bool atomEqualF(B w, B x) {
|
|||||||
#include "../singeli/gen/equal.c"
|
#include "../singeli/gen/equal.c"
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
typedef bool (*EqFn)(u8* a, u8* b, u64 l, u64 data);
|
typedef bool (*EqFn)(void* a, void* b, u64 l, u64 data);
|
||||||
bool notEq(u8* a, u8* b, u64 l, u64 data) { return false; }
|
bool notEq(void* a, void* b, u64 l, u64 data) { return false; }
|
||||||
|
|
||||||
#define F(X) avx2_equal_##X
|
#define F(X) avx2_equal_##X
|
||||||
EqFn eqFns[] = {
|
EqFn eqFns[] = {
|
||||||
@ -477,10 +477,8 @@ NOINLINE bool equal(B w, B x) { // doesn't consume
|
|||||||
|
|
||||||
#if SINGELI
|
#if SINGELI
|
||||||
if (we<=el_c32 && xe<=el_c32) { // remove & pass a(w) and a(x) to fn so it can do basic loop
|
if (we<=el_c32 && xe<=el_c32) { // remove & pass a(w) and a(x) to fn so it can do basic loop
|
||||||
u8* wp = tyany_ptr(w);
|
|
||||||
u8* xp = tyany_ptr(x);
|
|
||||||
u64 idx = we*8 + xe;
|
u64 idx = we*8 + xe;
|
||||||
return eqFns[idx](wp, xp, ia, eqFnData[idx]);
|
return eqFns[idx](tyany_ptr(w), tyany_ptr(x), ia, eqFnData[idx]);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (((we==el_f64 | we==el_i32) && (xe==el_f64 | xe==el_i32))) {
|
if (((we==el_f64 | we==el_i32) && (xe==el_f64 | xe==el_i32))) {
|
||||||
|
|||||||
@ -3,8 +3,8 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
// #define ARITH_DEBUG 1
|
// #define ARITH_DEBUG 1
|
||||||
|
|
||||||
typedef u64 (*CheckedFn)(u8* r, u8* w, u8* x, u64 len);
|
typedef u64 (*CheckedFn)(void* r, void* w, void* x, u64 len);
|
||||||
typedef void (*UncheckedFn)(u8* r, u8* w, u8* x, u64 len);
|
typedef void (*UncheckedFn)(void* r, void* w, void* x, u64 len);
|
||||||
#define FOR_ExecAA(F) \
|
#define FOR_ExecAA(F) \
|
||||||
F(fail) /* first to allow zero-initialization to be fail implicitly */ \
|
F(fail) /* first to allow zero-initialization to be fail implicitly */ \
|
||||||
F(swap) /* swap 𝕨 and 𝕩, then run ex2 */ \
|
F(swap) /* swap 𝕨 and 𝕩, then run ex2 */ \
|
||||||
@ -112,13 +112,13 @@ NOINLINE B dyArith_AA(DyTableAA* table, B w, B x) {
|
|||||||
}
|
}
|
||||||
case u_call_bit: {
|
case u_call_bit: {
|
||||||
u64* rp; r = m_bitarrc(&rp, x);
|
u64* rp; r = m_bitarrc(&rp, x);
|
||||||
fn->uFn((u8*)rp, tyany_ptr(w), tyany_ptr(x), ia);
|
fn->uFn(rp, tyany_ptr(w), tyany_ptr(x), ia);
|
||||||
goto decG_ret;
|
goto decG_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
case u_call_wxf64sq: {
|
case u_call_wxf64sq: {
|
||||||
f64* rp; r = m_f64arrc(&rp, x);
|
f64* rp; r = m_f64arrc(&rp, x);
|
||||||
fn->uFn((u8*)rp, tyany_ptr(w = toF64Any(w)), tyany_ptr(x = toF64Any(x)), ia);
|
fn->uFn(rp, tyany_ptr(w = toF64Any(w)), tyany_ptr(x = toF64Any(x)), ia);
|
||||||
r = num_squeeze(r);
|
r = num_squeeze(r);
|
||||||
goto decG_ret;
|
goto decG_ret;
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ NOINLINE B dyArith_AA(DyTableAA* table, B w, B x) {
|
|||||||
|
|
||||||
typedef struct DyTableSA DyTableSA;
|
typedef struct DyTableSA DyTableSA;
|
||||||
typedef bool (*ForBitsel)(DyTableSA*, B w, B* r);
|
typedef bool (*ForBitsel)(DyTableSA*, B w, B* r);
|
||||||
typedef u64 (*AtomArrFnC)(u8* r, u64 w, u8* x, u64 len);
|
typedef u64 (*AtomArrFnC)(void* r, u64 w, void* x, u64 len);
|
||||||
typedef B (*DyArithChrFn)(DyTableSA*, B, B, usz, u8);
|
typedef B (*DyArithChrFn)(DyTableSA*, B, B, usz, u8);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -173,8 +173,8 @@ bool bad_forBitselNN_SA(DyTableSA* table, B w, B* r) { return false; }
|
|||||||
B bad_chrAtomSA(DyTableSA* table, B w, B x, usz ia, u8 xe) { return arith_recd(table->mainFn, w, x); }
|
B bad_chrAtomSA(DyTableSA* table, B w, B x, usz ia, u8 xe) { return arith_recd(table->mainFn, w, x); }
|
||||||
#define bad_chrAtomAS bad_chrAtomSA
|
#define bad_chrAtomAS bad_chrAtomSA
|
||||||
|
|
||||||
u64 failAtomArr1(u8* r, u64 w, u8* x, u64 len) { return 0; }
|
u64 failAtomArr1(void* r, u64 w, void* x, u64 len) { return 0; }
|
||||||
u64 failAtomArr2(u8* r, u64 w, u8* x, u64 len) { return 1; }
|
u64 failAtomArr2(void* r, u64 w, void* x, u64 len) { return 1; }
|
||||||
|
|
||||||
u8 nextType[] = {
|
u8 nextType[] = {
|
||||||
[t_i8arr ] = t_i16arr, [t_c8arr ] = t_c16arr,
|
[t_i8arr ] = t_i16arr, [t_c8arr ] = t_c16arr,
|
||||||
@ -318,10 +318,10 @@ B dyArith_SA(DyTableSA* table, B w, B x) {
|
|||||||
#include "../gen/dyarith.c"
|
#include "../gen/dyarith.c"
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
static void rootAAu_f64_f64_f64(u8* r, u8* w, u8* x, u64 len) { for (u64 i = 0; i < len; i++) ((f64*)r)[i] = pow(((f64*)x)[i], 1.0/((f64*)w)[i]); }
|
static void rootAAu_f64_f64_f64(void* r, void* w, void* x, u64 len) { for (u64 i = 0; i < len; i++) ((f64*)r)[i] = pow(((f64*)x)[i], 1.0/((f64*)w)[i]); }
|
||||||
static void powAAu_f64_f64_f64(u8* r, u8* w, u8* x, u64 len) { for (u64 i = 0; i < len; i++) ((f64*)r)[i] = pow(((f64*)w)[i], ((f64*)x)[i]); }
|
static void powAAu_f64_f64_f64(void* r, void* w, void* x, u64 len) { for (u64 i = 0; i < len; i++) ((f64*)r)[i] = pow(((f64*)w)[i], ((f64*)x)[i]); }
|
||||||
static void stileAAu_f64_f64_f64(u8* r, u8* w, u8* x, u64 len) { for (u64 i = 0; i < len; i++) ((f64*)r)[i] = pfmod(((f64*)x)[i], ((f64*)w)[i]); }
|
static void stileAAu_f64_f64_f64(void* r, void* w, void* x, u64 len) { for (u64 i = 0; i < len; i++) ((f64*)r)[i] = pfmod(((f64*)x)[i], ((f64*)w)[i]); }
|
||||||
static void logAAu_f64_f64_f64(u8* r, u8* w, u8* x, u64 len) { for (u64 i = 0; i < len; i++) ((f64*)r)[i] = log(((f64*)x)[i])/log(((f64*)w)[i]); }
|
static void logAAu_f64_f64_f64(void* r, void* w, void* x, u64 len) { for (u64 i = 0; i < len; i++) ((f64*)r)[i] = log(((f64*)x)[i])/log(((f64*)w)[i]); }
|
||||||
|
|
||||||
bool add_forBitselNN_SA (DyTableSA* table, B w, B* r) { f64 f=o2fG(w); r[0] = m_f64(f+0); r[1] = m_f64(f+1); return true; }
|
bool add_forBitselNN_SA (DyTableSA* table, B w, B* r) { f64 f=o2fG(w); r[0] = m_f64(f+0); r[1] = m_f64(f+1); return true; }
|
||||||
bool sub_forBitselNN_SA (DyTableSA* table, B w, B* r) { f64 f=o2fG(w); r[0] = m_f64(f-0); r[1] = m_f64(f-1); return true; }
|
bool sub_forBitselNN_SA (DyTableSA* table, B w, B* r) { f64 f=o2fG(w); r[0] = m_f64(f-0); r[1] = m_f64(f-1); return true; }
|
||||||
@ -349,7 +349,7 @@ static NOINLINE B or_SA(B t, B w, B x) {
|
|||||||
B r = m_f64arrc(&rp, x);
|
B r = m_f64arrc(&rp, x);
|
||||||
usz ia = a(x)->ia;
|
usz ia = a(x)->ia;
|
||||||
x = toF64Any(x);
|
x = toF64Any(x);
|
||||||
orSAc_f64_f64_f64((u8*)rp, w.u, tyany_ptr(x), ia);
|
orSAc_f64_f64_f64(rp, w.u, tyany_ptr(x), ia);
|
||||||
decG(x);
|
decG(x);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,8 +24,8 @@ static NOINLINE void cmp_err() { if (please_tail_call_err) thrM("Invalid compari
|
|||||||
#include "../gen/cmp.c"
|
#include "../gen/cmp.c"
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
typedef void (*CmpAAFn)(u64*, u8*, u8*, u64);
|
typedef void (*CmpAAFn)(u64*, void*, void*, u64);
|
||||||
typedef void (*CmpASFn)(u64*, u8*, u64, u64);
|
typedef void (*CmpASFn)(u64*, void*, u64, u64);
|
||||||
#define CMPFN(A,F,S,T) A##_##F##S##_##T
|
#define CMPFN(A,F,S,T) A##_##F##S##_##T
|
||||||
#define FN_LUT(A,F,S) static const Cmp##S##Fn lut_##A##_##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,F,S) static const Cmp##S##Fn lut_##A##_##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)}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ FN_LUT(avx2, le, AS);
|
|||||||
w=tw; x=tx; \
|
w=tw; x=tx; \
|
||||||
} \
|
} \
|
||||||
AL(x); \
|
AL(x); \
|
||||||
if (ria) lut_avx2_##NAME##AA[we](rp, (u8*)tyany_ptr(w), (u8*)tyany_ptr(x), ria); \
|
if (ria) lut_avx2_##NAME##AA[we](rp, tyany_ptr(w), tyany_ptr(x), ria); \
|
||||||
decG(w);decG(x); return r; \
|
decG(w);decG(x); return r; \
|
||||||
} \
|
} \
|
||||||
bad: return NAME##_rec(swapped, w, x); \
|
bad: return NAME##_rec(swapped, w, x); \
|
||||||
@ -68,7 +68,7 @@ CMP_AA("≠", "?", ne, swapped=0;)
|
|||||||
#define CMP_SA(NAME, RNAME, PRE) B NAME##_SA(i32 swapped, B w, B x) { PRE \
|
#define CMP_SA(NAME, RNAME, PRE) B NAME##_SA(i32 swapped, B w, B x) { PRE \
|
||||||
u8 xe = TI(x, elType); if (xe==el_B) goto bad; \
|
u8 xe = TI(x, elType); if (xe==el_B) goto bad; \
|
||||||
AL(x); \
|
AL(x); \
|
||||||
if (ria) lut_avx2_##RNAME##AS[xe](rp, (u8*)tyany_ptr(x), w.u, ria); \
|
if (ria) lut_avx2_##RNAME##AS[xe](rp, tyany_ptr(x), w.u, ria); \
|
||||||
else dec(w); \
|
else dec(w); \
|
||||||
decG(x); return r; \
|
decG(x); return r; \
|
||||||
bad: return NAME##_rec(swapped, w, x); \
|
bad: return NAME##_rec(swapped, w, x); \
|
||||||
|
|||||||
@ -20,7 +20,7 @@ def bitsel{VL, T, r, bits, e0, e1, len} = {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
bitsel_i{VL,T}(r:*u8, bits:*u64, e0:u64, e1:u64, len:u64) : void = {
|
bitsel_i{VL,T}(r:*void, bits:*u64, e0:u64, e1:u64, len:u64) : void = {
|
||||||
bitsel{VL, T, *T~~r, bits, trunc{T,e0}, trunc{T,e1}, len}
|
bitsel{VL, T, *T~~r, bits, trunc{T,e0}, trunc{T,e1}, len}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -73,26 +73,26 @@ def any2bit{VT, unr, op, wS, wV, xS, xV, dst:*u64, len:(Size)} = {
|
|||||||
ri = ri+1
|
ri = ri+1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
aa2bit{VT, unr, op}(dst:*u64, wr:*u8, xr:*u8, len:Size) : void = {
|
aa2bit{VT, unr, op}(dst:*u64, wr:*void, xr:*void, len:Size) : void = {
|
||||||
wv:= *VT~~wr; ws:= *eltype{VT}~~wr
|
wv:= *VT~~wr; ws:= *eltype{VT}~~wr
|
||||||
xv:= *VT~~xr; xs:= *eltype{VT}~~xr
|
xv:= *VT~~xr; xs:= *eltype{VT}~~xr
|
||||||
any2bit{VT, unr, op, {i}=>load{ws,i}, {i}=>load{wv,i}, {i}=>load{xs,i}, {i}=>load{xv,i}, dst, len}
|
any2bit{VT, unr, op, {i}=>load{ws,i}, {i}=>load{wv,i}, {i}=>load{xs,i}, {i}=>load{xv,i}, dst, len}
|
||||||
}
|
}
|
||||||
|
|
||||||
as2bit{VT, unr, op}(dst:*u64, wr:*u8, x:u64, len:Size) : void = {
|
as2bit{VT, unr, op}(dst:*u64, wr:*void, x:u64, len:Size) : void = {
|
||||||
wv:= *VT~~wr; ws:= *eltype{VT}~~wr
|
wv:= *VT~~wr; ws:= *eltype{VT}~~wr
|
||||||
xv:= broadcast{VT, pathAS{dst, len, eltype{VT}, op, x}}
|
xv:= broadcast{VT, pathAS{dst, len, eltype{VT}, op, x}}
|
||||||
any2bit{VT, unr, op, {i}=>load{ws,i}, {i}=>load{wv,i}, {i}=>x, {i}=>xv, dst, len}
|
any2bit{VT, unr, op, {i}=>load{ws,i}, {i}=>load{wv,i}, {i}=>x, {i}=>xv, dst, len}
|
||||||
}
|
}
|
||||||
|
|
||||||
bitAA{bitop}(dst:*u64, wr:*u8, xr:*u8, len:Size) : void = {
|
bitAA{bitop}(dst:*u64, wr:*void, xr:*void, len:Size) : void = {
|
||||||
@forNZ (dst, w in *u64~~wr, x in *u64~~xr over _ to cdiv{len,64}) dst = bitop{w,x}
|
@forNZ (dst, w in *u64~~wr, x in *u64~~xr over _ to cdiv{len,64}) dst = bitop{w,x}
|
||||||
}
|
}
|
||||||
|
|
||||||
not(dst:*u64, x:*u64, len:Size) : void = { am:=cdiv{len,64}; @forNZ (dst,x over _ to am) dst = ~x }
|
not(dst:*u64, x:*u64, len:Size) : void = { am:=cdiv{len,64}; @forNZ (dst,x over _ to am) dst = ~x }
|
||||||
cpy(dst:*u64, x:*u64, len:Size) : void = { am:=cdiv{len,64}; @forNZ (dst,x over _ to am) dst = x }
|
cpy(dst:*u64, x:*u64, len:Size) : void = { am:=cdiv{len,64}; @forNZ (dst,x over _ to am) dst = x }
|
||||||
|
|
||||||
bitAS{op}(dst:*u64, wr:*u8, x:u64, len:Size) : void = { # show{'bitAS'}
|
bitAS{op}(dst:*u64, wr:*void, x:u64, len:Size) : void = { # show{'bitAS'}
|
||||||
xf:f64 = interp_f64{x}
|
xf:f64 = interp_f64{x}
|
||||||
r0:u1 = op{0,xf}
|
r0:u1 = op{0,xf}
|
||||||
r1:u1 = op{1,xf}
|
r1:u1 = op{1,xf}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ def copyFromBits{T, xp: *u64, rp: *eltype{T}, l:u64} = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
copy{vw, X, R}(x: *u8, r: *u8, l:u64, xRaw: *u8) : void = {
|
copy{vw, X, R}(x: *void, r: *void, l:u64, xRaw: *void) : void = {
|
||||||
assert{l!=0}
|
assert{l!=0}
|
||||||
|
|
||||||
def bulk = vw/max{width{X}, width{R}}
|
def bulk = vw/max{width{X}, width{R}}
|
||||||
|
|||||||
@ -148,12 +148,12 @@ def arithAAimpl{vw, mode, F, W, X, R, w, x, r, len} = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
arithAAc{vw, mode, F, W, X, R}(r:*u8, w:*u8, x:*u8, len:u64) : u64 = {
|
arithAAc{vw, mode, F, W, X, R}(r:*void, w:*void, x:*void, len:u64) : u64 = {
|
||||||
arithAAimpl{vw, mode, F, W, X, R, w, x, r, len}
|
arithAAimpl{vw, mode, F, W, X, R, w, x, r, len}
|
||||||
if (mode==1) len
|
if (mode==1) len
|
||||||
else 0
|
else 0
|
||||||
}
|
}
|
||||||
arithAAu{vw, mode, F, W, X, R}(r:*u8, w:*u8, x:*u8, len:u64) : void = {
|
arithAAu{vw, mode, F, W, X, R}(r:*void, w:*void, x:*void, len:u64) : void = {
|
||||||
arithAAimpl{vw, mode, F, W, X, R, w, x, r, len}
|
arithAAimpl{vw, mode, F, W, X, R, w, x, r, len}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ def arithAA{mode, F, W, X, R} = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# mode: 0:overflow-checked, needed; 1:overflow-erroring; 2: overflow-checked, not needed
|
# mode: 0:overflow-checked, needed; 1:overflow-erroring; 2: overflow-checked, not needed
|
||||||
arithSAf{vw, mode, F, swap, W, X, R}(r:*u8, w:u64, x:*u8, len:u64) : u64 = {
|
arithSAf{vw, mode, F, swap, W, X, R}(r:*void, w:u64, x:*void, len:u64) : u64 = {
|
||||||
# show{fmt_op{F}, swap, mode, W, X, R}
|
# show{fmt_op{F}, swap, mode, W, X, R}
|
||||||
assert{len>0}
|
assert{len>0}
|
||||||
def bulk = vw / max{width{W}, width{R}}
|
def bulk = vw / max{width{W}, width{R}}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ def swap{w,x} = {
|
|||||||
x = t
|
x = t
|
||||||
}
|
}
|
||||||
|
|
||||||
equal{W, X}(w:*u8, x:*u8, l:u64, d:u64) : u1 = {
|
equal{W, X}(w:*void, x:*void, l:u64, d:u64) : u1 = {
|
||||||
def bulk = 256 / width{X}
|
def bulk = 256 / width{X}
|
||||||
if (W!=X) if (d!=0) swap{w,x}
|
if (W!=X) if (d!=0) swap{w,x}
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ def gather{def:T, b:B, idx:[4]i32, M & w256{T,64}} = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
select{rw, TI, TD}(w0:*u8, x0:*u8, r0:*u8, wl:u64, xl:u64) : u1 = {
|
select{rw, TI, TD}(w0:*void, x0:*void, r0:*void, wl:u64, xl:u64) : u1 = {
|
||||||
def TIE = i32
|
def TIE = i32
|
||||||
def TDE = tern{width{TD}<32, u32, TD}
|
def TDE = tern{width{TD}<32, u32, TD}
|
||||||
def bulk = minBulk{rw,TIE,TDE}
|
def bulk = minBulk{rw,TIE,TDE}
|
||||||
|
|||||||
@ -41,7 +41,7 @@ def fold{F, x:T & w128{T}} = {
|
|||||||
}
|
}
|
||||||
def fold{F, x:T & w256{T}} = fold{F, F{half{x, 0}, half{x, 1}}}
|
def fold{F, x:T & w256{T}} = fold{F, F{half{x, 0}, half{x, 1}}}
|
||||||
|
|
||||||
squeeze{vw, X, CHR, B}(x0:*u8, len:Size) : u32 = {
|
squeeze{vw, X, CHR, B}(x0:*void, len:Size) : u32 = {
|
||||||
def bulk = vw / width{X}
|
def bulk = vw / width{X}
|
||||||
def XV = [bulk]X
|
def XV = [bulk]X
|
||||||
def E = tern{X==f64, u32, ty_u{X}}
|
def E = tern{X==f64, u32, ty_u{X}}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
#include "../singeli/gen/bits.c"
|
#include "../singeli/gen/bits.c"
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
typedef void (*BitselFn)(u8*, u64*, u64, u64, u64);
|
typedef void (*BitselFn)(void*, u64*, u64, u64, u64);
|
||||||
static BitselFn bitselFns[] = {
|
static BitselFn bitselFns[] = {
|
||||||
[0]=avx2_bitsel_8,
|
[0]=avx2_bitsel_8,
|
||||||
[1]=avx2_bitsel_16,
|
[1]=avx2_bitsel_16,
|
||||||
|
|||||||
@ -234,20 +234,20 @@ DEF_G(void, copy, B, (void* a, usz ms, B x, usz xs, usz l), ms, x, x
|
|||||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
#include "../singeli/gen/copy.c"
|
#include "../singeli/gen/copy.c"
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
typedef void (*copy_fn)(u8*, u8*, u64, u8*);
|
typedef void (*copy_fn)(void*, void*, u64, void*);
|
||||||
|
|
||||||
static void badCopy(u8* xp, u8* rp, u64 len, u8* xRaw) {
|
static void badCopy(void* xp, void* rp, u64 len, void* xRaw) {
|
||||||
err("Copying wrong array type");
|
err("Copying wrong array type");
|
||||||
}
|
}
|
||||||
|
|
||||||
#define COPY_FN(X,R) avx2_copy_##X##_##R
|
#define COPY_FN(X,R) avx2_copy_##X##_##R
|
||||||
#define MAKE_CPY(TY, MAKE, GET, WR, XRP, H2T, T, ...) \
|
#define MAKE_CPY(TY, MAKE, GET, WR, XRP, H2T, T, ...) \
|
||||||
static copy_fn copy##T##Fns[10]; \
|
static copy_fn copy##T##Fns[10]; \
|
||||||
NOINLINE void cpy##T##Arr_BF(u8* xp, u8* rp, u64 ia, Arr* xa) { \
|
NOINLINE void cpy##T##Arr_BF(void* xp, void* rp, u64 ia, Arr* xa) { \
|
||||||
AS2B fn = TIv(xa,GET); \
|
AS2B fn = TIv(xa,GET); \
|
||||||
for (usz i=0; i<ia; i++) WR(fn(xa,i)); \
|
for (usz i=0; i<ia; i++) WR(fn(xa,i)); \
|
||||||
} \
|
} \
|
||||||
static void cpy##T##Arr_B(u8* xp, u8* rp, u64 ia, u8* xRaw) { \
|
static void cpy##T##Arr_B(void* xp, void* rp, u64 ia, void* xRaw) { \
|
||||||
Arr* xa = (Arr*)xRaw; B* bxp = arrV_bptr(xa); \
|
Arr* xa = (Arr*)xRaw; B* bxp = arrV_bptr(xa); \
|
||||||
if (bxp!=NULL && sizeof(B)==sizeof(f64)) { \
|
if (bxp!=NULL && sizeof(B)==sizeof(f64)) { \
|
||||||
H2T; \
|
H2T; \
|
||||||
@ -258,14 +258,14 @@ DEF_G(void, copy, B, (void* a, usz ms, B x, usz xs, usz l), ms, x, x
|
|||||||
usz ia = IA(x); \
|
usz ia = IA(x); \
|
||||||
MAKE; arr_shCopy(r, x); \
|
MAKE; arr_shCopy(r, x); \
|
||||||
if (ia>0) { \
|
if (ia>0) { \
|
||||||
copy##T##Fns[TI(x,elType)](tyany_ptr(x), (u8*)(XRP), ia, (u8*)a(x)); \
|
copy##T##Fns[TI(x,elType)](tyany_ptr(x), XRP, ia, a(x)); \
|
||||||
} \
|
} \
|
||||||
if (TY) ptr_decT(a(x)); \
|
if (TY) ptr_decT(a(x)); \
|
||||||
else decG(x); \
|
else decG(x); \
|
||||||
return (T##Arr*)r; \
|
return (T##Arr*)r; \
|
||||||
}
|
}
|
||||||
#define BIT_PUT(V) bitp_set((u64*)rp, i, o2bG(V))
|
#define BIT_PUT(V) bitp_set((u64*)rp, i, o2bG(V))
|
||||||
#define H2T_COPY(T) copy##T##Fns[el_MAX]((u8*)bxp, rp, ia, xRaw)
|
#define H2T_COPY(T) copy##T##Fns[el_MAX](bxp, rp, ia, xRaw)
|
||||||
#define MAKE_TYCPY(T, E, F, ...) MAKE_CPY(1, T##Atom* rp; Arr* r = m_##E##arrp(&rp, ia), getU, ((T##Atom*)rp)[i] = F, rp, H2T_COPY(T), T, __VA_ARGS__)
|
#define MAKE_TYCPY(T, E, F, ...) MAKE_CPY(1, T##Atom* rp; Arr* r = m_##E##arrp(&rp, ia), getU, ((T##Atom*)rp)[i] = F, rp, H2T_COPY(T), T, __VA_ARGS__)
|
||||||
#define MAKE_CCPY(T,E) MAKE_TYCPY(T, E, o2cG, {badCopy, badCopy, badCopy, badCopy, badCopy, COPY_FN(c8,E),COPY_FN(c16,E),COPY_FN(c32,E),cpy##T##Arr_B,COPY_FN(B,E)})
|
#define MAKE_CCPY(T,E) MAKE_TYCPY(T, E, o2cG, {badCopy, badCopy, badCopy, badCopy, badCopy, COPY_FN(c8,E),COPY_FN(c16,E),COPY_FN(c32,E),cpy##T##Arr_B,COPY_FN(B,E)})
|
||||||
#define MAKE_ICPY(T,E) MAKE_TYCPY(T, E, o2fG, {COPY_FN(1,E),COPY_FN(i8,E),COPY_FN(i16,E),COPY_FN(i32,E),COPY_FN(f64,E),badCopy, badCopy, badCopy, cpy##T##Arr_B,COPY_FN(f64,E)})
|
#define MAKE_ICPY(T,E) MAKE_TYCPY(T, E, o2fG, {COPY_FN(1,E),COPY_FN(i8,E),COPY_FN(i16,E),COPY_FN(i32,E),COPY_FN(f64,E),badCopy, badCopy, badCopy, cpy##T##Arr_B,COPY_FN(f64,E)})
|
||||||
@ -285,13 +285,13 @@ DEF_G(void, copy, B, (void* a, usz ms, B x, usz xs, usz l), ms, x, x
|
|||||||
|
|
||||||
#define TCOPY_FN(T, N) static void m_copyG_##N(void* a, usz ms, B x, usz xs, usz l) { \
|
#define TCOPY_FN(T, N) static void m_copyG_##N(void* a, usz ms, B x, usz xs, usz l) { \
|
||||||
if (l==0) return; \
|
if (l==0) return; \
|
||||||
u8* xp = tyany_ptr(x); \
|
void* xp = tyany_ptr(x); \
|
||||||
T* rp = ms + (T*)a; \
|
T* rp = ms + (T*)a; \
|
||||||
u8 xt = TY(x); \
|
u8 xt = TY(x); \
|
||||||
if (xt==t_bitarr) { \
|
if (xt==t_bitarr) { \
|
||||||
for (usz i = 0; i < l; i++) rp[i] = bitp_get((u64*)xp, xs+i); \
|
for (usz i = 0; i < l; i++) rp[i] = bitp_get((u64*)xp, xs+i); \
|
||||||
} else { \
|
} else { \
|
||||||
tcopy_##N##Fns[xt]((xs << arrTypeWidthLog(xt)) + (u8*)xp, (u8*)rp, l, (u8*)a(x)); \
|
tcopy_##N##Fns[xt]((xs << arrTypeWidthLog(xt)) + (u8*)xp, rp, l, a(x)); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
TCOPY_FN(i8,i8)
|
TCOPY_FN(i8,i8)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user