Pass the exception type separately to @gputhrow - #1098
Merged
Merged
Conversation
Take the name of the exception type and the reason as separate arguments, like CUDA.jl, Metal.jl and OpenCL.jl do, instead of deriving the error code from a prefix of the message. This makes the quirks the same across back-ends, apart from how the exception is reported, which prepares for sharing them.
luraess
approved these changes
Sep 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is preparation for sharing the exception quirks (Base methods that are overridden so that exceptions don't box their arguments) across back-ends. Those are nearly identical across CUDA.jl, AMDGPU.jl, Metal.jl, OpenCL.jl, oneAPI.jl and KernelAbstractions' POCL back-end, except for the macro that throws: CUDA.jl, Metal.jl and OpenCL.jl use
@gputhrow name reason, taking the name of the exception type and a reason.Here,
@gpu_throw "Type: reason"becomes@gputhrow "Type" "reason", with the error code now derived from the type name instead of a prefix of the message. The reason is still dropped, as AMDGPU.jl's exception info only holds an 8-bit error code; I checked that every call site maps to the same code as before.Based on #1097: after merging that one, delete its branch (this repository doesn't do so automatically) so that GitHub retargets this PR to
main.