From 797a848ed40433778bc6eb9afc103f48eb1b5ad9 Mon Sep 17 00:00:00 2001 From: dzaima Date: Sun, 26 Sep 2021 00:18:38 +0300 Subject: [PATCH] =?UTF-8?q?warn=20slow=20for=20unknown=20scans=20&=20folds?= =?UTF-8?q?=20&=20=E2=8D=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/arithd.c | 5 ++++- src/builtins/cmp.c | 5 ++++- src/builtins/grade.h | 2 ++ src/builtins/md1.c | 7 ++++++- src/builtins/sfns.c | 4 ++-- src/core/stuff.c | 12 +++++++++++- src/h.h | 5 ++++- src/utils/each.h | 1 - 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/builtins/arithd.c b/src/builtins/arithd.c index 19765511..3410a2e2 100644 --- a/src/builtins/arithd.c +++ b/src/builtins/arithd.c @@ -2,7 +2,10 @@ #include "../utils/each.h" #include -#define P2(N) { if(isArr(w)|isArr(x)) return arith_recd(N##_c2, w, x); } +#define P2(N) { if(isArr(w)|isArr(x)) { \ + SLOWIF((!isArr(w) || TI(w,elType)!=el_B) && (!isArr(x) || TI(x,elType)!=el_B)) SLOW2("arithd " #N, w, x); \ + return arith_recd(N##_c2, w, x); \ +}} #if TYPED_ARITH #define GC2f(SYMB, NAME, EXPR, EXTRA) B NAME##_c2(B t, B w, B x) { \ if (isF64(w) & isF64(x)) return m_f64(EXPR); \ diff --git a/src/builtins/cmp.c b/src/builtins/cmp.c index 800b222c..7948217b 100644 --- a/src/builtins/cmp.c +++ b/src/builtins/cmp.c @@ -2,7 +2,10 @@ #include "../utils/each.h" #include -#define P2(N) { if(isArr(w)|isArr(x)) return arith_recd(N##_c2, w, x); } +#define P2(N) { if (isArr(w)|isArr(x)) { \ + SLOWIF((!isArr(w) || TI(w,elType)!=el_B) && (!isArr(x) || TI(x,elType)!=el_B)) SLOW2("cmp " #N, w, x); \ + return arith_recd(N##_c2, w, x); \ +}} #define AL(X) i8* rp; B r = m_i8arrc(&rp, X); diff --git a/src/builtins/grade.h b/src/builtins/grade.h index ed611b6b..ee025c18 100644 --- a/src/builtins/grade.h +++ b/src/builtins/grade.h @@ -72,6 +72,7 @@ B GRADE_CAT(c1)(B t, B x) { return r; } + SLOW1(GRADE_UD("⍋","⍒")"𝕩", x); TALLOC(BI32p, tmp, ia); SGetU(x) for (usz i = 0; i < ia; i++) { @@ -124,6 +125,7 @@ B GRADE_CAT(c2)(B t, B w, B x) { } } else { SGetU(x) + SLOW2("𝕨"GRADE_UD("⍋","⍒")"𝕩", w, x); B* wp = arr_bptr(w); if (wp==NULL) { HArr* a = toHArr(w); diff --git a/src/builtins/md1.c b/src/builtins/md1.c index 47e10e7e..58ebd6eb 100644 --- a/src/builtins/md1.c +++ b/src/builtins/md1.c @@ -118,6 +118,7 @@ B scan_c1(Md1D* d, B x) { B f = d->f; } } base:; + SLOW2("π•Ž`𝕩", f, x); bool reuse = v(x)->type==t_harr && reusable(x); usz i = 0; @@ -161,6 +162,8 @@ B scan_c2(Md1D* d, B w, B x) { B f = d->f; } } base:; + SLOW3("𝕨 F` 𝕩", w, x, f); + bool reuse = (v(x)->type==t_harr && reusable(x)) | !ia; usz i = 0; HArr_p r = reuse? harr_parts(REUSE(x)) : m_harrs(a(x)->ia, &i); @@ -198,7 +201,7 @@ B fold_c1(Md1D* d, B x) { B f = d->f; u8 xe = TI(x,elType); if (isFun(f) && v(f)->flags && xe<=el_f64) { u8 rtid = v(f)->flags-1; - if (rtid==0) { // + + if (rtid==0) { // + if (xe==el_i8 ) { i8* xp = i8any_ptr (x); i64 c=0; for (usz i=0; if; } } base:; + SLOW2("π•ŽΒ΄ 𝕩", f, x); SGet(x) BBB2B fc2 = c2fn(f); @@ -276,6 +280,7 @@ B fold_c2(Md1D* d, B w, B x) { B f = d->f; } } base:; + SLOW3("𝕨 FΒ΄ 𝕩", w, x, f); B c = w; SGet(x) diff --git a/src/builtins/sfns.c b/src/builtins/sfns.c index 96832e7b..ce587af2 100644 --- a/src/builtins/sfns.c +++ b/src/builtins/sfns.c @@ -1008,7 +1008,7 @@ B select_ucw(B t, B o, B w, B x) { for (i64 i = 0; i < xia; i++) set[i] = false; #define EQ(F) if (set[cw] && (F)) thrM("π”½βŒΎ(a⊸⊏): Incompatible result elements"); set[cw] = true; #define FREE_CHECK TFREE(set) - SLOWIF(xia>100 && wia100 && wia100 && wia100 && wiaia, eltype_repr(TI(x,elType)), x); - else printf("not array\n"); + else { + printf("atom: "); + printRaw(x = bqn_fmt(inc(x))); dec(x); + putchar('\n'); + } } void warn_slow1(char* s, B x) { if (isArr(x) && a(x)->ia<100) return; @@ -745,4 +749,10 @@ NOINLINE void printAllocStats() { printf("slow %s:\n 𝕨: ", s); warn_ln(w); printf(" 𝕩: "); warn_ln(x); } + void warn_slow3(char* s, B w, B x, B y) { + if ((isArr(w)||isArr(x)) && (!isArr(x) || a(x)->ia<50) && (!isArr(x) || a(x)->ia<50)) return; + printf("slow %s:\n 𝕨: ", s); warn_ln(w); + printf(" 𝕩: "); warn_ln(x); + printf(" f: "); warn_ln(y); + } #endif diff --git a/src/h.h b/src/h.h index a995045b..8eaf7088 100644 --- a/src/h.h +++ b/src/h.h @@ -250,12 +250,15 @@ typedef struct Arr { #if WARN_SLOW==1 void warn_slow1(char* s, B x); void warn_slow2(char* s, B w, B x); + void warn_slow3(char* s, B w, B x, B y); #define SLOW1(S, X) warn_slow1(S, X) #define SLOW2(S, W, X) warn_slow2(S, W, X) + #define SLOW3(S, W, X, Y) warn_slow3(S, W, X, Y) #define SLOWIF(C) if(C) #else #define SLOW1(S, X) - #define SLOW2(S, W,X) + #define SLOW2(S, W, X) + #define SLOW3(S, W, X, Y) #define SLOWIF(C) #endif diff --git a/src/utils/each.h b/src/utils/each.h index a4aa68fc..16de2637 100644 --- a/src/utils/each.h +++ b/src/utils/each.h @@ -152,7 +152,6 @@ static B eachd(B f, B w, B x) { // complete w FΒ¨ x without fills #if CATCH_ERRORS static inline B arith_recd(BBB2B f, B w, B x) { - SLOWIF((!isArr(w) || TI(w,elType)!=el_B) && (!isArr(x) || TI(x,elType)!=el_B)) SLOW2("arith", w, x); B fx = getFillQ(x); if (noFill(fx)) return eachd_fn(f, bi_N, w, x); B fw = getFillQ(w);