[TRIVIAL] Review fixup for #8266: RAII malloc buffers in test_cuda_kernel#8290
Merged
caugonnet merged 5 commits intoNVIDIA:mainfrom Apr 7, 2026
Merged
Conversation
Use std::unique_ptr<void, decltype(&free)> for X/Y malloc buffers so REQUIRE failures do not leak memory (review feedback). Made-with: Cursor
Contributor
oleksandr-pavlyk
approved these changes
Apr 3, 2026
jrhemstad
reviewed
Apr 4, 2026
|
|
||
| double* X = (double*) malloc(N * sizeof(double)); | ||
| double* Y = (double*) malloc(N * sizeof(double)); | ||
| std::unique_ptr<void, decltype(&free)> X_owner(malloc(N * sizeof(double)), free); |
Collaborator
There was a problem hiding this comment.
suggestion: Can't these just be std::vector to avoid the custom logic here?
Contributor
There was a problem hiding this comment.
I'm going to vote for this option too, and avoid all complicated stuffs
Wrap malloc (and cudaMallocHost/cudaFree paths) in unique_ptr with appropriate deleters so failed REQUIRE does not leak memory. Extends the pattern from test_cuda_kernel to logical_data, logical_data_with_place, places, task, and token tests. Made-with: Cursor
davebayer
reviewed
Apr 7, 2026
|
|
||
| double* X = (double*) malloc(N * sizeof(double)); | ||
| double* Y = (double*) malloc(N * sizeof(double)); | ||
| std::unique_ptr<void, decltype(&free)> X_owner(malloc(N * sizeof(double)), free); |
Contributor
There was a problem hiding this comment.
Q: why don't you just use new/delete? Or std::make_unique
Simplify host buffer management in STF C API tests per review feedback: use std::vector instead of std::unique_ptr<void, decltype(&free)> with custom deleters. Keeps unique_ptr for CUDA allocations (cudaMalloc, cudaMallocHost) where std::vector is not applicable. Made-with: Cursor
caugonnet
reviewed
Apr 7, 2026
| float* X = (float*) malloc(N * sizeof(float)); | ||
| float* Y = (float*) malloc(N * sizeof(float)); | ||
| float* Z = (float*) malloc(N * sizeof(float)); | ||
| [[maybe_unused]] std::vector<float> X(N); |
Tokens don't require backing buffers, so the vectors (and N) were dead code. Made-with: Cursor
Contributor
|
/ok to test fa10313 |
Contributor
🥳 CI Workflow Results🟩 Finished in 25m 48s: Pass: 100%/7 | Total: 38m 24s | Max: 25m 48s | Hits: 98%/720See results here. |
gonidelis
pushed a commit
to gonidelis/cccl
that referenced
this pull request
Apr 8, 2026
…uda_kernel (NVIDIA#8290) * STF test: RAII for cuda_kernel axpy host buffers Use std::unique_ptr<void, decltype(&free)> for X/Y malloc buffers so REQUIRE failures do not leak memory (review feedback). Made-with: Cursor * Use RAII for host allocations in STF Catch2 tests Wrap malloc (and cudaMallocHost/cudaFree paths) in unique_ptr with appropriate deleters so failed REQUIRE does not leak memory. Extends the pattern from test_cuda_kernel to logical_data, logical_data_with_place, places, task, and token tests. Made-with: Cursor * Replace unique_ptr<void> RAII wrappers with std::vector Simplify host buffer management in STF C API tests per review feedback: use std::vector instead of std::unique_ptr<void, decltype(&free)> with custom deleters. Keeps unique_ptr for CUDA allocations (cudaMalloc, cudaMallocHost) where std::vector is not applicable. Made-with: Cursor * Remove unused allocations from test_token.cpp Tokens don't require backing buffers, so the vectors (and N) were dead code. Made-with: Cursor --------- Co-authored-by: Cedric AUGONNET <caugonnet@nvidia.com> Co-authored-by: Cédric Augonnet <158148890+caugonnet@users.noreply.github.com>
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.
Follow-up from merged STF C API work: address review feedback on
test_cuda_kernel.cu.Wrap the host
mallocbuffers for the axpy test instd::unique_ptr<void, decltype(&free)>soREQUIREfailures cannot leak memory. Remove explicitfree(X)/free(Y)at the end of the test.Includes
REQUIREthat allocation succeeded (get() != nullptr).Made with Cursor