@fraczak/k 8.9.0 → 9.1.0

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 (90) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/DOCS/ARCHITECTURE.md +5 -4
  3. package/DOCS/DICTIONARY.md +2 -2
  4. package/DOCS/FILE_FORMATS.md +11 -9
  5. package/DOCS/KIR_V1.md +5 -1
  6. package/DOCS/KTVM_SPEC.md +907 -0
  7. package/DOCS/KVM_EXECUTION_MODEL.md +3 -2
  8. package/DOCS/KVM_VS_KTVM_COMPARATIVE_STUDY.md +127 -0
  9. package/DOCS/PROFILING_AND_TRACING.md +13 -4
  10. package/DOCS/README.md +3 -2
  11. package/DOCS/REPL.md +16 -12
  12. package/README.md +138 -2
  13. package/backend-api.mjs +31 -16
  14. package/backends/llvm/README.md +4 -5
  15. package/backends/llvm/bin/k-llvm-build.mjs +7 -19
  16. package/backends/llvm/bin/k-llvm-compile.mjs +6 -18
  17. package/backends/llvm/bin/k-llvm.mjs +11 -33
  18. package/backends/llvm/src/cli.mjs +2 -12
  19. package/backends/llvm/src/executable.mjs +7 -95
  20. package/backends/llvm/src/kvm2llvm.mjs +1 -7
  21. package/backends/llvm/src/llvm.mjs +4 -113
  22. package/backends/llvm/tests/k-llvm-run.mjs +1 -6
  23. package/backends/llvm/tests/perf-support.mjs +3 -5
  24. package/backends/llvm/tests/test-llvm.mjs +2 -16
  25. package/backends/wasm/README.md +7 -3
  26. package/backends/wasm/bin/k-wasm-compile.mjs +4 -7
  27. package/backends/wasm/bin/k-wasm.mjs +4 -6
  28. package/backends/wasm/src/cli.mjs +8 -24
  29. package/backends/wasm/src/wasm.mjs +60 -57
  30. package/backends/wasm/tests/test-wasm.mjs +41 -2
  31. package/browser/repl-browser.mjs +9 -8
  32. package/browser/shims/buffer.mjs +31 -2
  33. package/browser/shims/child_process.mjs +26 -0
  34. package/browser/shims/fs.mjs +3 -1
  35. package/codecs/runtime/prefix-codec.mjs +67 -1
  36. package/conformance/run.mjs +17 -2
  37. package/harness/adapters/ktvm-llvm.mjs +118 -0
  38. package/harness/adapters/ktvm-wasm.mjs +104 -0
  39. package/harness/adapters/ktvm.mjs +133 -0
  40. package/harness/registry.mjs +9 -0
  41. package/ktvm/ast.mjs +218 -0
  42. package/ktvm/bit-deque.mjs +497 -0
  43. package/ktvm/fixtures/integer-streaming.k +477 -0
  44. package/ktvm/index.mjs +130 -0
  45. package/ktvm/llvm/index.mjs +202 -0
  46. package/ktvm/llvm/lower-c.mjs +1258 -0
  47. package/ktvm/llvm/runtime.h +3542 -0
  48. package/ktvm/llvm/test-llvm.mjs +476 -0
  49. package/ktvm/lower-kir.mjs +2221 -0
  50. package/ktvm/optimize/fuse-kernel.mjs +2111 -0
  51. package/ktvm/optimize/index.mjs +116 -0
  52. package/ktvm/optimize/mwtr.mjs +283 -0
  53. package/ktvm/optimize/simplify-procs.mjs +5250 -0
  54. package/ktvm/optimize/synthesize-tables.mjs +1105 -0
  55. package/ktvm/parser.mjs +1101 -0
  56. package/ktvm/printer.mjs +281 -0
  57. package/ktvm/schema.mjs +1134 -0
  58. package/ktvm/specialize.mjs +538 -0
  59. package/ktvm/test-conformance.mjs +597 -0
  60. package/ktvm/test-ktvm.mjs +1805 -0
  61. package/ktvm/test-optimize.mjs +598 -0
  62. package/ktvm/validator.mjs +1280 -0
  63. package/ktvm/vm.mjs +2225 -0
  64. package/ktvm/wasm/index.mjs +331 -0
  65. package/ktvm/wasm/lower-wasm.mjs +1272 -0
  66. package/ktvm/wasm/runtime.wat +4404 -0
  67. package/ktvm/wasm/test-wasm.mjs +429 -0
  68. package/ktvm/wire.mjs +679 -0
  69. package/package.json +1 -9
  70. package/paper/Makefile +8 -5
  71. package/paper/k-transducer-compiler.pdf +0 -0
  72. package/paper/k-transducer-compiler.tex +658 -0
  73. package/paper/replay-diagnostic.mjs +63 -0
  74. package/repl.mjs +101 -20
  75. package/scripts/build-repl-html.mjs +40 -18
  76. package/scripts/perf-bigint-compare.mjs +12 -16
  77. package/scripts/perf-ieee.mjs +14 -232
  78. package/scripts/perf-int.mjs +16 -274
  79. package/scripts/perf-multiplication.mjs +116 -121
  80. package/scripts/perf-poly.mjs +9 -263
  81. package/scripts/run-tests.mjs +5 -2
  82. package/scripts/test-package.mjs +15 -3
  83. package/tests/README.md +3 -3
  84. package/tests/test-repl-html.mjs +72 -15
  85. package/tests/test-repl.mjs +24 -17
  86. package/DOCS/POLYMORPHIC_IR.md +0 -86
  87. package/access-table.mjs +0 -343
  88. package/pkir.mjs +0 -772
  89. package/tests/test-access-table.mjs +0 -213
  90. package/tests/test-pkir.mjs +0 -530
