Assert before terminating on throw in device code#7358
Merged
davebayer merged 3 commits intoNVIDIA:mainfrom Jan 26, 2026
Merged
Assert before terminating on throw in device code#7358davebayer merged 3 commits intoNVIDIA:mainfrom
throw in device code#7358davebayer merged 3 commits intoNVIDIA:mainfrom
Conversation
fbusato
approved these changes
Jan 26, 2026
Contributor
fbusato
left a comment
There was a problem hiding this comment.
I don't remember if we have a test to verify that _CCCL_THROW works correctly in the failing case.
This comment has been minimized.
This comment has been minimized.
Contributor
🥳 CI Workflow Results🟩 Finished in 1h 32m: Pass: 100%/84 | Total: 12h 49m | Max: 55m 32s | Hits: 99%/199283See results here. |
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.
Currently, if an exception is thrown in device code, we just call
cuda::std::terminate. There is basically no way to find out what went wrong.This PR tries to change that and make a small step towards the "Oh, I have an idea what went wrong.." goal by adding
_CCCL_ASSERTbefore thecuda::std::terminate()call, providing a message with the name of the exception that would be thrown.To make this possible, I had to change the implementation of the
_CCCL_THROWmacro, so we can convert the type name to string even if the type itself is not available (for example when compiling with NVRTC).There is also another hidden change. If an assertion happens, the CUDA API calls will return
cudaErrorAssertinstead of the one returned after__trap()(I cannot remember which one is it, but it's different).As the title says, this is an assertion, so if the user disables assertions in CCCL, just
cuda::std::terminate()is called as usually.