Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ ApolloCrossDev, copies it to a V4 with ApolloExplorer (`acp`), runs it there
(`ash`), and stores the output, the serial log and optionally a screenshot
or video in `build/v4/`. A test prints `PASS`, `FAIL` and `VALUE` lines (see
`tools/v4/tests/akbtest.h`). Variants of one test (`v4:variant`) run
alternately, as `guides/benchmark-method.md` asks. The script's header lists
alternately. The script's header lists
the environment variables for the V4's address, serial port, capture device
and power plug.

Expand Down
66 changes: 0 additions & 66 deletions core/best-practices/align-copy-destination.md

This file was deleted.

64 changes: 0 additions & 64 deletions core/best-practices/ammx-where-it-wins.md

This file was deleted.

16 changes: 5 additions & 11 deletions core/best-practices/close-loops-with-dbra.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type: best-practice
owner: TuKo1982
status: reviewed
origin: ai-assisted
basis: [core-developer, measured]
basis: [core-developer]
components: [cpu-68080]
applies_to:
core: "Core 12841"
Expand All @@ -22,15 +22,13 @@ sources:

## Goal

Speed: loop overhead of 1 cycle instead of 3. "Loops can often be free, or
very low cost" (G).
Speed: "Loops can often be free, or very low cost" (G).

## Technique

`dbra` is the best loop instruction (G). Use `dbra` for a 16-bit counter and
the 080 encoding `dbra.l` for a 32-bit counter (see
[prm/integer/dbcc-l.md](../cpu-68080/prm/integer/dbcc-l.md)). A
`bne.w` is not an accelerated branch.
[prm/integer/dbcc-l.md](../cpu-68080/prm/integer/dbcc-l.md))..

A good general-purpose loop (G):

Expand Down Expand Up @@ -72,14 +70,10 @@ most 256 bytes back (`bcc.s+`), while `dbra` has a 16-bit displacement.

| Variant | Measurement | Core | Test setup |
|---|---|---|---|
| Loop closed with a `bne.w` that does not fuse | 3 cycles overhead | Core 12841 | CCC counter (M) |
| Loop closed with `dbra` or `subq.l` + `bne.s` | 1 cycle overhead | Core 12841 | Same |
| `subq.l` + `bne` | Not recommended, partly for the loop size limit | any | Statement (G, 2026-11-03) |

`subq.l #1,dn` + `bne.s/.s+/.w` fuses; `subq` + `bpl` does not (M). Gunnar:
"DBRA is fast and nearly free" (G).
Gunnar: "DBRA is fast and nearly free" (G).

## When not to use

- Very short loops (1–4 turns) are expensive whatever the closing branch: one
turn cost about 12 cycles, each extra turn 3 (M). Special-case them.
No limits known beyond the core developer's statements above.
31 changes: 5 additions & 26 deletions core/best-practices/code-size-and-placement.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type: best-practice
owner: TuKo1982
status: reviewed
origin: ai-assisted
basis: [core-developer, measured]
basis: [core-developer]
components: [cpu-68080, toolchain]
applies_to:
core: "Core 12841"
Expand All @@ -23,7 +23,7 @@ sources:
## Goal

Speed of the whole program: hot code that stays in the I-cache. Fat code
evicts other code, and reloading it costs hundreds of cycles.
evicts other code.

## Technique

Expand All @@ -36,12 +36,7 @@ evicts other code, and reloading it costs hundreds of cycles.
- **Keep code and data apart** (G). Code and read-only constants may share a
4 KB page, in two blocks: 2 KB code, then 2 KB constants is fine. Finely
interleaved code and constants (20 bytes of code, 16 bytes of constants,
50 bytes of code, ...) is bad. Never put writable data in a code page (see
[self-modifying-code-and-caches.md](../pitfalls/self-modifying-code-and-caches.md)).
- **Keep hot code contiguous.** Link the assembler routine right after the C
code that calls it, and put cold objects first. Profile builds must keep
the release link order: use `-fno-toplevel-reorder` and the same object
order.
50 bytes of code, ...) is bad. Never put writable data in a code page.
- **Read memory in address order through `(An)+`** (G). Re-lay tables in the
order you read them instead of keeping a C layout; `d16(An)` everywhere
makes code fat.
Expand All @@ -51,24 +46,8 @@ evicts other code, and reloading it costs hundreds of cycles.

## Evidence

| Variant | Measurement | Core | Test setup |
|---|---|---|---|
| Six IMDCT copies (12.9 KB) | Baseline | Core 12841 | Full MP3 decode, CCC (M) |
| One shared transform + 3 short windows (3.8 KB) | Full decode 0.2–0.6 % faster | Core 12841 | Same |
| Profile build with default link order | Synthesis 10.1 % of time | Core 12841 | Same |
| Profile build with release link order | Synthesis 7.3 % of time | Core 12841 | Same |
| Same binary, different load addresses | Up to about 5 % apart (41.6–49.9 cycles on one loop) | Core 12841 | Same |

- Unrolled variants that won alone (an 8 KB FPU window, a 15-row integer
window) lost in the full decoder (M).
- Shrinking one 2.4 KB routine moved the code linked after it and cost 1.7 %
on the full decode, while the routine itself got 2 % faster (M).
No evidence beyond the core developer's statements above.

## When not to use

- A short scheduled tail can still win: turning a **multiply-bound**
scheduled tail into a dbra loop cost about 30 % per element (14 vs 11
cycles per sample). "Never unroll" holds for duplicated copies.
- Measure any unrolling in the full program, never in a microbenchmark.
- Core 12841 has an I-cache with few ways; 1-way builds alias code bigger
than the cache by design. Note the core build with every measurement.
No limits known beyond the core developer's statements above.
68 changes: 0 additions & 68 deletions core/best-practices/fixed-point-and-bitstreams.md

This file was deleted.

64 changes: 0 additions & 64 deletions core/best-practices/fpu-schedule-by-completion-slot.md

This file was deleted.

Loading