Skip to content

Store any_resource in device-resource global mapping - #2200

Merged
rapids-bot[bot] merged 3 commits into
rapidsai:mainfrom
bdice:device-ref-map-any-resource
Jan 10, 2026
Merged

rapids-bot[bot] merged 3 commits into
rapidsai:mainfrom
bdice:device-ref-map-any-resource

Conversation

@bdice

@bdice bdice commented Jan 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Part of #2011.

  • Change the per-device resource ref map to store cuda::mr::any_resource<device_accessible> instead of device_async_resource_ref
  • This provides ownership semantics - the global map now owns the stored resources
  • Added conversion operator and constructor in cccl_async_resource_ref to support conversion to/from any_resource

Notes

Refs returned from get_per_device_resource_ref() and set_per_device_resource_ref() now point to the owned copy inside any_resource, not the original object. Tests updated to verify functional correctness rather than ref identity.

Test plan

  • RMM tests pass locally
  • cuDF tests pass locally
  • rapidsmpf tests pass locally
  • RAFT tests pass locally
  • cuML tests pass locally

Change the per-device resource ref map to store
`cuda::mr::any_resource<device_accessible>` instead of
`device_async_resource_ref`. This provides ownership semantics -
the global map now owns the stored resources.

Key changes:
- `get_ref_map()` now returns map with `any_resource` values
- `set_per_device_resource_ref()` reifies incoming refs to `any_resource`
- `get_per_device_resource_ref()` returns refs from stored `any_resource`
- Added conversion operator and constructor in `cccl_async_resource_ref`
  to support conversion to/from `any_resource`

Note: Refs returned from get/set operations now point to the owned
copy inside `any_resource`, not the original object. Tests updated
to verify functional correctness rather than ref identity.
@bdice
bdice requested a review from a team as a code owner January 7, 2026 23:33
@bdice
bdice requested review from miscco and vyasr January 7, 2026 23:33
@bdice bdice mentioned this pull request Jan 7, 2026
51 tasks done
@bdice bdice added feature request New feature or request non-breaking Non-breaking change labels Jan 9, 2026
@bdice bdice moved this to In Progress in RMM Project Board Jan 9, 2026
@bdice bdice self-assigned this Jan 9, 2026
@bdice

bdice commented Jan 10, 2026

Copy link
Copy Markdown
Collaborator Author

/merge

@rapids-bot
rapids-bot Bot merged commit ddd4d57 into rapidsai:main Jan 10, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in RMM Project Board Jan 10, 2026
rapids-bot Bot pushed a commit that referenced this pull request Jan 12, 2026
## Summary

Part of #2011.

This PR adopts `any_resource` in `device_buffer` and `device_uvector`.

- Change `device_buffer::_mr` from `device_async_resource_ref` to `cuda::mr::any_resource<cuda::mr::device_accessible>`
- Make `memory_resource()` non-const on `device_buffer` and `device_uvector` (required because CCCL's `resource_ref` can only be constructed from non-const `any_resource&`)
- Use `std::move` for `_mr` in move constructor and move assignment

This ensures `device_buffer` owns its memory resource, preventing use-after-free if the original resource is destroyed while the buffer still exists.

## Stacked PR

This PR is stacked on top of #2200. To view only the changes in this PR:
bdice/rmm@device-ref-map-any-resource...containers-any-resource

## Test plan

- [x] RMM C++ tests pass locally
- [x] cuDF C++ tests pass locally

Authors:
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - Yunsong Wang (https://github.com/PointKernel)

URL: #2201
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request New feature or request non-breaking Non-breaking change

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants