Skip to content

Add best practice: Choose between AMMX fixed-point and FPU for matrix multiplication - #50

Open
Rudi7503 wants to merge 1 commit into
ApolloTeam-dev:mainfrom
Rudi7503:feature/matrix-multiplication-best-practice
Open

Rudi7503 wants to merge 1 commit into
ApolloTeam-dev:mainfrom
Rudi7503:feature/matrix-multiplication-best-practice

Conversation

@Rudi7503

Copy link
Copy Markdown

Summary

This PR adds a comprehensive best-practice guide (core/best-practices/matrix-multiplication-ammx-vs-fpu.md) comparing 16-bit AMMX fixed-point vs 32-bit FPU single-precision floating point for 2x2, 3x3, and 4x4 matrix multiplication in 3D geometry transformations and game engines.

Key Insights & Hardware Evidence

Measurements conducted on physical Vampire V4 Standalone hardware (Core 11350 @ 92 MHz, 100 runs under Forbid() with CCC performance counter):

Matrix Size GCC -O2 C Reference FPU Single-Precision (Opt) AMMX 16-Bit Fixed-Point Speedup vs C Speedup vs FPU
2x2 111 cycles 27 cycles 17 cycles 6.5x 1.6x
3x3 301 cycles 87 cycles 34 cycles 8.8x 2.6x
4x4 599 cycles 184 cycles 54 cycles 11.1x 3.4x
  • Hardware Limits Explained: Explains why 184 cycles is the hardware execution floor for 4x4 float on the 68080 (Pipe 1 FPU bottleneck, 160 FPU instructions, 6-cycle latency, and Bank prefixes).
  • AMMX 4-Lane Outer-Product: Demonstrates how vperm splatting + pmulh achieves 54 cycles for complete 4x4 matrix transformations.
  • Validation: Conforms to AKB schema, passes check_links.py, check_frontmatter.py, and the assembly snippet cleanly compiles with vasmm68k_mot 2.0f.

@Rudi7503

Copy link
Copy Markdown
Author

Hi @WDrijver @gunnar,

Beyond these best-practice guides, we have developed a comprehensive, automated hardware testing bench on physical Vampire V4 Standalone hardware (Core 11350 @ 92 MHz):

  1. Cycle-Exact Hardware Profiling:

    • Uses the Apollo 68080 hardware performance counters directly (CCC for exact clock cycles, IEP1 and IEP2 for Pipe 1 / Pipe 2 execution breakdown).
    • Measures raw vs. trained-loop execution with calibrated 10-iteration loop overhead subtraction.
  2. Automated Hardware Power-Cycling:

    • Currently v4test.py supports Tasmota HTTP smart plugs. We have integrated local USB relay hardware power-cycling (e.g. CH340 / FTDI USB serial relays wired to NC/NO), allowing automated reboot/recovery if a test locks up the machine or takes over the OS.
  3. Extensive Test Suites Ready for Integration:

    • Over 50 tested benchmarks across AMMX, SAGA blitting, signal processing, and memory bandwidth (BFLY, 1D/2D-DCT, DWT Haar/LeGall/Daubechies, 4x4 matrix, MEMSET at 1.13 GB/s, MEMCPY at 446 MB/s, Alpha Blit at 1.22 GPx/s).

Would you be interested in:

  • A PR adding USB-serial relay power-cycle support to tools/v4/v4test.py?
  • Porting our benchmark suites into tools/v4/tests/ so they can run as official regression/validation tests in the knowledge base?

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