-
Notifications
You must be signed in to change notification settings - Fork 57
SPIRV: Truncate Int128 to Int64 #728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #728 +/- ##
==========================================
- Coverage 75.26% 73.67% -1.60%
==========================================
Files 24 24
Lines 3635 3745 +110
==========================================
+ Hits 2736 2759 +23
- Misses 899 986 +87 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Oof that's a tough one. I feel like we should actually do the soft implementation instead of truncating to the lowbit |
What do you mean by soft implementation? The problem is that some
operations also return Int128. You mean implement a workaround for those
that don't?
Or add 128bit support to the Khronos translator? I think the Intel backend won't support it either.
…On Wed, Oct 8, 2025, 4:16 PM Valentin Churavy ***@***.***> wrote:
*vchuravy* left a comment (JuliaGPU/GPUCompiler.jl#728)
<#728 (comment)>
Oof that's a tough one. I feel like we should actually do the soft
implementation instead of truncating to the lowbit
—
Reply to this email directly, view it on GitHub
<#728 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACXCFWTGZLMBU3AZFKRCTDD3WV5LFAVCNFSM6AAAAACIVCK3ISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGOBTGI3DKMZTGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
With "soft math" I mean doing the operations in software instead of using hardware operations. So do the lowering as you are here converting As an example GCC https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html and LLVM https://github.com/llvm/llvm-project/tree/main/compiler-rt/lib/builtins https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/builtins/multi3.c (Note that this is similar to what we could/should do for platforms that don't have Float64) |
Phew. That's what I meant with teaching the translator Int128. That's quite a task. Let's say what about this as an interim fix? ;-) I somehow wonder why this Int128 is even emitted. It happens only in one test. I looked around a bit, but it seems that LLVM doesn't provide any built-in mechanism for Int128 -> Int64, Int64. Don't most backends have to implement it, since most hardware has no 128bit registers? Should I ask the AMDGPU folks? Can't we blame the frontend? Float64/128 emulation through Float32/Float64 is really a can of worms. |
Simply truncating seems bad indeed. Did you consider adding a quirk instead to override the Julia code that widens in the first place? |
No. Where do I add a quirk? I thought this was what you meant by quirk. |
Here: https://github.com/JuliaGPU/oneAPI.jl/blob/master/src/device/quirks.jl |
We are the frontend :/ |
Thanks both of you! It was indeed an easy fix. This It only triggered with |
In Julia >=1.12, the SPIRV translator encounters
Int128
s when running the oneAPI.jl tests. This PR truncatesInt128
toInt64
and prevents the translator from crashing. Additionally, it provides the user with clear information on the truncation.See JuliaGPU/oneAPI.jl#529 and #101