use fast path for inds⊸⊏˘el_B and ⌽˘el_B
This commit is contained in:
parent
6900ae4b68
commit
bc81b26a03
@ -503,9 +503,9 @@ B for_cells_c1(B f, u32 xr, u32 cr, u32 k, B x, u32 chr) { // F⎉cr x; array x,
|
|||||||
case n_reverse: {
|
case n_reverse: {
|
||||||
if (cr == 0) break;
|
if (cr == 0) break;
|
||||||
ux csz = xsh[k];
|
ux csz = xsh[k];
|
||||||
if (csz <= 1 || IA(x)==0) return x;
|
if (csz<=1 || IA(x)==0) return x;
|
||||||
u8 xe = TI(x,elType);
|
u8 xe = TI(x,elType);
|
||||||
if (cr==1 && csz<=64 && xe!=el_bit && xe!=el_B && csz < (128*8 >> arrTypeBitsLog(TY(x)))) {
|
if (cr==1 && csz<=64 && xe!=el_bit && csz < (128*8 >> arrTypeBitsLog(TY(x)))) {
|
||||||
incG(x); // TODO proper shape moving
|
incG(x); // TODO proper shape moving
|
||||||
Arr* r = customizeShape(select_rows_direct(x, csz, cam, reverse_inds_64+64-csz, csz, el_i8));
|
Arr* r = customizeShape(select_rows_direct(x, csz, cam, reverse_inds_64+64-csz, csz, el_i8));
|
||||||
arr_shCopy(r, x);
|
arr_shCopy(r, x);
|
||||||
|
|||||||
@ -559,9 +559,15 @@ B select_replace(u32 chr, B w, B x, B rep, usz wia, usz cam, usz csz) { // consu
|
|||||||
#undef FREE_CHECK
|
#undef FREE_CHECK
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* m_tyarrv_same(B* r, usz ia, B src) { // makes a new typed array with same element type as src, but new ia
|
static void* m_arrv_same(B* r, usz ia, B src) { // makes a new array with same element type as src, but new ia
|
||||||
u8 se = TI(src,elType); assert(se!=el_bit && se!=el_B);
|
u8 se = TI(src,elType); assert(se!=el_bit);
|
||||||
|
if (se==el_B) {
|
||||||
|
HArr_p p = m_harr0v(ia);
|
||||||
|
*r = p.b;
|
||||||
|
return p.a;
|
||||||
|
} else {
|
||||||
return m_tyarrlv(r, arrTypeWidthLog(TY(src)), ia, arrNewType(TY(src)));
|
return m_tyarrlv(r, arrTypeWidthLog(TY(src)), ia, arrNewType(TY(src)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
B slash_c2(B, B, B);
|
B slash_c2(B, B, B);
|
||||||
@ -596,8 +602,15 @@ B select_rows_direct(B x, ux csz, ux cam, void* inds, ux indn, u8 ie) { // ⥊ (
|
|||||||
|
|
||||||
u8 xe = TI(x,elType);
|
u8 xe = TI(x,elType);
|
||||||
u8 lb = arrTypeWidthLog(TY(x));
|
u8 lb = arrTypeWidthLog(TY(x));
|
||||||
u8* xp = tyany_ptr(x);
|
u8* xp;
|
||||||
if (xe==el_bit || xe==el_B) goto generic_any;
|
if (xe==el_B) {
|
||||||
|
if (sizeof(B) != 8) goto generic_any;
|
||||||
|
xp = (u8*) arr_bptr(x);
|
||||||
|
if (xp == NULL) goto generic_any;
|
||||||
|
} else {
|
||||||
|
if (xe == el_bit) goto generic_any;
|
||||||
|
xp = tyany_ptr(x);
|
||||||
|
}
|
||||||
|
|
||||||
B r;
|
B r;
|
||||||
ux ria = indn * cam;
|
ux ria = indn * cam;
|
||||||
@ -608,7 +621,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) {
|
||||||
if (csz>32 || indn>32 || indn>INDS_BUF_MAX) { // TODO properly tune
|
if (csz>32 || indn>32 || indn>INDS_BUF_MAX) { // TODO properly tune
|
||||||
u8* rp = m_tyarrv_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);
|
||||||
xp+= xbump;
|
xp+= xbump;
|
||||||
@ -667,7 +680,7 @@ B select_rows_direct(B x, ux csz, ux cam, void* inds, ux indn, u8 ie) { // ⥊ (
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
u8* rp = m_tyarrv_same(&r, ria, x);
|
u8* rp = m_arrv_same(&r, ria, x);
|
||||||
|
|
||||||
ux slow_cam = cam;
|
ux slow_cam = cam;
|
||||||
#if SINGELI_AVX2 || SINGELI_NEON
|
#if SINGELI_AVX2 || SINGELI_NEON
|
||||||
@ -748,12 +761,18 @@ B select_rows_direct(B x, ux csz, ux cam, void* inds, ux indn, u8 ie) { // ⥊ (
|
|||||||
assert(generic_allowed);
|
assert(generic_allowed);
|
||||||
return select_cells_base(indo, x, csz, cam);
|
return select_cells_base(indo, x, csz, cam);
|
||||||
}
|
}
|
||||||
|
goto generic_int;
|
||||||
|
|
||||||
generic_int:;
|
generic_int:;
|
||||||
assert(ie!=el_bit && generic_allowed);
|
assert(ie!=el_bit && generic_allowed);
|
||||||
B indo = taga(arr_shVec(m_tyslice(inds, a(emptyIVec()), ie, indn)));
|
B indo = taga(arr_shVec(m_tyslice(inds, a(emptyIVec()), ie, indn)));
|
||||||
return select_cells_base(indo, x, csz, cam);
|
return select_cells_base(indo, x, csz, cam);
|
||||||
|
|
||||||
decG_ret:;
|
decG_ret:;
|
||||||
|
if (xe==el_B) {
|
||||||
|
B* rp = harr_ptr(r);
|
||||||
|
for (ux i = 0; i < ria; i++) inc(rp[i]); // TODO if only a few columns are selected, could incBy in a stride per selected column
|
||||||
|
}
|
||||||
decG(x);
|
decG(x);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,4 +32,5 @@
|
|||||||
Test {{@ + 𝕩 •rand.Range 100}}
|
Test {{@ + 𝕩 •rand.Range 100}}
|
||||||
Test {{@ + 𝕩 •rand.Range 1000}}
|
Test {{@ + 𝕩 •rand.Range 1000}}
|
||||||
Test {{@ + 𝕩 •rand.Range 1114111}}
|
Test {{@ + 𝕩 •rand.Range 1114111}}
|
||||||
|
Test {{⊑⟜"foo"‿@¨ 𝕩 •rand.Range 2}}
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user