numbl 0.2.0 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/binding.gyp +24 -36
  2. package/dist-cli/cli.js +16096 -18209
  3. package/dist-lib/graphics/types.d.ts +22 -0
  4. package/dist-lib/lib.d.ts +1 -0
  5. package/dist-lib/lib.js +61324 -62782
  6. package/dist-lib/numbl-core/executeCode.d.ts +11 -21
  7. package/dist-lib/numbl-core/executors/cJit/builtins.d.ts +30 -0
  8. package/dist-lib/numbl-core/executors/cJit/chainCodegen.d.ts +59 -0
  9. package/dist-lib/numbl-core/executors/cJit/chainExecutor.d.ts +27 -0
  10. package/dist-lib/numbl-core/executors/cJit/chainPass.d.ts +42 -0
  11. package/dist-lib/numbl-core/executors/cJit/codegen.d.ts +44 -0
  12. package/dist-lib/numbl-core/executors/cJit/compile.d.ts +45 -0
  13. package/dist-lib/numbl-core/executors/cJit/elemwiseCodegen.d.ts +23 -0
  14. package/dist-lib/numbl-core/executors/cJit/elemwiseStructural.d.ts +33 -0
  15. package/dist-lib/numbl-core/executors/cJit/fuseAnalyze.d.ts +39 -0
  16. package/dist-lib/numbl-core/executors/cJit/fuseCodegen.d.ts +16 -0
  17. package/dist-lib/numbl-core/executors/cJit/fuseExecutor.d.ts +28 -0
  18. package/dist-lib/numbl-core/executors/cJit/loopExecutor.d.ts +32 -0
  19. package/dist-lib/numbl-core/executors/cJit/register.d.ts +10 -0
  20. package/dist-lib/numbl-core/executors/cJit/whitelist.d.ts +15 -0
  21. package/dist-lib/numbl-core/executors/cache.d.ts +26 -0
  22. package/dist-lib/numbl-core/executors/context.d.ts +76 -0
  23. package/dist-lib/numbl-core/executors/index.d.ts +17 -0
  24. package/dist-lib/numbl-core/executors/jsJit/callExecutor.d.ts +25 -0
  25. package/dist-lib/numbl-core/{jit/js → executors/jsJit/codegen}/jitCodegen.d.ts +2 -2
  26. package/dist-lib/numbl-core/{jit/js → executors/jsJit/codegen}/jitCodegenHoist.d.ts +1 -1
  27. package/dist-lib/numbl-core/executors/jsJit/codegen/jsMultiReduction.d.ts +67 -0
  28. package/dist-lib/numbl-core/executors/jsJit/helpers/alloc.d.ts +12 -0
  29. package/dist-lib/numbl-core/{jit/js → executors/jsJit/helpers}/jitHelpers.d.ts +2 -2
  30. package/dist-lib/numbl-core/{jit/js → executors/jsJit/helpers}/jitHelpersComplex.d.ts +1 -1
  31. package/dist-lib/numbl-core/executors/jsJit/helpers/jitHelpersIndex.d.ts +33 -0
  32. package/dist-lib/numbl-core/{jit/js → executors/jsJit/helpers}/jitHelpersTensor.d.ts +7 -7
  33. package/dist-lib/numbl-core/executors/jsJit/jitCall.d.ts +59 -0
  34. package/dist-lib/numbl-core/executors/jsJit/jitLoop.d.ts +53 -0
  35. package/dist-lib/numbl-core/executors/jsJit/jitTopLevel.d.ts +44 -0
  36. package/dist-lib/numbl-core/executors/jsJit/loopExecutor.d.ts +15 -0
  37. package/dist-lib/numbl-core/{jit/jitLoopAnalysis.d.ts → executors/jsJit/lower/blockAnalysis.d.ts} +5 -5
  38. package/dist-lib/numbl-core/{jit → executors/jsJit/lower}/jitBailSafety.d.ts +1 -1
  39. package/dist-lib/numbl-core/{jit → executors/jsJit/lower}/jitLower.d.ts +18 -4
  40. package/dist-lib/numbl-core/{jit → executors/jsJit/lower}/jitLowerExpr.d.ts +11 -2
  41. package/dist-lib/numbl-core/{jit → executors/jsJit/lower}/jitLowerStmt.d.ts +2 -2
  42. package/dist-lib/numbl-core/{jit → executors/jsJit/lower}/jitLowerTypes.d.ts +2 -2
  43. package/dist-lib/numbl-core/{jit → executors/jsJit/lower}/scalarEmit.d.ts +2 -2
  44. package/dist-lib/numbl-core/executors/jsJit/shared.d.ts +120 -0
  45. package/dist-lib/numbl-core/executors/jsJit/topLevelExecutor.d.ts +17 -0
  46. package/dist-lib/numbl-core/executors/lowering.d.ts +166 -0
  47. package/dist-lib/numbl-core/executors/plugins.d.ts +39 -0
  48. package/dist-lib/numbl-core/executors/registry.d.ts +148 -0
  49. package/dist-lib/numbl-core/executors/types.d.ts +103 -0
  50. package/dist-lib/numbl-core/fileIOAdapter.d.ts +2 -0
  51. package/dist-lib/numbl-core/functionResolve.d.ts +7 -0
  52. package/dist-lib/numbl-core/helpers/check-helpers.d.ts +4 -5
  53. package/dist-lib/numbl-core/helpers/linsolve.d.ts +2 -3
  54. package/dist-lib/numbl-core/helpers/prng.d.ts +1 -2
  55. package/dist-lib/numbl-core/interpreter/builtins/datetime.d.ts +2 -1
  56. package/dist-lib/numbl-core/interpreter/builtins/misc.d.ts +4 -1
  57. package/dist-lib/numbl-core/interpreter/builtins/types.d.ts +4 -91
  58. package/dist-lib/numbl-core/interpreter/interpreter.d.ts +34 -44
  59. package/dist-lib/numbl-core/interpreter/interpreterSpecialBuiltins.d.ts +6 -3
  60. package/dist-lib/numbl-core/interpreter/types.d.ts +27 -12
  61. package/dist-lib/numbl-core/{jit/jitTypes.d.ts → jitTypes.d.ts} +15 -1
  62. package/dist-lib/numbl-core/jsUserFunctions.d.ts +8 -0
  63. package/dist-lib/numbl-core/lowering/loweringContext.d.ts +24 -0
  64. package/dist-lib/numbl-core/native/lapack-bridge.d.ts +3 -3
  65. package/dist-lib/numbl-core/parser/types.d.ts +20 -0
  66. package/dist-lib/numbl-core/runtime/constructors.d.ts +6 -6
  67. package/dist-lib/numbl-core/runtime/cow.d.ts +33 -0
  68. package/dist-lib/numbl-core/runtime/index.d.ts +3 -2
  69. package/dist-lib/numbl-core/runtime/indexing.d.ts +6 -1
  70. package/dist-lib/numbl-core/runtime/plotBuiltinDispatch.d.ts +86 -0
  71. package/dist-lib/numbl-core/runtime/plotUtils.d.ts +17 -2
  72. package/dist-lib/numbl-core/runtime/refcount.d.ts +85 -0
  73. package/dist-lib/numbl-core/runtime/runtime.d.ts +27 -66
  74. package/dist-lib/numbl-core/runtime/runtimeDispatch.d.ts +2 -2
  75. package/dist-lib/numbl-core/runtime/runtimeIndexing.d.ts +2 -2
  76. package/dist-lib/numbl-core/runtime/runtimeMemberAccess.d.ts +1 -1
  77. package/dist-lib/numbl-core/runtime/runtimePlot.d.ts +1 -0
  78. package/dist-lib/numbl-core/runtime/struct-access.d.ts +2 -1
  79. package/dist-lib/numbl-core/runtime/types.d.ts +104 -62
  80. package/dist-lib/numbl-core/runtime/utils.d.ts +2 -8
  81. package/dist-lib/numbl-core/version.d.ts +1 -1
  82. package/dist-plot-viewer/assets/index-COAM8o1E.js +4426 -0
  83. package/dist-plot-viewer/index.html +1 -1
  84. package/native/lapack_linsolve.cpp +1 -1
  85. package/native/numbl_addon.cpp +9 -0
  86. package/native/numbl_addon_common.h +2 -2
  87. package/native/ops/comparison.c +1 -1
  88. package/package.json +3 -8
  89. package/dist-lib/numbl-core/jit/c/abi.d.ts +0 -90
  90. package/dist-lib/numbl-core/jit/c/assemble.d.ts +0 -56
  91. package/dist-lib/numbl-core/jit/c/classify.d.ts +0 -70
  92. package/dist-lib/numbl-core/jit/c/compile.d.ts +0 -37
  93. package/dist-lib/numbl-core/jit/c/context.d.ts +0 -152
  94. package/dist-lib/numbl-core/jit/c/emit/assign.d.ts +0 -20
  95. package/dist-lib/numbl-core/jit/c/emit/complexScalar.d.ts +0 -18
  96. package/dist-lib/numbl-core/jit/c/emit/fused.d.ts +0 -42
  97. package/dist-lib/numbl-core/jit/c/emit/helpers.d.ts +0 -40
  98. package/dist-lib/numbl-core/jit/c/emit/index.d.ts +0 -14
  99. package/dist-lib/numbl-core/jit/c/emit/scalar.d.ts +0 -23
  100. package/dist-lib/numbl-core/jit/c/emit/stmt.d.ts +0 -25
  101. package/dist-lib/numbl-core/jit/c/emit/tensor.d.ts +0 -127
  102. package/dist-lib/numbl-core/jit/c/emit/userCall.d.ts +0 -58
  103. package/dist-lib/numbl-core/jit/c/epilogue.d.ts +0 -26
  104. package/dist-lib/numbl-core/jit/c/feasibility.d.ts +0 -44
  105. package/dist-lib/numbl-core/jit/c/hybrid.d.ts +0 -42
  106. package/dist-lib/numbl-core/jit/c/install.d.ts +0 -15
  107. package/dist-lib/numbl-core/jit/c/parityError.d.ts +0 -26
  108. package/dist-lib/numbl-core/jit/c/prelude.d.ts +0 -37
  109. package/dist-lib/numbl-core/jit/c/registry.d.ts +0 -51
  110. package/dist-lib/numbl-core/jit/c/visit.d.ts +0 -63
  111. package/dist-lib/numbl-core/jit/e1/install.d.ts +0 -13
  112. package/dist-lib/numbl-core/jit/e1/kernelEmit.d.ts +0 -54
  113. package/dist-lib/numbl-core/jit/e1/openmpFlag.d.ts +0 -13
  114. package/dist-lib/numbl-core/jit/e1/scalarFnKernel.d.ts +0 -44
  115. package/dist-lib/numbl-core/jit/fusedChainHelpers.d.ts +0 -65
  116. package/dist-lib/numbl-core/jit/fusedScalarEmit.d.ts +0 -61
  117. package/dist-lib/numbl-core/jit/fusion.d.ts +0 -71
  118. package/dist-lib/numbl-core/jit/fusionOps.d.ts +0 -25
  119. package/dist-lib/numbl-core/jit/index.d.ts +0 -7
  120. package/dist-lib/numbl-core/jit/jitLoop.d.ts +0 -25
  121. package/dist-lib/numbl-core/jit/jitTopLevel.d.ts +0 -22
  122. package/dist-lib/numbl-core/jit/js/jitHelpersIndex.d.ts +0 -33
  123. package/dist-lib/numbl-core/jit/js/jsFusedCodegen.d.ts +0 -17
  124. package/dist-lib/numbl-core/runtime/alloc.d.ts +0 -23
  125. package/dist-plot-viewer/assets/index-GiUNnMQg.js +0 -4426
  126. package/native/jit_runtime/jit_runtime.c +0 -261
  127. package/native/jit_runtime/jit_runtime.h +0 -204
