Skip to content

Commit b611f06

Browse files
Ravenwaterclaude
andauthored
docs: introduce sb_add / sb_sub naming convention (#791)
Reader feedback: the term "sb_add" is used in the History section of docs/number-systems/lns.md and in the cost-comparison table before it is formally defined in the How section -- and "sb_" itself is opaque because it does not stand for anything in the LNS literature. It was introduced as Universal's internal C++ API prefix when the configurable add/sub framework landed in PR #784, without an inline definition. Fixes: 1. docs/number-systems/lns.md (Introduction): - History section: replace "sb_add" with descriptive prose ("approximation for the log-add correction") so the term is not used before its definition - Operation cost comparison table: same -- "Transcendental sb_add" -> "Transcendental log-add correction" - How section: add a "Naming convention" callout box where the formal definition is given. The callout: - states the formula (sb_add(d) = log2(1 + 2^d), sb_sub(d) = log2(1 - 2^d)) - explains that "sb_" reads as "sum-base" and is Universal's internal C++ API prefix - cites the LNS literature equivalents (Coleman et al.'s phi(z) / psi(z), Arnold et al.'s F+(d) / F-(d)) - clarifies that the mathematics is identical; only symbol choice differs 2. docs/number-systems/lns-addsub-algorithms.md (intro paragraph): - First reference now also defines sb_sub, and links to the Naming convention callout in the introduction page. 3. docs/number-systems/lns-tolerance-traits.md (boundary-rounding problem): - First reference adds a brief reminder of the formula and a link to the introduction's Naming convention callout. 4. docs/design/lns-add-sub.md (the canonical design doc): - Same Naming convention callout added at the point where sb_add and sb_sub are first formally defined. - Drive-by: replace one residual em dash with the ASCII " -- " in the same paragraph (matches the project's ASCII-only convention). The C++ API names (sb_add, sb_sub) are unchanged. Renaming the API to match the literature (phi/psi or F+/F-) was considered but rejected as out-of-scope churn -- the prefix has shipped through PRs #784-#788 and is now part of the policy class API contract. Documenting what it means is the right pragmatic call. Verified: docs-site sync runs cleanly, full astro build produces 80 pages, all 5 affected files are ASCII-only. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7c2ff41 commit b611f06

4 files changed

Lines changed: 37 additions & 8 deletions

File tree

docs/design/lns-add-sub.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,20 @@ For mixed-sign operands the analogous correction is
4848
unbounded slope as `d -> 0` (catastrophic cancellation), and goes to `-inf`
4949
exactly at `d = 0` (which is the `a + (-a) = 0` case).
5050

51-
So the entire game in lns add/sub is computing `sb_add(d)` and `sb_sub(d)`
51+
So the entire game in lns add/sub is computing `sb_add(d)` and `sb_sub(d)` --
5252
the rest is bookkeeping (sign routing, special values, encode/decode). The
5353
five algorithms in this framework differ only in *how* they compute `sb_add`
5454
and `sb_sub`.
5555

