From dc260169a21c0cea63998690c530e14401a7ab24 Mon Sep 17 00:00:00 2001 From: WDrijver Date: Tue, 24 Nov 2026 16:52:43 +0100 Subject: [PATCH] Core: Gunnar's answers on the guidelines, 2026-11-24 - Misaligned writes without penalty apply to Core 13000+; on Core 12841 the measured 1.7-1.8x stands. To be re-measured on Core 13000+. - A typical table miss is about 16 cycles; use it as the reference. The measured 27 is a bad case (dependent random reads over 4 MB). - FPU: current cores have the 8 68K FPU registers; all 32 come later. Corrects the note that FPU work could use FP0-FP7 and E0-E23. - All ALU instructions can use D0-D31 in byte, word and long size. - AMMX immediates: Gunnar prefers the 68K convention #$0101.w; vasm 2.0g needs paddb.w #$0101; the syntax may change. Co-Authored-By: Claude Opus 5.5 --- core/best-practices/align-copy-destination.md | 11 ++++++----- core/best-practices/memory-access-patterns.md | 8 +++++--- core/cpu-68080/caches-and-memory.md | 12 +++++++----- core/cpu-68080/execution-units.md | 7 +++++-- core/cpu-68080/fpu-performance-model.md | 8 ++++++-- core/pitfalls/ammx-separate-load-and-store.md | 7 +++++-- 6 files changed, 34 insertions(+), 19 deletions(-) diff --git a/core/best-practices/align-copy-destination.md b/core/best-practices/align-copy-destination.md index 8600056..bedb6f7 100644 --- a/core/best-practices/align-copy-destination.md +++ b/core/best-practices/align-copy-destination.md @@ -18,6 +18,7 @@ sources: - "TuKo1982, 68080 compilation and optimisation guide (2026-10-30), sections 0 (rules 12-13), 5.1 and 12" - "Gunnar (core developer), answers to questions on the guidelines, 2026-11-03" - "Gunnar (core developer), Simply 68080 coding guidelines, version of 2026-11-23" + - "Gunnar (core developer), answers on the guidelines, 2026-11-24" --- ## Goal @@ -56,10 +57,10 @@ Copy of a 156 x 2464-byte shape (M, Core 12841): - Copies under 1 KB: don't add code to align the pointers; use a simple copy loop (G, 2026-11-23). - Gunnar states that the CPU reads and writes misaligned without penalty and - combines writes into 16-byte chunks (G, 2026-11-23; on 2026-11-03 he - expected misaligned writes to work well "in many cases"). That conflicts - with the 1.7–1.8x measured above for a misaligned destination on - 2464-byte rows (M, Core 12841). Until this is re-measured, align the - destination of large copies and fills. + combines writes into 16-byte chunks (G, 2026-11-23). This applies to + **Core 13000+** (G, 2026-11-24). On Core 12841 a misaligned destination + measured 1.7–1.8x slower on 2464-byte rows (M), so on cores before 13000, + align the destination of large copies and fills. To be re-measured on + Core 13000+. - Tiny shapes: for rows of 64 bytes or less, plain 68k code wins (see [ammx-where-it-wins.md](ammx-where-it-wins.md)). diff --git a/core/best-practices/memory-access-patterns.md b/core/best-practices/memory-access-patterns.md index 219a799..6d79c4e 100644 --- a/core/best-practices/memory-access-patterns.md +++ b/core/best-practices/memory-access-patterns.md @@ -19,6 +19,7 @@ sources: - "Gunnar (core developer), Simply 68080 coding guidelines, draft (2026-11-03)" - "Gunnar (core developer), answers to questions on the guidelines, 2026-11-03" - "Gunnar (core developer), Simply 68080 coding guidelines, version of 2026-11-23" + - "Gunnar (core developer), answers on the guidelines, 2026-11-24" --- ## Goal @@ -37,9 +38,10 @@ overlap. - Put data that is used together in the same 64-byte line. - Don't use a table for anything you can compute in 16 cycles or less (G, 2026-11-03). MUL and DIV beat a table; a SIN table makes sense. Keep the - tables you do use small and hot. Gunnar puts a table miss at around 16 - cycles of stall, so 10 cycles of arithmetic can beat a table access - (G, 2026-11-23); the random miss measured below costs about 27 (M). + tables you do use small and hot. A typical table miss costs about 16 + cycles of stall; use 16 as the reference (G, 2026-11-24). So 10 cycles of + arithmetic can beat a table access (G, 2026-11-23). The 27 measured below + is a bad case: dependent random reads over 4 MB (M). - Avoid rows exactly 64 KB apart: they alias in the cache. - Use `touch d8(An,Dn)` 12–15 cycles ahead only for random accesses, never on a sequential stream. diff --git a/core/cpu-68080/caches-and-memory.md b/core/cpu-68080/caches-and-memory.md index c006e46..1fb2077 100644 --- a/core/cpu-68080/caches-and-memory.md +++ b/core/cpu-68080/caches-and-memory.md @@ -22,6 +22,7 @@ sources: - "Gunnar (core developer), memory controller width, 2026-11-04" - "WDrijver (maintainer), same core on every V4 model, 2026-11-04" - "Gunnar (core developer), Simply 68080 coding guidelines, version of 2026-11-23" + - "Gunnar (core developer), answers on the guidelines, 2026-11-24" --- ## Summary @@ -86,8 +87,9 @@ The memory controller is part of the core, so it is the same on every V4 model that runs the same core (see [hardware/index.md](../../hardware/index.md)). -The 27 cycles above are one case: dependent random reads over 4 MB. When -you measure a miss, state these conditions. +The 27 cycles above are one case: dependent random reads over 4 MB. The +typical miss, to use as the reference, is about 16 cycles of stall (G, +2026-11-24). When you measure a miss, state these conditions. Memory-bound measurements from a core before 12600 (64-bit controller) are not comparable with those from Core 12600 and later. All measurements in @@ -110,9 +112,9 @@ Copy of a 156 x 2464-byte shape (M): 0–13 %. - Gunnar (G, 2026-11-23): misaligned reads and writes have no penalty, a read may span two cache lines, writes are combined into 16-byte chunks, - and copies under 1 KB need no alignment code. The "no penalty" for writes - conflicts with the 1.7–1.8x measured above (M, Core 12841); to be - re-measured. + and copies under 1 KB need no alignment code. This applies to Core 13000+ + (G, 2026-11-24); on Core 12841 the 1.7–1.8x above stands (M). To be + re-measured on Core 13000+. - Copies are memory-bound at about 3 bytes per cycle: optimising a blit copy gained only 3–10 %. - A `.b`/`.w` write into a register also reads its old value: an extra diff --git a/core/cpu-68080/execution-units.md b/core/cpu-68080/execution-units.md index 26cb77c..17ee2b5 100644 --- a/core/cpu-68080/execution-units.md +++ b/core/cpu-68080/execution-units.md @@ -20,6 +20,7 @@ sources: - "Gunnar (core developer), Simply 68080 coding guidelines, draft (2026-11-03)" - "Gunnar (core developer), answers to questions on the guidelines, 2026-11-03" - "Gunnar (core developer), Simply 68080 coding guidelines, version of 2026-11-23" + - "Gunnar (core developer), answers on the guidelines, 2026-11-24" --- ## Summary @@ -59,8 +60,10 @@ the ALUs that own the data registers. Most cores run 2 pipes; 3 are planned. - `bsr.s`, `bsr.w` and `bsr.l` typically take 1 cycle (G, 2026-11-23). - `dbra.w` (16-bit counter) and `dbra.l` (32-bit counter) take a single cycle and can be the last instruction of a group (G, 2026-11-23). The - counter can be any data register D0–D31 (G, 2026-11-23; see - [bank-prefix.md](bank-prefix.md) for D8–D31 = E0–E23). See + counter can be any data register D0–D31 (G, 2026-11-23): all ALU + (integer) instructions can use the 32 data registers D0–D31, in byte, + word and long size (G, 2026-11-24). See [bank-prefix.md](bank-prefix.md) + for D8–D31 = E0–E23 and how they are encoded. See [close-loops-with-dbra.md](../best-practices/close-loops-with-dbra.md). - `jmp (An)` is computed by the EA unit and takes much longer than the branches in the first row. diff --git a/core/cpu-68080/fpu-performance-model.md b/core/cpu-68080/fpu-performance-model.md index 56eb36c..85da66e 100644 --- a/core/cpu-68080/fpu-performance-model.md +++ b/core/cpu-68080/fpu-performance-model.md @@ -17,6 +17,7 @@ related: sources: - "TuKo1982, 68080 compilation and optimisation guide (2026-10-30), section 4.1" - "Gunnar (core developer), Simply 68080 coding guidelines, draft (2026-11-03)" + - "Gunnar (core developer), answers on the guidelines, 2026-11-24" --- ## Summary @@ -53,8 +54,11 @@ predicted all 25 measured patterns exactly. - Gunnar's rule (G): **a pipelined unit showing more than 1 cycle per instruction means the schedule is wrong.** - Gunnar's rule of thumb (G): expect about 6 cycles latency for fadd and - fmul, unroll FPU code to cover it, and use the 32 registers available for - FPU work (FP0–FP7 and E0–E23). The measured fmul latency is 5. + fmul, and unroll FPU code to cover it. The measured fmul latency is 5. +- Current cores have the 8 FPU registers of the 68K (FP0–FP7), and FPU code + is normal 68K code. Later cores will let the FPU use all 32 registers + (G, 2026-11-24). This corrects an earlier note here that FPU work could + use FP0–FP7 and E0–E23. ## Differences from AmigaOS / AROS / 68060 diff --git a/core/pitfalls/ammx-separate-load-and-store.md b/core/pitfalls/ammx-separate-load-and-store.md index ae81ede..ea90ec9 100644 --- a/core/pitfalls/ammx-separate-load-and-store.md +++ b/core/pitfalls/ammx-separate-load-and-store.md @@ -26,6 +26,7 @@ sources: - "Gunnar (core developer), AMMX operand forms, 2026-11-24" - "Apollo 68080 PRM (sources/official/AC68080PRM.odt), AMMX format page" - "vasm 2.0g (ApolloCrossDev GCC-6.50-Dev), test assembly of the forms below, 2026-11-24" + - "Gunnar (core developer), answers on the guidelines, 2026-11-24" --- ## Symptom @@ -96,8 +97,10 @@ An immediate is an operand too: `paddb #$0101,d1,d2` assembles silently to a 64-bit immediate `$0000000000000101` (12-byte instruction), so only the lowest lanes get the value. `paddb #$0101.w,d1,d2` does the same, with a "trailing garbage" - warning. Gunnar suggests `#imm.w` as the syntax (G); vasm does not - support it. + warning. Gunnar prefers `#$0101.w`, the 68K convention of qualifying + the value, as in `move.l $04.w,a6` (G, 2026-11-24); vasm 2.0g does not + support it for AMMX. The team is discussing the syntax, so this may + change: check the vasm version you use. - **Names:** Gunnar calls the store instructions VSTORE, VSTOREM, VSTOREC, VSTOREM2 and VSTOREM3. vasm accepts only the PRM names `store`, `storem`, `storec`, `storeilm` (the PRM: "also called storem2") and