@@ -58,27 +58,23 @@ function printHelp() {
58
58
 
59
59
  Big Integer Arithmetic Performance Benchmark Harness.
60
60
  Benchmarks plus, minus, times, and squaring scale on lib/integer.k
61
- across Native JS, kVM interpreter, LLVM, Wasm, and PKIR backends.
61
+ across Native JS, kVM interpreter, LLVM, and Wasm backends.
62
62
 
63
63
  Options:
64
64
  --wasm-in-process
65
65
  Run WebAssembly in-process instead of persistent subprocess runner.
66
66
  --squaring-llvm-only
67
67
  Run squaring benchmark on LLVM only.
68
- --pkir-only
69
- Run only PKIR backend.
70
68
  -h, --help
71
69
  Show this help message and exit.
72
70
 
73
71
  Environment Variables:
74
72
  BACKENDS
75
- Target backend to run: 'llvm', 'wasm', or 'pkir'.
73
+ Target backend to run: 'llvm' or 'wasm'.
76
74
  LLVM_ONLY
77
75
  Run only LLVM backend ('1' to enable).
78
76
  WASM_ONLY
79
77
  Run only WebAssembly backend ('1' to enable).
80
- PKIR_ONLY
81
- Run only PKIR backend ('1' to enable).
82
78
  BACKENDS_ONLY
83
79
  Skip JS and kVM interpreter baselines ('1' to enable).
84
80
  SQUARING_LLVM_ONLY
@@ -123,23 +119,11 @@ const backendsEnv = process.env.BACKENDS?.toLowerCase();
123
119
  const backendsList = backendsEnv
124
120
  ? backendsEnv.split(",").map(s => s.trim())
125
121
  : null;
126
- const llvmPkirOnly = process.env.LLVM_PKIR_ONLY === "1"
127
- || (backendsList && backendsList.length === 1 &&
128
- backendsList[0] === "llvm-pkir")
129
- || process.argv.includes("--llvm-pkir-only");
130
- const pkirOnly = !llvmPkirOnly && (
131
- process.env.PKIR_ONLY === "1"
132
- || (backendsList && backendsList.length === 1 &&
133
- backendsList[0] === "pkir")
134
- || process.argv.includes("--pkir-only")
135
- );
136
- const llvmOnly = !pkirOnly && !llvmPkirOnly && (
137
- process.env.LLVM_ONLY === "1"
122
+ const llvmOnly = process.env.LLVM_ONLY === "1"
138
123
  || (backendsList && backendsList.length === 1 &&
139
124
  backendsList[0] === "llvm")
140
- || process.argv.includes("--llvm-only")
141
- );
142
- const wasmOnly = !pkirOnly && !llvmPkirOnly && !llvmOnly && (
125
+ || process.argv.includes("--llvm-only");
126
+ const wasmOnly = !llvmOnly && (
143
127
  process.env.WASM_ONLY === "1"
144
128
  || (backendsList && backendsList.length === 1 &&
145
129
  backendsList[0] === "wasm")
@@ -147,30 +131,21 @@ const wasmOnly = !pkirOnly && !llvmPkirOnly && !llvmOnly && (
147
131
  );
148
132
  const runLLVM = backendsList
149
133
  ? backendsList.includes("llvm")
150
- : !wasmOnly && !pkirOnly && !llvmPkirOnly;
151
- const runLLVMPKIR = backendsList
152
- ? backendsList.includes("llvm-pkir")
153
- : !wasmOnly && !pkirOnly && !llvmOnly;
134
+ : !wasmOnly;
154
135
  const runWasm = backendsList
155
136
  ? backendsList.includes("wasm")
156
- : !llvmOnly && !pkirOnly && !llvmPkirOnly;
157
- const runPKIR = backendsList
158
- ? backendsList.includes("pkir")
159
- : !llvmOnly && !wasmOnly && !llvmPkirOnly;
137
+ : !llvmOnly;
160
138
  const runBaselines = !process.env.BACKENDS_ONLY
161
139
  && (backendsList == null || backendsList.includes("kvm") ||
162
140
  backendsList.includes("js"))
163
- && !llvmOnly && !wasmOnly && !pkirOnly && !llvmPkirOnly;
164
- const squaringLlvmOnly = llvmOnly || llvmPkirOnly
141
+ && !llvmOnly && !wasmOnly;
142
+ const squaringLlvmOnly = llvmOnly
165
143
  || process.env.SQUARING_LLVM_ONLY === "1"
166
144
  || process.argv.includes("--squaring-llvm-only");
167
145
 
168
146
  function llvmLaneNameStr() {
169
147
  return llvmLaneName();
170
148
  }
171
- function llvmPkirLaneNameStr() {
172
- return llvmLaneName().replace("LLVM", "LLVM-PKIR");
173
- }
174
149
 
175
150
  const ops = ["plus", "minus", "times"];
176
151
  const benchNames = Object.fromEntries(ops.map(op => [op, `bench_${op}`]));
@@ -198,9 +173,6 @@ function wasmLaneName() {
198
173
  const mode = wasmPipe ? "persistent" : "in-process";
199
174
  return `WebAssembly (${mode})`;
200
175
  }
201
- function pkirLaneName() {
202
- return "PKIR (Wasm persistent)";
203
- }
204
176
 
205
177
  console.log("==> Initializing state and loading @fraczak/k/lib/integer.k");
206
178
  const state = createState();
@@ -263,36 +235,13 @@ if (runLLVM) {
263
235
  inputPattern: tc.inputPattern,
264
236
  cacheDir,
265
237
  sourceLabel:
266
- `@fraczak/k/lib/integer.k#${relation.relationName}`,
267
- usePKIR: false
238
+ `@fraczak/k/lib/integer.k#${relation.relationName}`
268
239
  });
269
240
  }
270
241
  codes.load(state.codes);
271
242
  printCompileFailures(testSuite);
272
243
  }