56+
> **Naming convention.** Universal's policy class API uses the prefix `sb_`
57+
> (read as "sum-base") for these correction functions. The LNS literature
58+
> uses different conventions for the same mathematics: Coleman et al.
59+
> (European Logarithmic Microprocessor) write `phi(z) = log_b(1 + b^z)` and
60+
> `psi(z) = log_b(1 - b^z)`; Arnold et al. write `F+(d)` and `F-(d)`. The
61+
> `sb_` prefix was chosen as a short, ASCII-friendly tag for the C++ API
62+
> at the start of the configurable add/sub framework (PR #784) and is
63+
> Universal-internal -- it's not standard literature.
64+
5665
---
5766

5867
## The customization point

docs/number-systems/lns-addsub-algorithms.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
LNS makes multiplication and division trivial -- they are integer
44
operations on the exponent. The hard problem is *addition*: it requires
5-
computing a transcendental correction term `sb_add(d) = log2(1 + 2^d)`,
6-
and there are many ways to compute it, each with a different
7-
accuracy / SRAM / latency / energy trade.
5+
computing a transcendental correction term `sb_add(d) = log2(1 + 2^d)`
6+
(and `sb_sub(d) = log2(1 - 2^d)` for mixed-sign / subtraction), and
7+
there are many ways to compute these corrections, each with a different
8+
accuracy / SRAM / latency / energy trade. See the [Introduction](../lns/)
9+
for the Gauss log-add derivation that produces these functions, and for
10+
the [Naming convention](../lns/#how) note explaining the `sb_` prefix.
811

912
Universal ships a configurable framework that lets users select, per
1013
`lns<>` instantiation, which `sb_add` / `sb_sub` implementation is used.

docs/number-systems/lns-tolerance-traits.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ Concrete example. With `lns<8, 2>` and `ArnoldBaileyAddSub`:
2121
- `ArnoldBailey` worst-case `sb_add` error: ~0.025 in the log domain
2222
(the secant-interpolation error mid-interval, near `d = -0.5`).
2323

24+
(Recall: `sb_add(d) = log2(1 + 2^d)` is the log-add correction defined
25+
in [Introduction](../lns/#how); the `sb_` prefix is documented there.)
26+
2427
The algorithm error 0.025 is much smaller than the ULP 0.25, so the
2528
algorithm is accurate "in absolute terms." But: when the true result
2629
sits near a rounding boundary, the algorithm's small log-domain error

docs/number-systems/lns.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ The modern computer-arithmetic treatment starts with:
2626
proposed a piecewise-linear approximation for the log-add correction
2727
needed to handle addition. The two-line formula `log2(1 + u) ~= u`
2828
for `u in [0, 1]` is now known as the *Mitchell approximation* and
29-
remains the cheapest closed-form sb_add available -- at the cost of
30-
~9% worst-case relative error.
29+
remains the cheapest closed-form approximation for the log-add
30+
correction available -- at the cost of ~9% worst-case relative error.
3131

3232
The 1980s and 1990s saw a wave of LNS hardware research aimed at making
3333
the log-domain add tractable for production hardware:
@@ -131,8 +131,8 @@ log domain (exponent).
131131
| Division | Significand divide (very expensive) | Integer subtract on exponent (cheap) |
132132
| Square | Significand multiply | Exponent left-shift by 1 |
133133
| Square root | Iterative significand op (very expensive) | Exponent right-shift by 1 |
134-
| Addition | Align + significand add (cheap) | Transcendental sb_add (expensive) |
135-
| Subtraction | Align + significand subtract (cheap) | Transcendental sb_sub (expensive) |
134+
| Addition | Align + significand add (cheap) | Transcendental log-add correction (expensive) |
135+
| Subtraction | Align + significand subtract (cheap) | Transcendental log-sub correction (expensive) |
136136

137137
The LNS column inverts the IEEE column for the multiply / divide / power
138138
group versus the add / subtract group. Every workload-level decision
@@ -188,6 +188,20 @@ a fundamental difficulty: `sb_sub` has unbounded slope as `d -> 0`
188188
(catastrophic cancellation) and goes to `-infinity` exactly at `d = 0`
189189
(which is the `x + (-x) = 0` case).
190190

191+
> **Naming convention.** Universal's policy class API uses the prefix
192+
> `sb_` (read as "sum-base", a short ASCII-friendly tag) for these
193+
> correction functions:
194+
>
195+
> - `sb_add(d) = log2(1 + 2^d)` for `d <= 0`
196+
> - `sb_sub(d) = log2(1 - 2^d)` for `d < 0`
197+
>
198+
> The LNS literature uses different conventions for the same functions:
199+
> Coleman et al. (European Logarithmic Microprocessor papers) write
200+
> `phi(z)` and `psi(z)`; Arnold et al. write `F+(d)` and `F-(d)`. The
201+
> mathematics is identical; only the symbol choice differs. The `sb_`
202+
> prefix is Universal's internal naming -- you will see it throughout
203+
> the C++ API, the policy classes, and the rest of these docs.
204+
191205
Different LNS implementations differ almost entirely in how they
192206
compute `sb_add` and `sb_sub`. The choices span:
193207

0 commit comments

Comments
 (0)