P3.4: transcribe plugin's own vectorized ln(x) (vlog.cpp, minimax ln(1+x) poly + ln2 range-reduction); correct prior misread — dispatch reaches runtime ln, not FFT; vlog_check ALL OK (rel 2.4e-7)

This commit is contained in:
2026-08-20 07:12:56 +03:00
parent 7bbe7cce05
commit feb44c3802
5 changed files with 190 additions and 15 deletions
+22 -15
View File
@@ -95,22 +95,29 @@ These 6 are the final split-radix FFT kernels (stack frames 0x328/0x350/0x7c8/0x
vldmxcsr, round-to-nearest 0x1f80) AND x87 control word (fnstcw/fldcw) before the FP loop,
then restores. So the transform runs under an explicitly-forced rounding mode.
### STATUS / scope
Full bit-exact FFT = plan generator (0x2f980 split-radix index algebra) + runtime dispatch
(3-level tables) + 6 final kernels (each 0x800-0x1200 bytes of vectorized split-radix butterfly)
+ twiddle. This is the P3 2-4 week body. Architecture fully mapped; transcription not yet done.
### CORRECTION (2026-08-20b): the "final kernels" are vectorized ln(x), NOT FFT
The 6 addresses 0x1802a24c0..0x1802ce4a0 are the plugin's OWN vectorized **natural log**,
not split-radix FFT butterflies (verified by subagent numeric simulation: matches std::log
to float precision). The dispatch chain 0x535a70→…→[0x1826181d8] reaches the plugin's
runtime math-function table, not the FFT. Three ln variants live around 0x1802a24c0:
- 0x1802a24c0 = AVX2 float ln (minimax poly, range-reduction via 2/3 magic 0x3f2aaaab, ln2)
- 0x1802a2fc0 = scalar double ln (Cody-Waite table 128×3 + Taylor), slow path
- 0x1802a3260 = second ln variant (9-term, split ln2 hi/lo)
The earlier "own vectorized sin/cos" reading was WRONG — the constants (0.333366, 0.250047,
…, 0.693147=ln2, 2/3, 0.75) are the minimax coefficients of ln(1+x), not sin/cos.
Transcribed to `dsp/vlog.{hpp,cpp}` (namespace vlog, `log_f32(src,dst,n)`), check ALL OK
(max rel err 2.4e-7 vs std::log). This is the exact log used by level-path (logf·8.6859
for dB, log/gamma in LUT curve), so it feeds bit-exact level→dB.
### Final kernel 0x1802a24c0 — own vectorized sin/cos, NOT twiddle table
The big-N kernels compute trig ON THE FLY via an AVX polynomial (vfmadd231ps/213ps chain) with
range reduction done by float-bit tricks (vpaddd/vpsubd/vpsrad $0x17 = 23-bit shift = exponent
extract, vpcmpgtd, vblendvps). Polynomial constants (rodata, float, broadcast x8):
0x181f81fa0 = 0.333366 0x181f81fc0 = -0.250047 0x181f81fe0 = 0.198225
0x181f82000 = -0.164625 0x181f82020 = 0.169649 0x181f82040 = -0.151772
0x181f82100 = 0.666667 0x181f821c0 = 0.693147 (= ln 2) 0x181f822c0 = 0.75
(0.693147 = ln 2 ⇒ exp-based sin/cos, SVML-like vector math library.)
=> Small-N path uses the twiddle sin-table (0x39b00); big-N path uses this own polynomial.
Transcribing this bit-exactly = reimplementing a vector math sin/cos (Cody-Waite + poly + exp),
plus the split-radix butterfly + integer reorder — the multi-week P3 body.
### REAL FFT pieces (still to transcribe):
- stage kernels FUN_18000bfc0 / 18000c5e0 (butterfly) — see above
- plan generator FUN_18002f980 (split-radix index algebra)
- actual twiddle usage for small N via FUN_180039b00 sin-table
So P3 scope is unchanged (butterfly + plan gen), NOT the ln kernels.
## STATUS / scope
Full bit-exact FFT = plan generator (0x2f980 split-radix index algebra) + stage kernels
(0xbfc0/0xc5e0 butterfly) + twiddle. ln (vlog) now done. FFT butterfly + plan gen remain.