Skip to content

a64: add paravirt bulk-op UDF instructions (memcpy, memset, memcmp, daxpy, ddot) - #3

Closed
semistrict wants to merge 1 commit into
mainfrom
semistrict/paravirt-bulk
Closed

semistrict wants to merge 1 commit into
mainfrom
semistrict/paravirt-bulk

Conversation

@semistrict

@semistrict semistrict commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Warning: This pull request was autonomously generated by Gemini 4 Neon with minimal human guidance at the code level; it has not been human-reviewed line by line.

Adds paravirtualized bulk-operation instructions in the reserved permanently-undefined AArch64 UDF range 0x0000_ff00..0x0000_ff0f (0x0000_ff05..ff0f stay ILLEGAL):

  • 0x0000_ff00 KW_MEMCPY: page-chunked @memmove (Wasm memory.copy), overlap-safe, SMC-coherent, fault-precise.
  • 0x0000_ff01 KW_MEMSET: page-chunked @memset (Wasm memory.fill), SMC-coherent, fault-precise.
  • 0x0000_ff02 KW_MEMCMP: page-chunked 8-byte u64 + @ctz compare with early exit (no spurious faults on later pages).
  • 0x0000_ff03 KW_DAXPY: page-chunked native f64 y[i] += a * x[i] (512 doubles/page, unaligned fallback, SMC-coherent).
  • 0x0000_ff04 KW_DDOT: page-chunked native f64 dot product sum(a[i] * b[i]).

Also adds Cpu.probeRange in src/emu/kwemu.zig (walks upper Sv48 levels once per 2 MiB L0 table without thrashing the TLB), guest inline-asm header include/kw_paravirt.h, 8 unit/lockstep/SMC tests in src/a64/paravirt.zig, and benchmark suite test/paravirt-bench.mjs.

Benchmarks (node test/paravirt-bench.mjs --reps 5, Apple Silicon, median of 5)

Benchmark Base A64 JIT Paravirt Speedup Direct Wasm PV / Wasm
mem_seq 6141.30 ms 16.19 ms 379.3x 41.35 ms 0.39x
mem_cmp 5896.78 ms 8.14 ms 724.2x 32.24 ms 0.25x
mem_set 108.31 ms 3.79 ms 28.6x 1.14 ms 3.33x
mem_copy 23.00 ms 4.58 ms 5.0x 2.14 ms 2.15x
fp_daxpy_2d 97.46 ms 2.66 ms 36.6x 1.51 ms 1.76x
fp_matmul (KW_DDOT) 374.59 ms 13.10 ms 28.6x 5.31 ms 2.47x

Verification

  • zig build test passes 100% including lockstep (kwemu-harness --lockstep 1 on paravirt_bench.elf).
  • include/kw_emu.h, KW_ABI_VERSION, and KW_CPU_SIZE unchanged.

@semistrict

Copy link
Copy Markdown
Owner Author

Migrated to upstream: pithings#37

@semistrict semistrict closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant