@fraczak/k 6.10.2 → 6.10.4
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.
- package/CHANGELOG.md +73 -0
- package/DOCS/BIG_PICTURE.md +174 -100
- package/DOCS/CODECS.md +74 -29
- package/DOCS/CODEC_ARCHITECTURE.md +87 -31
- package/DOCS/CONVERGENCE.md +42 -11
- package/DOCS/DICTIONARY.md +69 -2
- package/DOCS/FILE_FORMATS.md +420 -0
- package/DOCS/KIR_V1.md +53 -42
- package/DOCS/KVM_EXECUTION_MODEL.md +189 -147
- package/DOCS/OBJECT_FILE_AND_PATTERN.md +35 -17
- package/DOCS/PATTERNS.md +10 -6
- package/DOCS/REPL.md +100 -60
- package/DOCS/TEXTUAL_VALUES.md +24 -19
- package/DOCS/TYPE_DERIVATION.md +68 -22
- package/Examples/karatsuba-mult.k +215 -0
- package/README.md +92 -58
- package/backends/arm64/scripts/run-tests.mjs +16 -0
- package/backends/llvm/bin/k-llvm-build.mjs +40 -14
- package/backends/llvm/bin/k-llvm-compile.mjs +29 -12
- package/backends/llvm/runtime/krt.c +10 -10
- package/backends/llvm/runtime/krt.h +6 -1
- package/backends/llvm/scripts/run-tests.mjs +16 -0
- package/backends/llvm/src/cli.mjs +1 -1
- package/backends/llvm/src/executable.mjs +36 -0
- package/backends/llvm/src/kvm2llvm.mjs +10 -4
- package/backends/llvm/tests/integration.sh +11 -0
- package/backends/llvm/tests/test-llvm.mjs +15 -1
- package/backends/wasm/scripts/run-tests.mjs +16 -0
- package/browser/vfs-data.mjs +1 -1
- package/codecs/README.md +78 -67
- package/core.k +5 -5
- package/objects/README.md +57 -37
- package/package.json +2 -1
- package/scripts/benchmark-idempotency.mjs +27 -0
- package/scripts/benchmark.mjs +51 -0
- package/scripts/build-repl-html.mjs +17 -0
- package/scripts/generate-dependency-graph.mjs +25 -1
- package/scripts/perf-ieee.mjs +75 -0
- package/scripts/perf-int.mjs +67 -0
- package/scripts/perf-multiplication.mjs +644 -0
- package/scripts/perf-poly.mjs +67 -0
- package/scripts/render-benchmark.mjs +25 -0
- package/scripts/run-tests.mjs +19 -0
- package/tests/README.md +28 -17
- package/tests/test-karatsuba.mjs +133 -0
package/scripts/perf-ieee.mjs
CHANGED
|
@@ -52,6 +52,81 @@ import {
|
|
|
52
52
|
import { compileWasmArtifactFromObject } from "../backends/wasm/src/wasm.mjs";
|
|
53
53
|
import { compileARM64ArtifactFromObject } from "../backends/arm64/src/arm64.mjs";
|
|
54
54
|
|
|
55
|
+
function printHelp() {
|
|
56
|
+
console.log(`Usage: node scripts/perf-ieee.mjs [options]
|
|
57
|
+
|
|
58
|
+
IEEE 754 Floating-Point Arithmetic Benchmark Harness.
|
|
59
|
+
Benchmarks add, sub, mul, and div on Examples/ieee.k across
|
|
60
|
+
Native JS, kVM interpreter, LLVM, Wasm, and ARM64 backends.
|
|
61
|
+
|
|
62
|
+
Options:
|
|
63
|
+
--opt=<levels>, --opts=<levels>
|
|
64
|
+
Comma-separated Clang optimization levels for LLVM (e.g. -O1,-O2).
|
|
65
|
+
--O0, --O1, --O2, --O3
|
|
66
|
+
Direct Clang optimization level flags for LLVM.
|
|
67
|
+
--full
|
|
68
|
+
Run full LLVM optimization sweep (-O0, -O1, -O2).
|
|
69
|
+
--wasm-in-process
|
|
70
|
+
Run WebAssembly in-process instead of persistent subprocess runner.
|
|
71
|
+
-h, --help
|
|
72
|
+
Show this help message and exit.
|
|
73
|
+
|
|
74
|
+
Environment Variables:
|
|
75
|
+
BACKENDS
|
|
76
|
+
Target backend to run: 'llvm', 'wasm', or 'arm64'.
|
|
77
|
+
LLVM_ONLY
|
|
78
|
+
Run only LLVM backend ('1' to enable).
|
|
79
|
+
WASM_ONLY
|
|
80
|
+
Run only WebAssembly backend ('1' to enable).
|
|
81
|
+
ARM64_ONLY
|
|
82
|
+
Run only ARM64 backend ('1' to enable).
|
|
83
|
+
BACKENDS_ONLY
|
|
84
|
+
Skip JS and kVM interpreter baselines ('1' to enable).
|
|
85
|
+
VALUES
|
|
86
|
+
Comma-separated float values to benchmark
|
|
87
|
+
(default: 0.5,-4,0,Infinity,-Infinity,NaN).
|
|
88
|
+
ITERATIONS
|
|
89
|
+
Measured iterations per benchmark (default: 3).
|
|
90
|
+
ARM64_WARMUP_ITERATIONS
|
|
91
|
+
Warmup iterations for ARM64 backend (default: 1).
|
|
92
|
+
ARM64_OPT
|
|
93
|
+
ARM64 backend optimization flags (default: -O2).
|
|
94
|
+
ARM64_SPAWN_PER_CALL
|
|
95
|
+
Spawn process per ARM64 call instead of persistent ('1' or '0').
|
|
96
|
+
ARM64_PIPELINE
|
|
97
|
+
Use persistent pipelined runner for ARM64 ('1' or '0').
|
|
98
|
+
LLVM_WARMUP_ITERATIONS
|
|
99
|
+
Warmup iterations for LLVM backend (default: 1).
|
|
100
|
+
LLVM_SPAWN_PER_CALL
|
|
101
|
+
Spawn process per LLVM call instead of persistent ('1' or '0').
|
|
102
|
+
LLVM_PIPELINE
|
|
103
|
+
Use persistent pipelined runner for LLVM ('1' or '0').
|
|
104
|
+
LLVM_OPTS
|
|
105
|
+
Comma-separated Clang optimization levels for LLVM.
|
|
106
|
+
K_LLVM_IEEE_RUNTIME_MODE
|
|
107
|
+
LLVM runtime compilation mode for IEEE (default: fast).
|
|
108
|
+
K_LLVM_IEEE_CLANG_OPT
|
|
109
|
+
Clang optimization levels for IEEE LLVM (default: -O1).
|
|
110
|
+
K_LLVM_CACHE_DIR
|
|
111
|
+
Directory to cache compiled LLVM executable binaries.
|
|
112
|
+
PERF_FULL
|
|
113
|
+
Set to '1' to test multiple LLVM optimization levels
|
|
114
|
+
(-O0, -O1, -O2).
|
|
115
|
+
WASM_WARMUP_ITERATIONS
|
|
116
|
+
Warmup iterations for WebAssembly backend (default: 10).
|
|
117
|
+
WASM_RESET
|
|
118
|
+
Reset WebAssembly memory between iterations (default: 1).
|
|
119
|
+
WASM_PIPE
|
|
120
|
+
Use persistent subprocess for Wasm (default: 1, '0': in-process).
|
|
121
|
+
WASM_IN_PROCESS
|
|
122
|
+
Run WebAssembly in-process ('1' to enable).`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (process.argv.includes("-h") || process.argv.includes("--help")) {
|
|
126
|
+
printHelp();
|
|
127
|
+
process.exit(0);
|
|
128
|
+
}
|
|
129
|
+
|
|
55
130
|
// Backend selection
|
|
56
131
|
const backendsEnv = process.env.BACKENDS?.toLowerCase();
|
|
57
132
|
const llvmOnly = process.env.LLVM_ONLY === "1" || backendsEnv === "llvm";
|
package/scripts/perf-int.mjs
CHANGED
|
@@ -56,6 +56,73 @@ import {
|
|
|
56
56
|
import { compileARM64ArtifactFromObject } from "../backends/arm64/src/arm64.mjs";
|
|
57
57
|
import { compileWasmArtifactFromObject } from "../backends/wasm/src/wasm.mjs";
|
|
58
58
|
|
|
59
|
+
function printHelp() {
|
|
60
|
+
console.log(`Usage: node scripts/perf-int.mjs [options]
|
|
61
|
+
|
|
62
|
+
Big Integer Arithmetic Performance Benchmark Harness.
|
|
63
|
+
Benchmarks plus, minus, times, and squaring scale on arithmetics.k
|
|
64
|
+
across Native JS, kVM interpreter, LLVM, Wasm, and ARM64 backends.
|
|
65
|
+
|
|
66
|
+
Options:
|
|
67
|
+
--wasm-in-process
|
|
68
|
+
Run WebAssembly in-process instead of persistent subprocess runner.
|
|
69
|
+
-h, --help
|
|
70
|
+
Show this help message and exit.
|
|
71
|
+
|
|
72
|
+
Environment Variables:
|
|
73
|
+
BACKENDS
|
|
74
|
+
Target backend to run: 'llvm', 'wasm', or 'arm64'.
|
|
75
|
+
LLVM_ONLY
|
|
76
|
+
Run only LLVM backend ('1' to enable).
|
|
77
|
+
WASM_ONLY
|
|
78
|
+
Run only WebAssembly backend ('1' to enable).
|
|
79
|
+
ARM64_ONLY
|
|
80
|
+
Run only ARM64 backend ('1' to enable).
|
|
81
|
+
BACKENDS_ONLY
|
|
82
|
+
Skip JS and kVM interpreter baselines ('1' to enable).
|
|
83
|
+
INPUTS
|
|
84
|
+
Comma-separated integer strings to benchmark.
|
|
85
|
+
ITERATIONS
|
|
86
|
+
Measured iterations per benchmark (default: 3).
|
|
87
|
+
ARM64_WARMUP_ITERATIONS
|
|
88
|
+
Warmup iterations for ARM64 backend (default: 1).
|
|
89
|
+
ARM64_OPT
|
|
90
|
+
ARM64 backend optimization flags (default: -O2).
|
|
91
|
+
ARM64_SPAWN_PER_CALL
|
|
92
|
+
Spawn process per ARM64 call instead of persistent ('1' or '0').
|
|
93
|
+
ARM64_PIPELINE
|
|
94
|
+
Use persistent pipelined runner for ARM64 ('1' or '0').
|
|
95
|
+
LLVM_WARMUP_ITERATIONS
|
|
96
|
+
Warmup iterations for LLVM backend (default: 1).
|
|
97
|
+
LLVM_SPAWN_PER_CALL
|
|
98
|
+
Spawn process per LLVM call instead of persistent ('1' or '0').
|
|
99
|
+
LLVM_PIPELINE
|
|
100
|
+
Use persistent pipelined runner for LLVM ('1' or '0').
|
|
101
|
+
K_LLVM_CACHE_DIR
|
|
102
|
+
Directory to cache compiled LLVM executable binaries.
|
|
103
|
+
WASM_WARMUP_ITERATIONS
|
|
104
|
+
Warmup iterations for WebAssembly backend (default: 3).
|
|
105
|
+
WASM_RESET
|
|
106
|
+
Reset WebAssembly memory between iterations (default: 1).
|
|
107
|
+
WASM_PIPE
|
|
108
|
+
Use persistent subprocess for Wasm (default: 1, '0': in-process).
|
|
109
|
+
WASM_IN_PROCESS
|
|
110
|
+
Run WebAssembly in-process ('1' to enable).
|
|
111
|
+
SQUARING_INPUT
|
|
112
|
+
Initial integer for squaring benchmark (default: 987654321).
|
|
113
|
+
SQUARING_STEPS
|
|
114
|
+
Number of squaring steps (default: 10).
|
|
115
|
+
SQUARING_STEP_TIMEOUT_MS
|
|
116
|
+
Timeout per squaring step in milliseconds (default: 60000).
|
|
117
|
+
K_ARENA_CAPACITY_MB
|
|
118
|
+
Memory arena capacity in MB (default: 4096).`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (process.argv.includes("-h") || process.argv.includes("--help")) {
|
|
122
|
+
printHelp();
|
|
123
|
+
process.exit(0);
|
|
124
|
+
}
|
|
125
|
+
|
|
59
126
|
// Backend selection
|
|
60
127
|
const backendsEnv = process.env.BACKENDS?.toLowerCase();
|
|
61
128
|
const llvmOnly = process.env.LLVM_ONLY === "1" || backendsEnv === "llvm";
|