273
244
 
274
- // Setup LLVM-PKIR
275
- if (runLLVMPKIR) {
276
- console.log("==> Compiling LLVM-PKIR executables");
277
- for (const tc of testSuite) {
278
- const relation = relations[tc.op];
279
- tc.llvmPKIR = tryCompileCase({
280
- object: relation.object,
281
- relationName: relation.relationName,
282
- relHash: relation.relHash,
283
- inputPattern: tc.inputPattern,
284
- cacheDir,
285
- sourceLabel:
286
- `@fraczak/k/lib/integer.k#${relation.relationName}`,
287
- usePKIR: true
288
- });
289
- }
290
- codes.load(state.codes);
291
- printCompileFailures(
292
- testSuite.map(tc => ({ ...tc, llvm: tc.llvmPKIR }))
293
- );
294
- }
295
-
296
245
  // Setup Wasm
297
246
  let wasmExports = null;
298
247
  const wasmExes = new Map();
@@ -305,7 +254,7 @@ if (runWasm) {
305
254
  const wasmPath = path.join(cacheDir, `perf_int_wasm_${op}.wasm`);
306
255
  const exePath = path.join(cacheDir, `perf_int_wasm_${op}.exe`);
307
256
  const wasmBuf = await compileWasmArtifactFromObject(relation.object, {
308
- entry: "__main__"
257
+ entry: relation.relHash
309
258
  });
310
259
  fs.writeFileSync(wasmPath, wasmBuf);
311
260
  const runBin = fileURLToPath(import.meta.resolve("../backends/wasm/bin/k-wasm-run.mjs"));
@@ -346,35 +295,6 @@ if (runWasm) {
346
295
  }
347
296
  }
