mark some heuristics
This commit is contained in:
parent
1bcaebbd1f
commit
60cefa158b
@ -214,7 +214,7 @@ NOINLINE B leading_axis_arith(FC2 fc2, B w, B x, usz* wsh, usz* xsh, ur mr) { //
|
|||||||
ur br = wr>xr? wr : xr;
|
ur br = wr>xr? wr : xr;
|
||||||
|
|
||||||
usz csz = shProd(bsh, mr, br);
|
usz csz = shProd(bsh, mr, br);
|
||||||
if (csz<5120>>arrTypeBitsLog(TY(b))) {
|
if (HEURISTIC(csz<5120>>arrTypeBitsLog(TY(b)))) {
|
||||||
B s = mr==wr? w : x; // smaller argument
|
B s = mr==wr? w : x; // smaller argument
|
||||||
s = C2(slash, m_usz(csz), taga(arr_shVec(TI(s,slice)(s,0,IA(s)))));
|
s = C2(slash, m_usz(csz), taga(arr_shVec(TI(s,slice)(s,0,IA(s)))));
|
||||||
assert(reusable(s) && RNK(s)==1);
|
assert(reusable(s) && RNK(s)==1);
|
||||||
@ -265,7 +265,7 @@ static NOINLINE B pick_cells(usz ind, B x, ur xr, usz cam, usz k) { // ind <∘
|
|||||||
static void set_column_typed(void* rp, B v, u8 e, ux p, ux stride, ux n) { // may write to all elements 0 ≤ i < stride×n, and after that too for masked stores
|
static void set_column_typed(void* rp, B v, u8 e, ux p, ux stride, ux n) { // may write to all elements 0 ≤ i < stride×n, and after that too for masked stores
|
||||||
assert(p < stride);
|
assert(p < stride);
|
||||||
switch(e) { default: UD;
|
switch(e) { default: UD;
|
||||||
case el_bit: if (stride<64 && n>64) goto bit_special;
|
case el_bit: if (stride<64 && HEURISTIC(n>64)) goto bit_special;
|
||||||
NOVECTORIZE for (usz i=0; i<n; i++, p+= stride) bitp_set(rp, p, o2bG(v));return;
|
NOVECTORIZE for (usz i=0; i<n; i++, p+= stride) bitp_set(rp, p, o2bG(v));return;
|
||||||
case el_c8 : NOVECTORIZE for (usz i=0; i<n; i++, p+= stride) ((u8 *)rp)[p] = o2cG(v); return;
|
case el_c8 : NOVECTORIZE for (usz i=0; i<n; i++, p+= stride) ((u8 *)rp)[p] = o2cG(v); return;
|
||||||
case el_c16: NOVECTORIZE for (usz i=0; i<n; i++, p+= stride) ((u16*)rp)[p] = o2cG(v); return;
|
case el_c16: NOVECTORIZE for (usz i=0; i<n; i++, p+= stride) ((u16*)rp)[p] = o2cG(v); return;
|
||||||
@ -703,7 +703,7 @@ NOINLINE B for_cells_AS(B f, B w, B x, ur wcr, ur wr, u32 chr) { // F⟜x⎉wcr
|
|||||||
if (IA(w)!=0 && isPervasiveDy(f)) {
|
if (IA(w)!=0 && isPervasiveDy(f)) {
|
||||||
if (isAtm(x)) return c2(f, w, x);
|
if (isAtm(x)) return c2(f, w, x);
|
||||||
if (RNK(x)!=wcr || !eqShPart(SH(x), wsh+wk, wcr)) goto generic;
|
if (RNK(x)!=wcr || !eqShPart(SH(x), wsh+wk, wcr)) goto generic;
|
||||||
if (TI(w,elType)==el_B || TI(x,elType)==el_B || (IA(x)>(2048*8)>>arrTypeBitsLog(TY(x)) && IA(w)!=IA(x))) goto generic;
|
if (TI(w,elType)==el_B || TI(x,elType)==el_B || HEURISTIC(IA(x)>(2048*8)>>arrTypeBitsLog(TY(x)) && IA(w)!=IA(x))) goto generic;
|
||||||
return c2(f, w, C2(shape, C1(fne, incG(w)), x));
|
return c2(f, w, C2(shape, C1(fne, incG(w)), x));
|
||||||
}
|
}
|
||||||
} else if (!isMd(f)) {
|
} else if (!isMd(f)) {
|
||||||
@ -812,7 +812,7 @@ NOINLINE B for_cells_SA(B f, B w, B x, ur xcr, ur xr, u32 chr) { // w⊸F⎉xcr
|
|||||||
if (isAtm(w)) return c2(f, w, x);
|
if (isAtm(w)) return c2(f, w, x);
|
||||||
if (IA(x)==0) break;
|
if (IA(x)==0) break;
|
||||||
if (RNK(w)!=xcr || !eqShPart(SH(w), xsh+xk, xcr)) break;
|
if (RNK(w)!=xcr || !eqShPart(SH(w), xsh+xk, xcr)) break;
|
||||||
if (TI(w,elType)==el_B || TI(x,elType)==el_B || (IA(w)>(2048*8)>>arrTypeBitsLog(TY(w)) && IA(w)!=IA(x))) break;
|
if (TI(w,elType)==el_B || TI(x,elType)==el_B || HEURISTIC(IA(w)>(2048*8)>>arrTypeBitsLog(TY(w)) && IA(w)!=IA(x))) break;
|
||||||
return c2(f, C2(shape, C1(fne, incG(x)), w), x);
|
return c2(f, C2(shape, C1(fne, incG(x)), w), x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -291,7 +291,7 @@ B select_c2(B t, B w, B x) {
|
|||||||
#define BOOL_SPECIAL(W)
|
#define BOOL_SPECIAL(W)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!bool_use_simd && xe==el_bit && (csz&7)!=0 && (xl==0? wia>=256 : wia>=4) && csz<128 && TI(w,arrD1)) {
|
if (!bool_use_simd && xe==el_bit && (csz&7)!=0 && HEURISTIC(xl==0? wia>=256 : wia>=4) && csz<128 && TI(w,arrD1)) {
|
||||||
// test widen/narrow on bitarr input
|
// test widen/narrow on bitarr input
|
||||||
// ShArr* sh = RNK(x)==1? NULL : ptr_inc(shObj(x));
|
// ShArr* sh = RNK(x)==1? NULL : ptr_inc(shObj(x));
|
||||||
// B t = C2(select, w, widenBitArr(x, 1));
|
// B t = C2(select, w, widenBitArr(x, 1));
|
||||||
@ -300,7 +300,7 @@ B select_c2(B t, B w, B x) {
|
|||||||
// return r;
|
// return r;
|
||||||
if (csz==1) {
|
if (csz==1) {
|
||||||
if (wia/4>=xia) return taga(cpyBitArr(C2(select, w, taga(cpyI8Arr(x)))));
|
if (wia/4>=xia) return taga(cpyBitArr(C2(select, w, taga(cpyI8Arr(x)))));
|
||||||
} else if (csz>64? wia/2>=xn : wia>=xn/2) {
|
} else if (HEURISTIC(csz>64? wia/2>=xn : wia>=xn/2)) {
|
||||||
ShArr* sh = ptr_inc(shObj(x));
|
ShArr* sh = ptr_inc(shObj(x));
|
||||||
B t = C2(select, w, widenBitArr(x, 1));
|
B t = C2(select, w, widenBitArr(x, 1));
|
||||||
B r = narrowWidenedBitArr(t, wr, xr-1, sh->a+1);
|
B r = narrowWidenedBitArr(t, wr, xr-1, sh->a+1);
|
||||||
@ -368,11 +368,12 @@ B select_c2(B t, B w, B x) {
|
|||||||
case el_i16: TYPE(i16,cpyI32Arr)
|
case el_i16: TYPE(i16,cpyI32Arr)
|
||||||
case el_i32: TYPE(i32,cpyF64Arr)
|
case el_i32: TYPE(i32,cpyF64Arr)
|
||||||
case el_f64: {
|
case el_f64: {
|
||||||
if (FL_HAS(w, fl_squoze)) goto generic_l; // either has non-integers (i.e. error, thus don't care about speed) or very large (i.e. will hit memory bandwidth anyway)
|
if (MAY_T(FL_HAS(w, fl_squoze))) goto generic_l; // either has non-integers (i.e. error, thus don't care about speed) or very large (i.e. will hit memory bandwidth anyway)
|
||||||
// else fallthrough - want to do integer 𝕨 if possible
|
// else fallthrough - want to do integer 𝕨 if possible
|
||||||
}
|
}
|
||||||
case el_B: case el_c8: case el_c16: case el_c32: {
|
case el_B: case el_c8: case el_c16: case el_c32: {
|
||||||
w = squeeze_numTry(w, &we);
|
w = squeeze_numTry(w, &we);
|
||||||
|
if (RANDOMIZE_HEURISTICS && we==el_f64) goto generic_l; // avoid infinite loop
|
||||||
if (elNum(we)) goto retry;
|
if (elNum(we)) goto retry;
|
||||||
goto def_xf_base;
|
goto def_xf_base;
|
||||||
}
|
}
|
||||||
@ -721,8 +722,7 @@ B select_rows_direct(B x, ux csz, ux cam, void* inds, ux indn, u8 ie) { // ⥊ (
|
|||||||
|
|
||||||
if (ie==el_bit) {
|
if (ie==el_bit) {
|
||||||
// TODO path for xe==el_bit + long indn
|
// TODO path for xe==el_bit + long indn
|
||||||
if (csz>32 || indn>32 || indn>INDS_BUF_MAX) { // TODO properly tune
|
if (HEURISTIC_BOUNDED(csz>32 || indn>32 || indn>INDS_BUF_MAX, xe!=el_bit && (csz>8 || indn>8), true)) { // TODO properly tune
|
||||||
assert(xe!=el_bit && (csz>8 || indn>8));
|
|
||||||
u8* rp = m_arrv_same(&r, ria, x);
|
u8* rp = m_arrv_same(&r, ria, x);
|
||||||
for (ux i = 0; i < cam; i++) {
|
for (ux i = 0; i < cam; i++) {
|
||||||
bitselFns[lb](rp, inds, loadu_u64(xp), loadu_u64(xp + (1<<lb)), indn);
|
bitselFns[lb](rp, inds, loadu_u64(xp), loadu_u64(xp + (1<<lb)), indn);
|
||||||
@ -1030,7 +1030,7 @@ B select_ucw(B t, B o, B w, B x) {
|
|||||||
|
|
||||||
usz wia = IA(w);
|
usz wia = IA(w);
|
||||||
B rep;
|
B rep;
|
||||||
if (isArr(o) && RNK(x)>0) {
|
if (MAY_F(isArr(o) && RNK(x)>0)) {
|
||||||
usz xn = *SH(x);
|
usz xn = *SH(x);
|
||||||
i64 buf[2];
|
i64 buf[2];
|
||||||
if (wia!=0 && (!getRange_fns[we](tyany_ptr(w), buf, wia) || buf[0]<-(i64)xn || buf[1]>=xn)) {
|
if (wia!=0 && (!getRange_fns[we](tyany_ptr(w), buf, wia) || buf[0]<-(i64)xn || buf[1]>=xn)) {
|
||||||
@ -1039,7 +1039,7 @@ B select_ucw(B t, B o, B w, B x) {
|
|||||||
fatal("select_ucw expected to error");
|
fatal("select_ucw expected to error");
|
||||||
}
|
}
|
||||||
rep = incG(o);
|
rep = incG(o);
|
||||||
} else if (isFun(o) && TY(o)==t_md1D && RNK(x)==1) {
|
} else if (MAY_F(isFun(o) && TY(o)==t_md1D && RNK(x)==1)) {
|
||||||
Md1D* od = c(Md1D,o);
|
Md1D* od = c(Md1D,o);
|
||||||
if (PRTID(od->m1) != n_each) goto notConstEach;
|
if (PRTID(od->m1) != n_each) goto notConstEach;
|
||||||
B c;
|
B c;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user