Skip to content

Add memory resource control to valid_if - #23490

Draft
bdice wants to merge 1 commit into
rapidsai:mainfrom
bdice:test-mr-valid-if
Draft

Add memory resource control to valid_if#23490
bdice wants to merge 1 commit into
rapidsai:mainfrom
bdice:test-mr-valid-if

Conversation

@bdice

@bdice bdice commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Update cudf::detail::valid_if to accept cudf::memory_resources. The returned validity mask uses the output resource, and its temporary valid-count scalar uses the temporary resource.

This enables cudf::label_bins, the pilot API for temporary memory-resource control, to propagate separate output and temporary resources through validity-mask construction without falling back to the current device resource.

This is a non-breaking change for existing callers of valid_if.

Ref: #20780

Teach cudf::detail::valid_if to accept cudf::memory_resources so the allocation roles inside the helper can be controlled independently. The returned validity mask now uses the output resource, while the device scalar used to accumulate the valid count uses the temporary resource.

Replacing the former device_async_resource_ref parameter preserves existing source calls through memory_resources' implicit one-resource construction. Those callers retain the previous behavior: their supplied resource owns the returned mask and the current cuDF resource supplies temporary storage. Explicit two-resource callers can now avoid any fallback to global resource state.

Add focused bitmask tests using the reusable memory-resource harness. The non-empty case installs an allocation-failing current resource, verifies output allocation lifetime, confirms temporary allocation activity and release, and validates the generated mask. The empty case proves the explicit two-resource path remains allocation-free and does not query the current resource.

Validation performed:

- ninja -C cpp/build/latest BITMASK_TEST

- cpp/build/latest/gtests/BITMASK_TEST --gtest_filter='ValidIfTest.Explicit*'

- test-cudf-cpp -R BITMASK_TEST

- pre-commit run --all-files
@copy-pr-bot

copy-pr-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the libcudf Affects libcudf (C++/CUDA) code. label Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libcudf Affects libcudf (C++/CUDA) code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant