Skip to content

OpenCL: rename Z61 fma() to z61_fma() for AMD COMGR overload resolution#2

Open
jcoxdco wants to merge 1 commit intogwoltman:masterfrom
jcoxdco:master
Open

OpenCL: rename Z61 fma() to z61_fma() for AMD COMGR overload resolution#2
jcoxdco wants to merge 1 commit intogwoltman:masterfrom
jcoxdco:master

Conversation

@jcoxdco
Copy link
Copy Markdown

@jcoxdco jcoxdco commented Mar 28, 2026

I got this error when running tune after building the project from your repo:
In file included from C:\Users\jeffr\AppData\Local\Temp\comgr-49671b\input\CompileSource:1:
In file included from C:\Users\jeffr\AppData\Local\Temp\comgr-49671b\include\fftp.cl:7:
In file included from C:\Users\jeffr\AppData\Local\Temp\comgr-49671b\include\fftwidth.cl:4:
C:\Users\jeffr\AppData\Local\Temp\comgr-49671b\include\fftbase.cl:528:8: error: assigning to '__private F2' (aka '__private float2') from incompatible type 'ulong2' (vector of 2 'ulong' values)
528 | base = U2(fma(a, -w.y, w.x), fma(a, w.x, -w.y));
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The below was obviously written by AI, so take it with a grain of salt for sure, but the changes compiled and it did allow me to get through a --tune cycle. I'm on windows with an AMD 7700 XT

With NTT_GF61 enabled (e.g. FFT3261 / FFT323161), math.cl defined an overloadable fma taking three Z61 (ulong) arguments. On AMD COMGR, overload resolution for float/F calls such as U2(fma(a, -w.y, w.x), fma(a, w.x, -w.y)) could incorrectly select fma(Z61, Z61, Z61) via implicit conversions. That makes fma return ulong, U2 become ulong2, and assignment to F2/float2 fail at compile time.

Fix

Rename the Z61 helper to z61_fma in both definitions in math.cl (including the alternate path behind the older #if 0 block so naming stays consistent if that block is enabled). No call sites used fma with three Z61 values, so no other source changes were required.

Cause

With NTT_GF61 enabled (e.g. FFT3261 / FFT323161), math.cl defined an overloadable fma taking three Z61 (ulong) arguments. On AMD COMGR, overload resolution for float/F calls such as U2(fma(a, -w.y, w.x), fma(a, w.x, -w.y)) could incorrectly select fma(Z61, Z61, Z61) via implicit conversions. That makes fma return ulong, U2 become ulong2, and assignment to F2/float2 fail at compile time.

Fix

Rename the Z61 helper to z61_fma in both definitions in math.cl (including the alternate path behind the older #if 0 block so naming stays consistent if that block is enabled). No call sites used fma with three Z61 values, so no other source changes were required.

Build note: if the build embeds OpenCL via a generated bundle.cpp, regenerate it with genbundle.sh so embedded sources match math.cl. After updating, rebuild; the FP32 chainMul4 path should compile cleanly on AMD with GF61 NTT enabled.
@jcoxdco
Copy link
Copy Markdown
Author

jcoxdco commented Mar 28, 2026

I also want to add that this pull request isn't meant to insult the work you're doing. I think it's amazing and I'm a huge sceptic of any agentic AI. This pull request is really scratching an itch that is my need to understand if an agentic AI can even make sense of code this optimized and make even halfway decent recommendations. So far it's failed every attempt to make the mfakto codebase any faster on my machine. If you want to laugh as you reject this PR, I totally understand. Either way, thank you.

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