348
297
 
349
- // Setup PKIR (persistent runner)
350
- const pkirExes = new Map();
351
- if (runPKIR) {
352
- console.log("==> Compiling PKIR executables (persistent runner)...");
353
- for (const op of ops) {
354
- const relation = relations[op];
355
- try {
356
- const wasmPath = path.join(cacheDir, `perf_int_pkir_${op}.wasm`);
357
- const exePath = path.join(cacheDir, `perf_int_pkir_${op}.exe`);
358
- const wasmBuf = await compileWasmArtifactFromObject(relation.object, {
359
- entry: "__main__",
360
- usePKIR: true
361
- });
362
- fs.writeFileSync(wasmPath, wasmBuf);
363
- const runBin = fileURLToPath(import.meta.resolve("../backends/wasm/bin/k-wasm-run.mjs"));
364
- fs.writeFileSync(exePath, `#!/bin/sh\nexec node "${runBin}" "${wasmPath}" "$@"\n`, { mode: 0o755 });
365
- pkirExes.set(op, { status: "ok", exePath, wasmPath });
366
- } catch (error) {
367
- pkirExes.set(op, {
368
- status: "failed",
369
- error: error.stack || error.message || String(error)
370
- });
371
- }
372
- }
373
- for (const tc of testSuite) {
374
- tc.pkir = pkirExes.get(tc.op);
375
- }
376
- }
377
-
378
298
  function createWasmRunner(testSuite) {
379
299
  const wasmCases = testSuite.filter(tc => tc.wasm?.status === "ok");
380
300
  const servers = new Map();
@@ -403,34 +323,6 @@ function createWasmRunner(testSuite) {
403
323
  };
404
324
  }
405
325
 