@@ -1,44 +0,0 @@
1
- /**
2
- * e1 (experimental) — whole-function scalar kernel emission.
3
- *
4
- * Complements [kernelEmit.ts](./kernelEmit.ts) (which handles tensor
5
- * fusible chains) by covering the other big win case: a user function
6
- * that is entirely scalar arithmetic — e.g. the inner loop of a
7
- * Horner-style series, a Runge-Kutta step on a handful of doubles,
8
- * benchmarks/scalar_bench.m's `run_bench(N, M)`.
9
- *
10
- * Under `--opt e1`, when a JIT-able function's signature and body are
11
- * purely scalar, we call `generateC()` (the same emitter the C-JIT
12
- * uses at `--opt 2`) and wrap its output with a thin inline JS
13
- * function that shells out to `$h.compileKernel(...)`. The C source
14
- * and koffi signature are inlined as JS string literals, so
15
- * `--dump-js` shows the complete picture.
16
- *
17
- * Scope for the prototype:
18
- * - All params are scalar doubles / booleans (CParamDesc.kind === "scalar")
19
- * - All outputs are scalar / boolean (COutputDesc.kind === "scalar" | "boolean")
20
- * - No tic/toc, no Index reads (no errFlag), no disp(...) calls
21
- *
22
- * Anything outside that envelope returns `null` and the caller falls
23
- * back to the plain JS-JIT path, which still benefits from e1's
24
- * per-chain tensor kernels.
25
- */
26
- import type { FunctionDef } from "../../interpreter/types.js";
27
- import type { JitStmt, JitType } from "../jitTypes.js";
28
- import type { GeneratedFn } from "../jitLower.js";
29
- import type { Interpreter } from "../../interpreter/interpreter.js";
30
- export interface ScalarFnKernelResult {
31
- /** The inline-compileKernel JS source. The JIT caller splices this
32
- * in place of the normal JS-JIT body. */
33
- jsSource: string;
34
- /** Content-addressed kernel name from generateC, for logging. */
35
- kernelName: string;
36
- /** Raw C source (also embedded in `jsSource` as a string literal).
37
- * Exposed for `--dump-c` / logging. */
38
- cSource: string;
39
- }
40
- /**
41
- * Try to emit a whole-function scalar kernel for the given lowered IR.
42
- * Returns null when the function is not a pure-scalar candidate.
43
- */
44
- export declare function tryEmitScalarFnKernel(interp: Interpreter, fn: FunctionDef, body: JitStmt[], outputNames: string[], localVars: Set<string>, outputType: JitType | null, outputTypes: JitType[], argTypes: JitType[], nargout: number, generatedIRBodies: Map<string, GeneratedFn>): ScalarFnKernelResult | null;
@@ -1,65 +0,0 @@
1
- /**
2
- * Chain-level helpers shared by the JS and C fused-codegen backends.
3
- *
4
- * The per-element scalar expression walker lives in `fusedScalarEmit.ts`;
5
- * this module covers the surrounding logic that decides which chain dests
6
- * need a write-back to their tensor buffer, and the reduction-accumulator
7
- * init/combine snippets for inline reductions.
8
- *
9
- * Reductions are parameterized over a small `ReductionLiterals` record so
10
- * each backend supplies its own spelling of `0` vs `0.0`, `===` vs `==`,
11
- * `-Infinity` vs `(-1.0/0.0)`, etc. — the control structure is identical.
12
- */
13
- import { BinaryOperation } from "../parser/types.js";
14
- import type { FusibleChain } from "./fusion.js";
15
- /**
16
- * Compute the set of distinct dest names in a fused chain and which of
17
- * them require a write-back into their tensor buffer.
18
- *
19
- * A dest normally needs write-back; the exception is the chain's last
20
- * tensor if it is fully consumed by a trailing reduction (in which case
21
- * the scalar reduction accumulator is the only output — materialising
22
- * the tensor buffer would be wasted work). If that last-dest tensor is
23
- * ALSO a named output of the enclosing function, the write-back is kept
24
- * so the caller sees the updated buffer.
25
- */
26
- export declare function determineWriteBack(chain: FusibleChain, outputTensorNames: ReadonlySet<string>): {
27
- destNames: Set<string>;
28
- writeBack: Set<string>;
29
- reductionConsumes: boolean;
30
- };
31
- /**
32
- * Target-specific literal spellings used by the reduction helpers.
33
- *
34
- * The structure of the reduction snippets is identical between JS and
35
- * C, but the literals differ: JS uses `1`, `-Infinity`, `===`/`!==`,
36
- * while C uses `1.0`, `(-1.0/0.0)`, `==`/`!=`. The caller picks a
37
- * record for its target and reuses it.
38
- */
39
- export interface ReductionLiterals {
40
- /** Additive identity (`0` for JS, `0.0` for C). */
41
- zero: string;
42
- /** Multiplicative identity / truthy (`1` or `1.0`). */
43
- one: string;
44
- /** Positive infinity literal (`Infinity` or `(1.0/0.0)`). */
45
- posInf: string;
46
- /** Negative infinity literal (`-Infinity` or `(-1.0/0.0)`). */
47
- negInf: string;
48
- /** Strict-equality operator (`===` for JS, `==` for C). */
49
- eq: string;
50
- /** Strict-inequality operator (`!==` for JS, `!=` for C). */
51
- neq: string;
52
- }
53
- export declare const JS_REDUCTION_LITERALS: ReductionLiterals;
54
- export declare const C_REDUCTION_LITERALS: ReductionLiterals;
55
- /** Initial value expression for a reduction accumulator. */
56
- export declare function reductionInit(reduceName: string, lits: ReductionLiterals): string;
57
- /** Statement that folds a per-element `valueExpr` into the accumulator. */
58
- export declare function reductionCombine(reduceName: string, accVar: string, valueExpr: string, lits: ReductionLiterals): string;
59
- /**
60
- * Statement that folds a per-chain `val` into an enclosing accumulator
61
- * `dest` via the outer-loop op (e.g. `ir_acc = ir_acc + sum(...)`).
62
- *
63
- * Target-neutral: `+=` / `-=` / `*=` have identical syntax in JS and C.
64
- */
65
- export declare function accumulateOp(op: BinaryOperation, dest: string, val: string): string;
@@ -1,61 +0,0 @@
1
- /**
2
- * Shared per-element scalar-expression emission for fused loops.
3
- *
4
- * Both the JS-JIT and C-JIT fused-chain emitters walk the chain's
5
- * expression trees and emit each sub-expression in "per-element"
6
- * form — tensor Vars become `data[__i]` reads (or a scalar local for
7
- * chain-produced intermediates), Binary/Unary/Call map to scalar
8
- * operations that will run once per element of the fused loop.
9
- *
10
- * The walk itself is identical between the two backends; only the
11
- * leaf syntax differs (JS `Math.sin` vs C `sin`, integer literal
12
- * formatting, mangling prefix). A backend supplies a `FusedTarget`
13
- * describing those leaves and a value-form `ScalarOpTarget` for the
14
- * arithmetic/comparison/logical switches.
15
- *
16
- * Note: the op target used here must emit comparison / logical ops
17
- * in *numeric* form (result is a double 0.0/1.0 suitable for tensor
18
- * write-back). For C this coincides with the regular value target;
19
- * for JS a second target instance is needed because value-form
20
- * comparisons return a JS boolean.
21
- */
22
- import type { JitExpr } from "./jitTypes.js";
23
- import type { FusibleChain } from "./fusion.js";
24
- import { type ScalarOpTarget } from "./scalarEmit.js";
25
- /** Scalar local name for a chain-produced tensor intermediate. */
26
- export declare function fusedLocal(name: string): string;
27
- export interface FusedTarget {
28
- /** Format a numeric literal (e.g. `1` for JS, `1.0` for C). */
29
- formatNumber(v: number): string;
30
- /** Mangle a scalar variable reference (non-tensor). */
31
- mangle(name: string): string;
32
- /**
33
- * Emit a per-element read of tensor var `name` — i.e. the expression
34
- * that yields `data[__i]` for that tensor. The backend decides how
35
- * the data pointer is named and whether it's aliased locally.
36
- */
37
- tensorElemRead(name: string): string;
38
- /**
39
- * Emit a call to a scalar math builtin. The backend decides which
40
- * builtins it supports and how they map to library functions (e.g.
41
- * JS `Math.sin` vs C `sin`). Return `null` to reject.
42
- *
43
- * `name` is the builtin name (e.g. `"sin"`, `"mod"`, `"rem"`);
44
- * `args` are already-emitted per-element scalar expressions.
45
- */
46
- emitBuiltinCall(name: string, args: string[]): string | null;
47
- }
48
- /** Shared walker: emit a JitExpr as a per-element scalar expression. */
49
- export declare function emitFusedScalarExpr(expr: JitExpr, chainLocals: ReadonlySet<string>, allTensorVars: ReadonlySet<string>, opTarget: ScalarOpTarget, fusedTarget: FusedTarget): string;
50
- /**
51
- * Find the first tensor-param name referenced in a chain's assigns.
52
- * Used by both backends to pick the length-determining tensor.
53
- */
54
- export declare function findTensorParamInChain(chain: FusibleChain, paramTensors: ReadonlySet<string>, allTensorVars: ReadonlySet<string>): string | null;
55
- /**
56
- * Collect distinct tensor names referenced in the chain's expression
57
- * trees that are NOT produced by the chain itself (i.e. read from
58
- * outside: params or pre-existing locals). Both backends need this to
59
- * pick a length-reference tensor when no formal param is in the chain.
60
- */
61
- export declare function collectInputTensors(chain: FusibleChain, allTensorVars: ReadonlySet<string>): Set<string>;
@@ -1,71 +0,0 @@
1
- /**
2
- * Fusion analysis for JIT backends (shared by JS-JIT and C-JIT).
3
- *
4
- * Scans a statement list for runs of tensor element-wise assigns that
5
- * can be collapsed into a single per-element `for` loop. Each such run
6
- * is a "fusible chain."
7
- *
8
- * A chain breaks on:
9
- * - control flow (If/For/While)
10
- * - any non-Assign statement
11
- * - a tensor assign whose RHS references a tensor that is NOT an input
12
- * param and NOT previously assigned within the same chain
13
- * - a scalar assign (left for the per-op emitter)
14
- *
15
- * An optional **trailing reduction** is absorbed when the statement
16
- * immediately after a tensor chain is of the form
17
- * `acc = acc + reduce(lastChainVar)` or
18
- * `acc = reduce(lastChainVar)`
19
- * where `reduce` is sum/prod/max/min/mean/any/all. Absorbing the
20
- * reduction lets the fused loop emit an inline accumulator instead of
21
- * materialising the intermediate buffer.
22
- */
23
- import type { JitExpr, JitStmt } from "./jitTypes.js";
24
- import { BinaryOperation } from "../parser/types.js";
25
- /** One tensor assign inside a fusible chain. */
26
- export interface FusedAssign {
27
- /** Destination tensor variable name. */
28
- destName: string;
29
- /** RHS expression tree (all tensor ops are element-wise). */
30
- expr: JitExpr;
31
- }
32
- /** A trailing reduction absorbed into the fused loop. */
33
- export interface FusedReduction {
34
- /** Scalar accumulator variable name (e.g. `chain_acc`). */
35
- accName: string;
36
- /** Reduction builtin name (e.g. `sum`). */
37
- reduceName: string;
38
- /** The tensor variable being reduced (last chain dest). */
39
- tensorName: string;
40
- /**
41
- * When true, the scalar statement is `acc = acc OP reduce(tensor)`,
42
- * and `accOp` says which binary op combines the old accumulator with
43
- * the reduction result. When false, it's a plain `acc = reduce(tensor)`.
44
- */
45
- hasAccumulate: boolean;
46
- accOp?: BinaryOperation;
47
- }
48
- /** Describes one fusible chain found in a statement list. */
49
- export interface FusibleChain {
50
- /** Index of the first statement in the chain (within the parent list). */
51
- startIdx: number;
52
- /** Number of statements consumed (tensor assigns + optional reduction). */
53
- length: number;
54
- /** The tensor assigns to fuse. */
55
- assigns: FusedAssign[];
56
- /** Optional trailing reduction. */
57
- reduction?: FusedReduction;
58
- }
59
- /**
60
- * Scan a statement list and return all fusible chains.
61
- *
62
- * `paramTensors` is the set of tensor parameter names (input data that
63
- * will be read via `data[i]` in the fused loop).
64
- * `allTensorVars` is the full set of tensor-typed variables (params +
65
- * locals + outputs).
66
- * `allowedUnaryOps` optionally restricts which tensor unary Call names
67
- * are fusible. Defaults to `FUSIBLE_TENSOR_UNARY_OPS` (full set).
68
- * The JS backend passes a restricted set that excludes transcendentals
69
- * (V8 can't vectorize them, so fusing them is slower than per-op calls).
70
- */
71
- export declare function findFusibleChains(stmts: JitStmt[], paramTensors: ReadonlySet<string>, allTensorVars: ReadonlySet<string>, allowedUnaryOps?: ReadonlySet<string>): FusibleChain[];
@@ -1,25 +0,0 @@
1
- /**
2
- * Shared fusible-operation name sets for JIT fusion analysis.
3
- *
4
- * Both the C-JIT and JS-JIT fusion paths use these to determine which
5
- * tensor Call nodes are fusible element-wise unary ops or absorbable
6
- * trailing reductions. The numeric op codes live in their respective
7
- * backend files (feasibility.ts for C, jitHelpersTensor.ts for JS).
8
- */
9
- /** Tensor unary builtins fusible into per-element loops. */
10
- export declare const FUSIBLE_TENSOR_UNARY_OPS: ReadonlySet<string>;
11
- /**
12
- * JS-JIT-safe subset: excludes transcendentals (exp, sin, cos, tan, etc.)
13
- * which V8 can't SIMD-vectorize. Fusing these into a scalar per-element
14
- * loop is slower than calling libnumbl_ops per-op (which uses -fopenmp-simd).
15
- * The C-JIT uses the full set because GCC/Clang vectorize via #pragma omp simd.
16
- */
17
- export declare const FUSIBLE_TENSOR_UNARY_OPS_JS: ReadonlySet<string>;
18
- /**
19
- * Two-argument tensor element-wise builtins fusible into per-element loops.
20
- * These are parsed as Call nodes (not Binary nodes) and need separate
21
- * recognition in isPureElementwise / emitScalarExpr.
22
- */
23
- export declare const FUSIBLE_TENSOR_BINARY_OPS: ReadonlySet<string>;
24
- /** Tensor reduction builtins absorbable as trailing reductions. */
25
- export declare const FUSIBLE_TENSOR_REDUCTION_OPS: ReadonlySet<string>;
@@ -1,7 +0,0 @@
1
- /**
2
- * JIT compilation entry point for interpreter function calls.
3
- */
4
- import type { Interpreter } from "../interpreter/interpreter.js";
5
- import type { FunctionDef } from "../interpreter/types.js";
6
- export declare const JIT_SKIP: unique symbol;
7
- export declare function tryJitCall(interp: Interpreter, fn: FunctionDef, args: unknown[], nargout: number): unknown | typeof JIT_SKIP;
@@ -1,25 +0,0 @@
1
- /**
2
- * JIT compilation for inline for/while loops.
3
- *
4
- * When the interpreter encounters a for or while loop, these functions
5
- * attempt to JIT-compile the loop as a synthetic function: inputs are
6
- * variables from the enclosing scope, outputs are variables assigned
7
- * inside the loop body. On success the compiled code runs and output
8
- * values are written back to the interpreter environment.
9
- */
10
- import type { Interpreter } from "../interpreter/interpreter.js";
11
- import type { Stmt } from "../parser/types.js";
12
- /**
13
- * Attempt to JIT-compile and execute a for-loop statement.
14
- * Returns true if JIT succeeded, false to fall back to interpretation.
15
- */
16
- export declare function tryJitFor(interp: Interpreter, stmt: Stmt & {
17
- type: "For";
18
- }): boolean;
19
- /**
20
- * Attempt to JIT-compile and execute a while-loop statement.
21
- * Returns true if JIT succeeded, false to fall back to interpretation.
22
- */
23
- export declare function tryJitWhile(interp: Interpreter, stmt: Stmt & {
24
- type: "While";
25
- }): boolean;
@@ -1,22 +0,0 @@
1
- /**
2
- * JIT compilation for the top-level script body (the main workspace).
3
- *
4
- * Wraps the list of non-function, non-classdef statements of a script as
5
- * a synthetic `FunctionDef` whose parameters are the live-in env vars
6
- * and whose outputs are every variable assigned in the script. On
7
- * success the compiled code runs once and all output values are written
8
- * back to the interpreter's workspace env.
9
- *
10
- * Mirrors `tryJitLoop` in jitLoop.ts — same lowering, same JS/C backend
11
- * pipeline, same progressive type widening. The differences:
12
- * - the synthetic body is the list of stmts directly, not a single For/While
13
- * - every assigned variable is live-out (the whole workspace is live)
14
- * - cache key is per-Interpreter (a single script AST per interp run)
15
- */
16
- import type { Interpreter } from "../interpreter/interpreter.js";
17
- import type { Stmt } from "../parser/types.js";
18
- /**
19
- * Attempt to JIT-compile and execute the top-level script body.
20
- * Returns true if JIT succeeded, false to fall back to interpretation.
21
- */
22
- export declare function tryJitTopLevel(interp: Interpreter, stmts: Stmt[]): boolean;
@@ -1,33 +0,0 @@
1
- /**
2
- * Tensor indexing helpers for JIT-compiled code.
3
- *
4
- * Three tiers of helpers, from most general to most specialized:
5
- * 1. Generic (idx1, idx2, idxN) — handle any base type, real or complex
6
- * 2. Real-tensor fast path (idx1r, idx2r, idx3r) — skip type/imag checks
7
- * 3. Hoisted-base (idx*r_h, set*r_h) — take pre-extracted data/len/shape
8
- *
9
- * All helpers use 1-based MATLAB indexing and include per-dimension bounds
10
- * checks to ensure consistency with the interpreter.
11
- */
12
- import { type FloatXArrayType, type RuntimeTensor } from "../../runtime/types.js";
13
- export declare class JitBailToInterpreter extends Error {
14
- readonly reason: string;
15
- constructor(reason: string);
16
- }
17
- export declare function bce(): never;
18
- export declare function idx1(base: unknown, i: number): unknown;
19
- export declare function idx2(base: unknown, ri: number, ci: number): unknown;
20
- export declare function idxN(base: unknown, indices: number[]): unknown;
21
- export declare function idx1r(base: RuntimeTensor, i: number): number;
22
- export declare function idx2r(base: RuntimeTensor, ri: number, ci: number): number;
23
- export declare function idx3r(base: RuntimeTensor, i1: number, i2: number, i3: number): number;
24
- export declare function idx1r_h(data: FloatXArrayType, len: number, i: number): number;
25
- export declare function idx2r_h(data: FloatXArrayType, len: number, rows: number, ri: number, ci: number): number;
26
- export declare function idx3r_h(data: FloatXArrayType, len: number, d0: number, d1: number, i1: number, i2: number, i3: number): number;
27
- export declare function set1r_h(data: FloatXArrayType, len: number, i: number, v: number): void;
28
- export declare function set2r_h(data: FloatXArrayType, len: number, rows: number, ri: number, ci: number, v: number): void;
29
- export declare function set3r_h(data: FloatXArrayType, len: number, d0: number, d1: number, i1: number, i2: number, i3: number, v: number): void;
30
- export declare function setRange1r_h(dstData: FloatXArrayType, dstLen: number, dstStart: number, dstEnd: number, srcData: FloatXArrayType, srcLen: number, srcStart: number, srcEnd: number): void;
31
- export declare function subarrayCopy1r(srcData: FloatXArrayType, srcLen: number, start: number, end: number): RuntimeTensor;
32
- export declare function subarrayCopy1rRow(srcData: FloatXArrayType, srcLen: number, start: number, end: number): RuntimeTensor;
33
- export declare function setCol2r_h(dstData: FloatXArrayType, dstRows: number, dstLen: number, col: number, srcData: FloatXArrayType, srcLen: number): void;
@@ -1,17 +0,0 @@
1
- /**
2
- * Fused per-element loop emission for the JS-JIT.
3
- *
4
- * Given a FusibleChain (from fusion.ts), emits a single block-scoped
5
- * JavaScript `for` loop that evaluates all the chain's tensor assigns
6
- * as inline scalar expressions per element — no $h.tAdd / $h.tMul
7
- * helper calls, no intermediate tensor allocations.
8
- *
9
- * Tensor var references become either:
10
- * - `__<name>_data[__i]` for input params / pre-existing tensors
11
- * - `__f_<name>` for chain-produced intermediates (scalar local)
12
- *
13
- * The optional trailing reduction is absorbed as an inline accumulator
14
- * inside the same loop.
15
- */
16
- import type { FusibleChain } from "../fusion.js";
17
- export declare function emitJsFusedChain(lines: string[], indent: string, chain: FusibleChain, allTensorVars: ReadonlySet<string>, paramTensors: ReadonlySet<string>, outputTensorNames: ReadonlySet<string>, _localTensorNames: ReadonlySet<string>, mangle: (n: string) => string, experimental?: string): void;
@@ -1,23 +0,0 @@
1
- /**
2
- * Allocate an UNINITIALIZED typed array — skips the zero-fill that
3
- * `new Float64Array(n)` / `new FloatXArray(n)` perform by default.
4
- *
5
- * On Node, `Buffer.allocUnsafe` returns un-zeroed memory; wrapping it
6
- * in a TypedArray view costs ~10× less than the zero-fill for a 16 MB
7
- * buffer (~45 µs vs ~470 µs at N=2M doubles).
8
- *
9
- * SAFETY CONTRACT (very important):
10
- * The caller MUST write every element before reading it. Any element
11
- * that is read before being written will contain arbitrary stale bytes
12
- * from recently-freed memory. If you cannot guarantee full coverage,
13
- * use `new Float64Array(n)` / `new FloatXArray(n)` instead.
14
- *
15
- * In non-Node environments (browser, Deno without node-compat, …) where
16
- * `Buffer` is unavailable, we fall back to the zero-filling constructor
17
- * — still correct, just slower.
18
- */
19
- import { FloatXArray } from "./types.js";
20
- type FloatXInstance = InstanceType<typeof FloatXArray>;
21
- export declare function uninitFloat64(n: number): Float64Array<ArrayBuffer>;
22
- export declare function uninitFloatX(n: number): FloatXInstance;
23
- export {};