Skip to content

[TRIVIAL] Review fixup for #8266: RAII malloc buffers in test_cuda_kernel#8290

Merged
caugonnet merged 5 commits intoNVIDIA:mainfrom
andralex:fix/stf-cuda-kernel-test-malloc-raii
Apr 7, 2026
Merged

[TRIVIAL] Review fixup for #8266: RAII malloc buffers in test_cuda_kernel#8290
caugonnet merged 5 commits intoNVIDIA:mainfrom
andralex:fix/stf-cuda-kernel-test-malloc-raii

Conversation

@andralex
Copy link
Copy Markdown
Contributor

@andralex andralex commented Apr 3, 2026

Follow-up from merged STF C API work: address review feedback on test_cuda_kernel.cu.

Wrap the host malloc buffers for the axpy test in std::unique_ptr<void, decltype(&free)> so REQUIRE failures cannot leak memory. Remove explicit free(X) / free(Y) at the end of the test.

Includes REQUIRE that allocation succeeded (get() != nullptr).

Made with Cursor

Use std::unique_ptr<void, decltype(&free)> for X/Y malloc buffers so
REQUIRE failures do not leak memory (review feedback).

Made-with: Cursor
@andralex andralex requested a review from a team as a code owner April 3, 2026 22:00
@andralex andralex requested a review from NaderAlAwar April 3, 2026 22:00
@github-project-automation github-project-automation bot moved this to Todo in CCCL Apr 3, 2026
@copy-pr-bot
Copy link
Copy Markdown
Contributor

copy-pr-bot bot commented Apr 3, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@cccl-authenticator-app cccl-authenticator-app bot moved this from Todo to In Review in CCCL Apr 3, 2026
@andralex andralex changed the title STF C test: RAII malloc buffers in test_cuda_kernel [TRIVIAL] Review fixup for #8266: RAII malloc buffers in test_cuda_kernel Apr 3, 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);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: Can't these just be std::vector to avoid the custom logic here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm going to vote for this option too, and avoid all complicated stuffs

@caugonnet caugonnet added the stf Sequential Task Flow programming model label Apr 6, 2026
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

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);
Copy link
Copy Markdown
Contributor

@davebayer davebayer Apr 7, 2026

Choose a reason for hiding this comment

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

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
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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is actually unused

caugonnet and others added 2 commits April 7, 2026 22:16
Tokens don't require backing buffers, so the vectors (and N) were dead code.

Made-with: Cursor
@caugonnet
Copy link
Copy Markdown
Contributor

/ok to test fa10313

@caugonnet caugonnet enabled auto-merge (squash) April 7, 2026 20:18
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

🥳 CI Workflow Results

🟩 Finished in 25m 48s: Pass: 100%/7 | Total: 38m 24s | Max: 25m 48s | Hits: 98%/720

See results here.

@caugonnet caugonnet merged commit 9a243e3 into NVIDIA:main Apr 7, 2026
24 of 26 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stf Sequential Task Flow programming model

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants