rename elWidthLogBits to something less long & add byte variant
This commit is contained in:
parent
6a0805eb9d
commit
5efd90cc91
@ -513,7 +513,7 @@ B GRADE_CAT(c2)(B t, B w, B x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if SINGELI
|
#if SINGELI
|
||||||
u8 k = elWidthLogBits(we) - 3;
|
u8 k = elwByteLog(we);
|
||||||
u8 rl = wia<128 ? 0 : wia<(1<<15) ? 1 : wia<(1<<31) ? 2 : 3;
|
u8 rl = wia<128 ? 0 : wia<(1<<15) ? 1 : wia<(1<<31) ? 2 : 3;
|
||||||
void *rp = m_tyarrc(&r, 1<<rl, x, el2t(el_i8+rl));
|
void *rp = m_tyarrc(&r, 1<<rl, x, el2t(el_i8+rl));
|
||||||
si_bins[k*2 + GRADE_UD(0,1)](tyany_ptr(w), wia, tyany_ptr(x), xia, rp, rl);
|
si_bins[k*2 + GRADE_UD(0,1)](tyany_ptr(w), wia, tyany_ptr(x), xia, rp, rl);
|
||||||
|
|||||||
@ -52,7 +52,7 @@ extern B add_c2(B,B,B);
|
|||||||
extern B sub_c2(B,B,B);
|
extern B sub_c2(B,B,B);
|
||||||
extern B mul_c2(B,B,B);
|
extern B mul_c2(B,B,B);
|
||||||
|
|
||||||
static u64 elRange(u8 eltype) { return 1ull<<(1<<elWidthLogBits(eltype)); }
|
static u64 elRange(u8 eltype) { return 1ull<<(1<<elwBitLog(eltype)); }
|
||||||
|
|
||||||
#define TABLE(IN, FOR, TY, INIT, SET) \
|
#define TABLE(IN, FOR, TY, INIT, SET) \
|
||||||
usz it = elRange(IN##e); /* Range of writes */ \
|
usz it = elRange(IN##e); /* Range of writes */ \
|
||||||
@ -90,7 +90,7 @@ static NOINLINE B toIntCell(B x, ux csz0, ur co) {
|
|||||||
ShArr* rsh;
|
ShArr* rsh;
|
||||||
if (co>1) { rsh=m_shArr(co); shcpy(rsh->a,SH(x),co); }
|
if (co>1) { rsh=m_shArr(co); shcpy(rsh->a,SH(x),co); }
|
||||||
B r0 = widenBitArr(x, co);
|
B r0 = widenBitArr(x, co);
|
||||||
usz csz = shProd(SH(r0),co,RNK(r0)) << elWidthLogBits(TI(r0,elType));
|
usz csz = shProd(SH(r0),co,RNK(r0)) << elwBitLog(TI(r0,elType));
|
||||||
u8 t;
|
u8 t;
|
||||||
if (csz==8) t = t_i8slice;
|
if (csz==8) t = t_i8slice;
|
||||||
else if (csz==16) t = t_i16slice;
|
else if (csz==16) t = t_i16slice;
|
||||||
@ -129,8 +129,8 @@ static NOINLINE B2 splitCells(B n, B p, u8 mode) { // 0:∊ 1:⊐ 2:⊒
|
|||||||
u8 pe = TI(p,elType);
|
u8 pe = TI(p,elType);
|
||||||
if (ne<el_B && pe<el_B && elNum(ne)==elNum(pe)) {
|
if (ne<el_B && pe<el_B && elNum(ne)==elNum(pe)) {
|
||||||
usz csz = arr_csz(p);
|
usz csz = arr_csz(p);
|
||||||
u8 neb = elWidthLogBits(ne);
|
u8 neb = elwBitLog(ne);
|
||||||
u8 peb = elWidthLogBits(pe);
|
u8 peb = elwBitLog(pe);
|
||||||
u8 meb = neb>peb? neb : peb;
|
u8 meb = neb>peb? neb : peb;
|
||||||
ux rb = csz<<meb;
|
ux rb = csz<<meb;
|
||||||
if (rb!=0 && rb<=62) {
|
if (rb!=0 && rb<=62) {
|
||||||
|
|||||||
@ -270,7 +270,7 @@ B select_c2(B t, B w, B x) {
|
|||||||
switch (we) { default: UD;
|
switch (we) { default: UD;
|
||||||
case el_bit: {
|
case el_bit: {
|
||||||
if (xr!=1) {
|
if (xr!=1) {
|
||||||
if (xe!=el_B && (csz<<elWidthLogBits(xe)) < 128) {
|
if (xe!=el_B && (csz<<elwBitLog(xe)) < 128) {
|
||||||
dec(xf);
|
dec(xf);
|
||||||
return C2(select, taga(cpyI8Arr(w)), x);
|
return C2(select, taga(cpyI8Arr(w)), x);
|
||||||
} else {
|
} else {
|
||||||
@ -318,7 +318,7 @@ B select_c2(B t, B w, B x) {
|
|||||||
SLOW2("𝕨⊏𝕩", w, x);
|
SLOW2("𝕨⊏𝕩", w, x);
|
||||||
SGetU(w)
|
SGetU(w)
|
||||||
usz csz = arr_csz(x);
|
usz csz = arr_csz(x);
|
||||||
CFRes f = cf_get(1, csz<<elWidthLogBits(xe));
|
CFRes f = cf_get(1, csz<<elwBitLog(xe));
|
||||||
|
|
||||||
MAKE_MUT_INIT(rm, ria, xe);
|
MAKE_MUT_INIT(rm, ria, xe);
|
||||||
usz i = 0; f64 badw;
|
usz i = 0; f64 badw;
|
||||||
|
|||||||
@ -91,7 +91,7 @@ SHOULD_INLINE bool canCompare64_norm(B* x, void** xp, usz n) {
|
|||||||
}
|
}
|
||||||
static bool shouldWidenBitarr(B x, usz csz) { // assumes cells won't anymore have sizes of 0, 8, or 16 bits
|
static bool shouldWidenBitarr(B x, usz csz) { // assumes cells won't anymore have sizes of 0, 8, or 16 bits
|
||||||
u8 xe = TI(x,elType);
|
u8 xe = TI(x,elType);
|
||||||
ux bcsz = ((ux)csz)<<elWidthLogBits(xe);
|
ux bcsz = ((ux)csz)<<elwBitLog(xe);
|
||||||
assert(csz!=0 && bcsz!=1 && bcsz!=8 && bcsz!=16);
|
assert(csz!=0 && bcsz!=1 && bcsz!=8 && bcsz!=16);
|
||||||
if (bcsz<64 && bcsz!=32) { assert(xe!=el_B); return true; } // not el_B because csz>0 → csz*sizeof(B) >= 64
|
if (bcsz<64 && bcsz!=32) { assert(xe!=el_B); return true; } // not el_B because csz>0 → csz*sizeof(B) >= 64
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -68,7 +68,7 @@ typedef void (*TranspFn)(void*,void*,u64,u64,u64,u64);
|
|||||||
|
|
||||||
static void transpose_move(void* rv, void* xv, u8 xe, usz w, usz h) {
|
static void transpose_move(void* rv, void* xv, u8 xe, usz w, usz h) {
|
||||||
assert(xe!=el_bit); assert(xe!=el_B);
|
assert(xe!=el_bit); assert(xe!=el_B);
|
||||||
transposeFns[elWidthLogBits(xe)-3](rv, xv, w, h, w, h);
|
transposeFns[elwByteLog(xe)](rv, xv, w, h, w, h);
|
||||||
}
|
}
|
||||||
// Return an array with data from x transposed as though it's shape h,w
|
// Return an array with data from x transposed as though it's shape h,w
|
||||||
// Shape of result needs to be set afterwards!
|
// Shape of result needs to be set afterwards!
|
||||||
@ -274,7 +274,7 @@ B transp_c2(B t, B w, B x) {
|
|||||||
j0 -= rsh[a] * str; \
|
j0 -= rsh[a] * str; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
u8 xlw = elWidthLogBits(xe);
|
u8 xlw = elwBitLog(xe);
|
||||||
if (csz >= (32*8) >> xlw) { // cell >= 32 bytes
|
if (csz >= (32*8) >> xlw) { // cell >= 32 bytes
|
||||||
usz ria = csz * shProd(rsh, 0, na);
|
usz ria = csz * shProd(rsh, 0, na);
|
||||||
MAKE_MUT_INIT(rm, ria, xe); MUTG_INIT(rm);
|
MAKE_MUT_INIT(rm, ria, xe); MUTG_INIT(rm);
|
||||||
|
|||||||
@ -53,8 +53,10 @@ extern u8 elType2type[];
|
|||||||
#define el2t(X) elType2type[X] // TODO maybe reorganize array types such that this can just be addition?
|
#define el2t(X) elType2type[X] // TODO maybe reorganize array types such that this can just be addition?
|
||||||
extern u8 elTypeWidth[];
|
extern u8 elTypeWidth[];
|
||||||
#define elWidth(X) elTypeWidth[X]
|
#define elWidth(X) elTypeWidth[X]
|
||||||
extern u8 elTypeWidthLogBits[];
|
extern u8 elwBitLogT[];
|
||||||
#define elWidthLogBits(X) elTypeWidthLogBits[X]
|
#define elwBitLog(X) elwBitLogT[X]
|
||||||
|
extern u8 elwByteLogT[];
|
||||||
|
#define elwByteLog(X) elwByteLogT[X]
|
||||||
extern u8 arrTypeWidthLog[];
|
extern u8 arrTypeWidthLog[];
|
||||||
#define arrTypeWidthLog(X) arrTypeWidthLog[X]
|
#define arrTypeWidthLog(X) arrTypeWidthLog[X]
|
||||||
extern u8 arrTypeBitsLog[];
|
extern u8 arrTypeBitsLog[];
|
||||||
|
|||||||
@ -12,15 +12,19 @@ u8 elTypeWidth[] = {
|
|||||||
[el_i8 ] = 1, [el_c8 ] = 1,
|
[el_i8 ] = 1, [el_c8 ] = 1,
|
||||||
[el_i16] = 2, [el_c16] = 2,
|
[el_i16] = 2, [el_c16] = 2,
|
||||||
[el_i32] = 4, [el_c32] = 4,
|
[el_i32] = 4, [el_c32] = 4,
|
||||||
[el_bit] = 0, [el_f64] = 8,
|
[el_f64] = 8, [el_B ] = 8, [el_bit] = 0
|
||||||
[el_B] = 8
|
|
||||||
};
|
};
|
||||||
u8 elTypeWidthLogBits[] = {
|
u8 elwBitLogT[] = {
|
||||||
[el_i8 ] = 3, [el_c8 ] = 3,
|
[el_i8 ] = 3, [el_c8 ] = 3,
|
||||||
[el_i16] = 4, [el_c16] = 4,
|
[el_i16] = 4, [el_c16] = 4,
|
||||||
[el_i32] = 5, [el_c32] = 5,
|
[el_i32] = 5, [el_c32] = 5,
|
||||||
[el_bit] = 0, [el_f64] = 6,
|
[el_f64] = 6, [el_B ] = 6, [el_bit] = 0
|
||||||
[el_B] = 6
|
};
|
||||||
|
u8 elwByteLogT[] = {
|
||||||
|
[el_i8 ] = 0, [el_c8 ] = 0,
|
||||||
|
[el_i16] = 1, [el_c16] = 1,
|
||||||
|
[el_i32] = 2, [el_c32] = 2,
|
||||||
|
[el_f64] = 3, [el_B ] = 3, [el_bit] = 99
|
||||||
};
|
};
|
||||||
u8 arrTypeWidthLog[] = {
|
u8 arrTypeWidthLog[] = {
|
||||||
[t_bitarr]=0, // 0 for mut.c hack to allow restoring a bitarr offset from array pointer & arrTypeWidthLog-"corrected" element pointer
|
[t_bitarr]=0, // 0 for mut.c hack to allow restoring a bitarr offset from array pointer & arrTypeWidthLog-"corrected" element pointer
|
||||||
|
|||||||
@ -178,7 +178,7 @@ static NOINLINE B zeroPadToCellBits0(B x, usz lr, usz cam, usz pcsz, usz ncsz) {
|
|||||||
}
|
}
|
||||||
NOINLINE B widenBitArr(B x, ur axis) {
|
NOINLINE B widenBitArr(B x, ur axis) {
|
||||||
assert(isArr(x) && TI(x,elType)!=el_B && axis>=1 && RNK(x)>=axis);
|
assert(isArr(x) && TI(x,elType)!=el_B && axis>=1 && RNK(x)>=axis);
|
||||||
usz pcsz = shProd(SH(x), axis, RNK(x))<<elWidthLogBits(TI(x,elType));
|
usz pcsz = shProd(SH(x), axis, RNK(x))<<elwBitLog(TI(x,elType));
|
||||||
assert(pcsz!=0);
|
assert(pcsz!=0);
|
||||||
usz ncsz;
|
usz ncsz;
|
||||||
if (pcsz<=8) ncsz = 8;
|
if (pcsz<=8) ncsz = 8;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user