Skip to content

Assert before terminating on throw in device code#7358

Merged
davebayer merged 3 commits intoNVIDIA:mainfrom
davebayer:assert_device_throw
Jan 26, 2026
Merged

Assert before terminating on throw in device code#7358
davebayer merged 3 commits intoNVIDIA:mainfrom
davebayer:assert_device_throw

Conversation

@davebayer
Copy link
Contributor

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_ASSERT before the cuda::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_THROW macro, 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 cudaErrorAssert instead 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.

@davebayer davebayer requested review from a team as code owners January 26, 2026 15:43
@davebayer davebayer requested a review from gonidelis January 26, 2026 15:43
@github-project-automation github-project-automation bot moved this to Todo in CCCL Jan 26, 2026
@davebayer davebayer requested a review from griwes January 26, 2026 15:43
@cccl-authenticator-app cccl-authenticator-app bot moved this from Todo to In Review in CCCL Jan 26, 2026
Copy link
Contributor

@fbusato fbusato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember if we have a test to verify that _CCCL_THROW works correctly in the failing case.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

🥳 CI Workflow Results

🟩 Finished in 1h 32m: Pass: 100%/84 | Total: 12h 49m | Max: 55m 32s | Hits: 99%/199283

See results here.

@davebayer davebayer merged commit ece118b into NVIDIA:main Jan 26, 2026
196 of 202 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in CCCL Jan 26, 2026
@davebayer davebayer deleted the assert_device_throw branch January 26, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants

Comments