raz / commit 01dfbf63

commit
01dfbf639db5994f0085144d06bd551171e68be9
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
36e782df
PLAN: better code for reals, done

Against v0.8.0, on test/bench's kernels, raz against FPC -O2: Jacobi
3.1 -> 1.3 times (251 -> 103 ms), NBody 4.4 -> 1.4 (375 -> 116); rat's
workload and the integer kernels as they were. compiler.md says what
is left: Jacobi's index, worked out for each element where FPC shares
it; NBody's call to Math.sqrt; a comparison of reals that jumps
without a BOOL. Not tagged.

patch · log

3 files changed, +31 -8

CLAUDE.md modified +6 -3

@@ -91,9 +91,12 @@
9191 `raz-tutorial(7)`, `raz(7)` and `raz-lib(3)`, made by `tools/Doc.raz`
9292 from `lib/`, and v0.8.0, better code again: slices in registers,
9393 parameters left in rdi and rsi, operands as the machine has them,
94-`while` tested at the bottom, and one line table, DWARF's. `make
95-kernels` measures `test/bench` against FPC `-O2`. Next, by `PLAN.md`:
96-what the owner chooses.
94+`while` tested at the bottom, and one line table, DWARF's, and,
95+not yet tagged, better code for reals: reals on the stack and the
96+busiest real variables in xmm registers, and an array's element and a
97+constant offset as operands, measured on two kernels of reals,
98+`Jacobi` and `NBody`. `make kernels` measures `test/bench` against
99+FPC `-O2`. Next, by `PLAN.md`: what the owner chooses.
97100
98101 **The freeze.** Since v0.5.0 the language changes only to mend a
99102 defect, and the library grows only by what breaks no program written

PLAN.md (history) modified +12 -5

@@ -5,12 +5,12 @@
55 stopping for the owner's review. A finished milestone is cut from this
66 file: git keeps the history, and the report's section 12 the language's.
77
8-Better code for reals is under way, by the owner's word. v0.7.1, the
9-manual, and v0.8.0, better code again, are tagged; all before v0.7.1
10-is approved by the owner, and v0.7.1 and v0.8.0 wait for the owner's
11-review.
8+Better code for reals, begun by the owner's word, is done and waits for the
9+owner's review; it isn't tagged. v0.7.1, the manual, and v0.8.0,
10+better code again, are tagged; all before v0.7.1 is approved by the
11+owner, and v0.7.1 and v0.8.0 wait for the owner's review.
1212
13-## Now: better code for reals
13+## Done: better code for reals
1414
1515 For: code with reals near FPC `-O2`'s, as integer code is. raz keeps a
1616 real in an integer register and copies it to xmm0 or xmm1 and back
@@ -46,6 +46,13 @@
4646 slot, from which the trap report reads it and a call's return loads
4747 it, as System V keeps no xmm register through a call. NBody 147 ms
4848 to 116; rat within noise.
49+
50+All told: Jacobi 3.1 times FPC `-O2`'s time to 1.3, NBody 4.4 to 1.4;
51+rat and the integer kernels as they were; 9,131 lines of code. Left:
52+Jacobi's index, worked out for each element where FPC shares it, which
53+one pass can't; NBody's call to `Math.sqrt`, an instruction to FPC;
54+a comparison of reals that jumps without making a `BOOL`, which
55+neither kernel needs.
4956
5057 ## Next, when the owner says
5158

doc/compiler.md (history) modified +13 -0

@@ -603,6 +603,19 @@
603603 nothing in the trap report, bought 3% more on that copy and nothing
604604 on NBody.
605605
606+All told, against v0.8.0: Jacobi 251 ms to 103, 3.1 times FPC
607+`-O2`'s time to 1.3; NBody 375 ms to 116, 4.4 times to 1.4; rat and
608+the integer kernels as they were. What is left of Jacobi is its index,
609+`i * N + j`, worked out five times a round, once for each element,
610+where FPC works it out three times: one pass keeps no expression to
611+share. What is left of
612+NBody is mostly its call to `Math.sqrt`, an instruction FPC puts in
613+place, with the spills and loads around it; then the `lea` of each
614+array's address, which FPC makes too, and the fifth real, `d2`, for
615+which there is no register. A comparison of reals still makes a
616+`BOOL` before it jumps, as `not (a < b)` isn't `a >= b` for a NaN;
617+neither kernel has one.
618+
606619 ## diag.pas: messages
607620
608621 Every message the compiler prints is made here. A position, `TPos`, is