406
- function createPKIRRunner(testSuite) {
407
- const pkirCases = testSuite.filter(tc => tc.pkir?.status === "ok");
408
- const servers = new Map();
409
- function serverFor(exePath) {
410
- let server = servers.get(exePath);
411
- if (server == null) {
412
- server = new PersistentExecutable(exePath);
413
- servers.set(exePath, server);
414
- }
415
- return server;
416
- }
417
-
418
- return {
419
- async run(iterations) {
420
- if (pkirCases.length === 0) return null;
421
- return runTimedIterationsAsync(iterations, async () => {
422
- for (const tc of pkirCases) {
423
- await serverFor(tc.pkir.exePath).request(tc.inputWire);
424
- }
425
- });
426
- },
427
- serverFor,
428
- close() {
429
- for (const server of servers.values()) server.close();
430
- }
431
- };
432
- }
433
-
434
326
  function printBenchmarkDescription() {
435
327
  const lanes = [];
436
328
  if (runBaselines) {
@@ -439,9 +331,7 @@ function printBenchmarkDescription() {
439
331
  lanes.push("kVM Interpreter (Env-Free)");
440
332
  }
441
333
  if (runLLVM) lanes.push(llvmLaneNameStr());
442
- if (runLLVMPKIR) lanes.push(llvmPkirLaneNameStr());
443
334
  if (runWasm) lanes.push(wasmLaneName());
444
- if (runPKIR) lanes.push(pkirLaneName());
445
335
 
446
336
  console.log("==> Benchmark description");
447
337
  console.log(" source: @fraczak/k/lib/integer.k");
@@ -453,18 +343,11 @@ function printBenchmarkDescription() {
453
343
  console.log(` llvm-ready cases: ${testSuite.filter(tc => tc.llvm?.status === "ok").length}`);
454
344
  console.log(` llvm warmup iterations: ${llvmWarmupIterations}`);
455
345
  }
456
- if (runLLVMPKIR) {
457
- console.log(` llvm-pkir ready cases: ${testSuite.filter(tc => tc.llvmPKIR?.status === "ok").length}`);
458
- console.log(` llvm-pkir warmup iterations: ${llvmWarmupIterations}`);
459
- }
460
346
  if (runWasm) {
461
347
  console.log(` wasm runner mode: ${wasmPipe ? "persistent pipe" : "in-process"}`);
462
348
  console.log(` wasm warmup iterations: ${wasmWarmupIterations}`);
463
349
  if (!wasmPipe) console.log(` wasm arena reset: ${wasmReset ? "yes" : "no"}`);
464
350
  }
465
- if (runPKIR) {
466
- console.log(` pkir warmup iterations: ${wasmWarmupIterations}`);
467
- }
468
351
  console.log(` iterations: ${iterations}`);
469
352
  console.log(` benchmark lanes: ${lanes.join("; ")}`);
470
353
  console.log(" conformance: all outputs are compared to native expected values");
@@ -499,22 +382,6 @@ if (runLLVM) {
499
382
  }
500
383
  }
501
384
 
502
- // 2b. LLVM-PKIR lane
503
- let llvmPkirResult = null;
504
- if (runLLVMPKIR) {
505
- const llvmPkirCases = testSuite.map(tc => ({ ...tc, llvm: tc.llvmPKIR }));
506
- const llvmPkirRunner = createLLVMRunner(llvmPkirCases);
507
- try {
508
- if (llvmWarmupIterations > 0) {
509
- console.log(`==> Warming LLVM-PKIR executables (${llvmWarmupIterations} iterations)...`);
510
- await llvmPkirRunner.run(llvmWarmupIterations);
511
- }
512
- llvmPkirResult = await llvmPkirRunner.run(iterations);
513
- } finally {
514
- llvmPkirRunner.close();
515
- }
516
- }
517
-
518
385
  // 3. Wasm lane
519
386
  let wasmResult = null;
520
387
  if (runWasm) {
@@ -559,25 +426,6 @@ if (runWasm) {
559
426
  }
560
427
  }
561
428
 
562
- // 4. PKIR lane
563
- let pkirResult = null;
564
- if (runPKIR) {
565
- const pkirCases = testSuite.filter(tc => tc.pkir?.status === "ok");
566
- if (pkirCases.length === testSuite.length) {
567
- const pkirRunner = createPKIRRunner(testSuite);
568
- try {
569
- if (wasmWarmupIterations > 0) {
570
- console.log(`==> Warming PKIR (${wasmWarmupIterations} iterations)...`);
571
- await pkirRunner.run(wasmWarmupIterations);
572
- }
573
- console.log(`==> Running PKIR (${iterations} iterations)...`);
574
- pkirResult = await pkirRunner.run(iterations);
575
- } finally {
576
- pkirRunner.close();
577
- }
578
- }
579
- }
580
-
581
429
  console.log("\n=================== INTEGER BENCHMARK RESULTS ===================");
582
430
  console.log(`Operation calls per iteration: ${testSuite.length}`);
583
431
  console.log(`Total requested operation calls: ${iterations * testSuite.length}`);
@@ -592,16 +440,9 @@ if (runLLVM) {
592
440
  const name = llvmLaneNameStr().padEnd(29);
593
441
  console.log(`${laneIndex++}. ${name} ${formatTiming(llvmResult)}`);
594
442
  }
595
- if (runLLVMPKIR) {
596
- const name = llvmPkirLaneNameStr().padEnd(29);
597
- console.log(`${laneIndex++}. ${name} ${formatTiming(llvmPkirResult)}`);
598
- }
599
443
  if (runWasm) {
600
444
  console.log(`${laneIndex++}. ${wasmLaneName().padEnd(29)} ${formatTiming(wasmResult)}`);
601
445
  }
602
- if (runPKIR) {
603
- console.log(`${laneIndex++}. ${pkirLaneName().padEnd(29)} ${formatTiming(pkirResult)}`);
604
- }
605
446
  console.log("=================================================================\n");
606
447
 
607
448
  // Conformance Validation
@@ -629,24 +470,6 @@ for (const tc of testSuite) {
629
470
  }
630
471
  }
