Fix unchecked CUDA calls in noexcept functions - #1244
Conversation
… in noexcept contexts Adds MATX_CUDA_CHECK_NOEXCEPT: - checks the error state against cudaSuccess - on failure, logs the error - logging is guarded by try/catch, to allow safe usage in noexcept contexts (logging with std::format could throw)
# Conflicts: # include/matx/core/allocator.h
Covers print.h, pybind.h, and tensor.h's prefetch helpers.
Covers cuda_executor_common.h's timing/profiling calls and distributed.h's device-guard and stream-cleanup destructors.
…forms/ Covers base_operator.h's copy/event-record paths and the solver transforms (cgsolve, chol, eig, fft, inverse, lu, qr, solve, svd).
Greptile SummaryThe PR adds checked CUDA-call handling, including non-throwing diagnostics for noexcept contexts, and converts the temporary stream and event lifetimes in iterative solver paths to RAII.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported exception-path resource leak is addressed by transferring each successfully created CUDA handle into RAII ownership before subsequent throwing operations. Important Files Changed
Reviews (3): Last reviewed commit: "Merge branch 'main' into fix/unchecked_c..." | Re-trigger Greptile |
The newly-added MATX_CUDA_CHECK calls in cgsolve_impl and svdbpi_impl can now throw between creating their temporary d2h stream/event and the end-of-function cleanup that used to destroy them, leaking both on any such throw. Replace the manual create/destroy with detail::CudaStreamGuard/CudaEventGuard (core/resource_guard.h), a shared unique_ptr-based RAII guard for opaque CUDA handles, so cleanup runs on any exception path.
|
/build |
|
Hi @cliffburdick, could you let me know which test is failing? I made sure no tests failed locally because of my changes, but some didn't run from the beginning because of the Jetson architecture, so it could be one of these cases I could not verify |
Hi @lennartvoelz, nothing is failing. It's just a DNS issue. I'll review and merge when ready. |
@lennartvoelz there is one unresolved comment from greptile. |
Hi @cliffburdick, I think the comment is stale. Should be fixed with the latest commit and the introduced resource guard 31c0b3c |
|
/build |
Fixes #1241
Adds MATX_CUDA_CHECK_NOEXCEPT:
Wraps bare CUDA API calls in either MATX_CUDA_CHECK or MATX_CUDA_CHECK_NOEXCEPT