631
472
 
632
- if (runLLVMPKIR) {
633
- if (tc.llvmPKIR.status !== "ok") {
634
- tc.llvmPkirConformance = "compile-failed";
635
- } else {
636
- try {
637
- const outputWire = await runExecutable(tc.llvmPKIR.exePath, tc.inputWire);
638
- const actual = decodeWire(outputWire).value;
639
- assert.deepEqual(toPlainObject(actual), toPlainObject(tc.expected));
640
- tc.llvmPkirConformance = "ok";
641
- } catch (error) {
642
- tc.llvmPkirConformance = "failed";
643
- tc.llvmPKIR.error = error.stack || error.message || String(error);
644
- console.log(`LLVM-PKIR conformance failure for ${tc.op}(${tc.label}):`);
645
- console.log(tc.llvmPKIR.error.split("\n").slice(0, 8).join("\n"));
646
- }
647
- }
648
- }
649
-
650
473
  if (runWasm) {
651
474
  if (wasmPipe) {
652
475
  if (tc.wasm?.status !== "ok") {
@@ -685,24 +508,6 @@ for (const tc of testSuite) {
685
508
  }
686
509
  }
687
510
 
688
- if (runPKIR) {
689
- if (tc.pkir?.status !== "ok") {
690
- tc.pkirConformance = "compile-failed";
691
- } else {
692
- try {
693
- const outputWire = await runExecutable(tc.pkir.exePath, tc.inputWire);
694
- const actual = decodeWire(outputWire).value;
695
- assert.deepEqual(toPlainObject(actual), toPlainObject(tc.expected));
696
- tc.pkirConformance = "ok";
697
- } catch (error) {
698
- tc.pkirConformance = "failed";
699
- tc.pkir.error = error.stack || error.message || String(error);
700
- console.log(`PKIR conformance failure for ${tc.op}(${tc.label}):`);
701
- console.log(tc.pkir.error.split("\n").slice(0, 8).join("\n"));
702
- }
703
- }
704
- }
705
-
706
511
  }
707
512
 
708
513
  const validationSummary = [];
@@ -711,24 +516,14 @@ if (runLLVM) {
711
516
  const llvmOk = testSuite.filter(tc => tc.llvmConformance === "ok").length;
712
517
  validationSummary.push(`LLVM ${llvmOk}/${testSuite.length}`);
713
518
  }
714
- if (runLLVMPKIR) {
715
- const pkirOk = testSuite.filter(tc => tc.llvmPkirConformance === "ok").length;
716
- validationSummary.push(`LLVM-PKIR ${pkirOk}/${testSuite.length}`);
717
- }
718
519
  if (runWasm) {
719
520
  const wasmOk = testSuite.filter(tc => tc.wasmConformance === "ok").length;
720
521
  validationSummary.push(`Wasm ${wasmOk}/${testSuite.length}`);
721
522
  }
722
- if (runPKIR) {
723
- const pkirOk = testSuite.filter(tc => tc.pkirConformance === "ok").length;
724
- validationSummary.push(`PKIR ${pkirOk}/${testSuite.length}`);
725
- }
726
523
 
727
524
  console.log(`Conformance validation: ${validationSummary.join(", ")} cases match expected values.`);
728
525
  if (runLLVM && shouldStrictFail(testSuite)) process.exitCode = 1;
729
- if (runLLVMPKIR && shouldStrictFail(testSuite.map(tc => ({ ...tc, llvm: tc.llvmPKIR })))) process.exitCode = 1;
730
526
  if (runWasm && testSuite.some(tc => tc.wasmConformance !== "ok")) process.exitCode = 1;
731
- if (runPKIR && testSuite.some(tc => tc.pkirConformance !== "ok")) process.exitCode = 1;
732
527
 
733
528
  // =======================================================================
734
529
  // Squaring Scale & Memory Profiling Benchmark
@@ -805,37 +600,19 @@ for (const algo of squaringAlgos) {
805
600
  relHash: algo.rel.relHash,
806
601
  inputPattern: sInputPattern,
807
602
  cacheDir,
808
- sourceLabel: algo.sourceLabel,
809
- usePKIR: false
603
+ sourceLabel: algo.sourceLabel
810
604
  });
811
605
  if (sLlvmCompiled.status === "ok") {
812
606
  algo.llvmServer = new PersistentExecutable(sLlvmCompiled.exePath);
813
607
  }
814
608
  }
815
609
 
816
- algo.llvmPkirServer = null;
817
- if (runLLVMPKIR) {
818
- const sLlvmPkirCompiled = tryCompileCase({
819
- object: algo.rel.object,
820
- relationName: algo.rel.relationName,
821
- relHash: algo.rel.relHash,
822
- inputPattern: sInputPattern,
823
- cacheDir,
824
- sourceLabel: algo.sourceLabel,
825
- usePKIR: true
826
- });
827
- if (sLlvmPkirCompiled.status === "ok") {
828
- algo.llvmPkirServer =
829
- new PersistentExecutable(sLlvmPkirCompiled.exePath);
830
- }
831
- }
832
-
833
610
  algo.wasmServer = null;
834
611
  if (runWasm && !squaringLlvmOnly) {
835
612
  try {
836
613
  const sWasmPath = path.join(cacheDir, `perf_int_wasm_${algo.id}.wasm`);
837
614
  const sWasmExe = path.join(cacheDir, `perf_int_wasm_${algo.id}.exe`);
838
- const wasmBuf = await compileWasmArtifactFromObject(algo.rel.object, { entry: "__main__" });
615
+ const wasmBuf = await compileWasmArtifactFromObject(algo.rel.object, { entry: algo.rel.relHash });
839
616
  fs.writeFileSync(sWasmPath, wasmBuf);
840
617
  const runBin = fileURLToPath(import.meta.resolve("../backends/wasm/bin/k-wasm-run.mjs"));
841
618
  fs.writeFileSync(sWasmExe, `#!/bin/sh\nexec node "${runBin}" "${sWasmPath}" "$@"\n`, { mode: 0o755 });
@@ -845,24 +622,6 @@ for (const algo of squaringAlgos) {
845
622
  }
846
623
  }
847
624
 
848
- algo.pkirServer = null;
849
- if (runPKIR && !squaringLlvmOnly) {
850
- try {
851
- const sPkirPath = path.join(cacheDir, `perf_int_pkir_${algo.id}.wasm`);
852
- const sPkirExe = path.join(cacheDir, `perf_int_pkir_${algo.id}.exe`);
853
- const wasmBuf = await compileWasmArtifactFromObject(algo.rel.object, {
854
- entry: "__main__",
855
- usePKIR: true
856
- });
857
- fs.writeFileSync(sPkirPath, wasmBuf);
858
- const runBin = fileURLToPath(import.meta.resolve("../backends/wasm/bin/k-wasm-run.mjs"));
859
- fs.writeFileSync(sPkirExe, `#!/bin/sh\nexec node "${runBin}" "${sPkirPath}" "$@"\n`, { mode: 0o755 });
860
- algo.pkirServer = new PersistentExecutable(sPkirExe);
861
- } catch (e) {
862
- console.log(`Failed to build PKIR executable for '${algo.id}':`, e.message);
863
- }
864
- }
865
-
866
625
  algo.results = {};
867
626
  }
868
627
 
@@ -880,20 +639,9 @@ if (runLLVM) {
880
639
  memLabel: "peak RSS"
881
640
  });
882
641
  }
883
- if (runLLVMPKIR) {
884
- squaringLanes.push({
885
- id: "llvm-pkir",
886
- name: llvmPkirLaneNameStr(),
887
- type: "persistent",
888
- memLabel: "peak RSS"
889
- });
890
- }
891
642
  if (runWasm && !squaringLlvmOnly) {
892
643
  squaringLanes.push({ id: "wasm", name: wasmLaneName(), type: "persistent", memLabel: "peak RSS" });
893
644
  }
894
- if (runPKIR && !squaringLlvmOnly) {
895
- squaringLanes.push({ id: "pkir", name: pkirLaneName(), type: "persistent", memLabel: "peak RSS" });
896
- }
897
645
 
898
646
  for (const algo of squaringAlgos) {
899
647
  for (const lane of squaringLanes) {
@@ -903,16 +651,12 @@ for (const algo of squaringAlgos) {
903
651
  const stepMetadata = [];
904
652
 
905
653
  try {
906
- // 1. Persistent child processes (Wasm, PKIR, LLVM)
654
+ // 1. Persistent child processes (Wasm, LLVM)
907
655
  for (const lane of squaringLanes.filter(l => l.type === "persistent")) {
908
656
  for (const algo of squaringAlgos) {
909
657
  const server = lane.id === "llvm"
910
658
  ? algo.llvmServer
911
- : lane.id === "llvm-pkir"
912
- ? algo.llvmPkirServer
913
- : lane.id === "pkir"
914
- ? algo.pkirServer
915
- : algo.wasmServer;
659
+ : algo.wasmServer;
916
660
  if (!server) continue;
917
661
  console.log(`==> Running ${lane.name} squaring [${algo.name}]...`);
918
662
  let curWire = sInitWire;
@@ -1013,9 +757,7 @@ try {
1013
757
  } finally {
1014
758
  for (const algo of squaringAlgos) {
1015
759
  if (algo.wasmServer) algo.wasmServer.close();
1016
- if (algo.pkirServer) algo.pkirServer.close();
1017
760
  if (algo.llvmServer) algo.llvmServer.close();
1018
- if (algo.llvmPkirServer) algo.llvmPkirServer.close();
1019
761
  }
1020
762
  }
1021
763
 
@@ -1034,7 +776,7 @@ for (let step = 1; step <= squaringSteps; step++) {
1034
776
  const sep130 = "=".repeat(130);
1035
777
  const line130 = "-".repeat(130);
1036
778
 
1037
- if (squaringAlgos.length === 2 && squaringLanes.length === 1 && (squaringLanes[0].id === "llvm" || squaringLanes[0].id === "llvm-pkir")) {
779
+ if (squaringAlgos.length === 2 && squaringLanes.length === 1 && squaringLanes[0].id === "llvm") {
1038
780
  const laneId = squaringLanes[0].id;
1039
781
  const laneName = squaringLanes[0].name;
1040
782
  // LLVM Only side-by-side comparison table