Skip to content

Refactor tracking, statistics, and aligned resource adaptors to shared CCCL MR design - #2265

Merged
bdice merged 2 commits into
rapidsai:stagingfrom
bdice:detemplate-tier2-adaptors
Feb 26, 2026
Merged

bdice merged 2 commits into
rapidsai:stagingfrom
bdice:detemplate-tier2-adaptors

Conversation

@bdice

@bdice bdice commented Feb 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Converts tracking_resource_adaptor, statistics_resource_adaptor, and aligned_resource_adaptor from header-only class templates to non-template classes backed by a detail::*_impl held via cuda::mr::shared_resource, following the pattern established by logging_resource_adaptor (#2246).

Part of #2011.

Changes

New files

  • cpp/include/rmm/mr/detail/tracking_resource_adaptor_impl.hpp
  • cpp/include/rmm/mr/detail/statistics_resource_adaptor_impl.hpp
  • cpp/include/rmm/mr/detail/aligned_resource_adaptor_impl.hpp
  • cpp/src/mr/detail/tracking_resource_adaptor_impl.cpp
  • cpp/src/mr/detail/statistics_resource_adaptor_impl.cpp
  • cpp/src/mr/detail/aligned_resource_adaptor_impl.cpp
  • cpp/src/mr/tracking_resource_adaptor.cpp
  • cpp/src/mr/statistics_resource_adaptor.cpp
  • cpp/src/mr/aligned_resource_adaptor.cpp
  • cpp/tests/mr/mr_ref_tracking_tests.cpp — CcclMrRefTest / CcclMrRefAllocationTest / CcclMrRefTestMT instantiations
  • cpp/tests/mr/mr_ref_statistics_tests.cpp — same
  • cpp/tests/mr/mr_ref_aligned_tests.cpp — CcclMrRefTest / CcclMrRefAllocationTest

Modified files

  • Public headers de-templated, private shared_resource inheritance, get_property friend, static_assert concept check
  • cpp/CMakeLists.txt — new .cpp sources added
  • cpp/tests/CMakeLists.txt — TRACKING_MR_REF_TEST, STATISTICS_MR_REF_TEST, ALIGNED_MR_REF_TEST targets
  • cpp/tests/mr/adaptor_tests.cpp — removed template/pointer-based aligned tests, updated owning_wrapper to use limiting_resource_adaptor
  • cpp/tests/mr/tracking_mr_tests.cpp, statistics_mr_tests.cpp, aligned_mr_tests.cpp — template aliases removed, null/pointer constructions replaced, stacked-adaptor tests use device_async_resource_ref{mr} to avoid copy-construction
  • cpp/tests/mr/cccl_adaptor_tests.cpp — all three new adaptors added to the typed shared-ownership suite
  • python/rmm/rmm/librmm/memory_resource.pxd — template parameters removed from statistics_resource_adaptor and tracking_resource_adaptor
  • python/rmm/rmm/pylibrmm/memory_resource/_memory_resource.pyx — template instantiation syntax removed

Checklist

  • Create detail/*_impl.hpp (class declaration)
  • Create src/mr/detail/*_impl.cpp (member definitions)
  • Create src/mr/*_adaptor.cpp (outer class definitions)
  • Modify public headers (de-template, private inheritance, get_property, static_assert)
  • Update CMakeLists.txt
  • Update Cython .pxd and .pyx
  • Update tests (remove template instantiation, add non-template fixtures)
  • pre-commit run --all-files
  • build-rmm-cpp -j0 && test-rmm-cpp

…d CCCL MR design

Converts tracking_resource_adaptor, statistics_resource_adaptor, and
aligned_resource_adaptor from header-only class templates to non-template
classes backed by detail::*_impl held via cuda::mr::shared_resource,
following the pattern established by logging_resource_adaptor (rapidsai#2246).

Part of rapidsai#2011.
@copy-pr-bot

copy-pr-bot Bot commented Feb 26, 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.

@bdice

bdice commented Feb 26, 2026

Copy link
Copy Markdown
Collaborator Author

/ok to test

* @brief Construct an aligned resource adaptor using `upstream` to satisfy allocation requests.
*
* @throws rmm::logic_error if `alignment` is not a power of 2
* @brief Compare two adaptors for equality (shared-impl identity).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Once the legacy code is removed, any remaining equality operators should probably say they have the same upstream and adaptor state -- or something that is simpler than the impl identity.

Comment thread cpp/tests/mr/adaptor_tests.cpp Outdated
static_assert(rmm::detail::polyfill::resource_with<rmm::mr::tracking_resource_adaptor<cuda_mr>,
cuda::mr::device_accessible>);

// static property checks — converted (non-template) adaptors

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These tests need to move to cccl_adaptor_tests.cpp.

@bdice bdice self-assigned this Feb 26, 2026
@bdice bdice added breaking Breaking change improvement Improvement / enhancement to an existing function labels Feb 26, 2026
@bdice bdice moved this to In Progress in RMM Project Board Feb 26, 2026
@bdice
bdice marked this pull request as ready for review February 26, 2026 17:54
@bdice
bdice requested review from a team as code owners February 26, 2026 17:54
@bdice
bdice requested review from harrism and rongou and removed request for a team February 26, 2026 17:54
@bdice

bdice commented Feb 26, 2026

Copy link
Copy Markdown
Collaborator Author

I'm going to merge this once CI passes. I self-reviewed and this follows the same patterns as the other CCCL MR migrations.

@bdice
bdice merged commit 7cf928a into rapidsai:staging Feb 26, 2026
77 of 79 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in RMM Project Board Feb 26, 2026
bdice added a commit that referenced this pull request Mar 6, 2026
## Summary

- De-template `arena_memory_resource` by removing the `Upstream`
template parameter
- Split implementation into `detail::arena_memory_resource_impl` held
via `cuda::mr::shared_resource` for reference-counted, copyable
ownership
- Retain the `device_memory_resource` legacy compatibility layer
(`do_allocate`, `do_deallocate`, `do_is_equal`)
- Update benchmarks, C++ tests, and Python (Cython) bindings to use the
non-template `arena_memory_resource`

This follows the same pattern established in #2246, #2258, #2264, and
#2265 for the other memory resources.

### New files

| File | Contents |
|------|----------|
| `cpp/include/rmm/mr/detail/arena_memory_resource_impl.hpp` |
`detail::arena_memory_resource_impl` class declaration |
| `cpp/src/mr/detail/arena_memory_resource_impl.cpp` | Impl member
function definitions |
| `cpp/src/mr/arena_memory_resource.cpp` | Outer class constructor +
delegating method definitions |

### Modified files

| File | Change |
|------|--------|
| `cpp/include/rmm/mr/arena_memory_resource.hpp` | De-template,
`shared_resource` wrapping |
| `cpp/CMakeLists.txt` | Add new `.cpp` source files |
| `cpp/tests/mr/arena_mr_tests.cpp` |
`arena_memory_resource<device_memory_resource>` →
`arena_memory_resource` |
| `cpp/tests/mr/mr_ref_arena_tests.cpp` | Add `ArenaMRFixture` +
`CcclMrRefTest`/`CcclMrRefAllocationTest`/`CcclMrRefTestMT`
instantiations |
| `cpp/tests/mr/mr_ref_test.hpp` | Update `make_arena()` and `arena_mr`
type alias |
| `cpp/tests/mr/cccl_adaptor_tests.cpp` | Add arena `static_assert` +
`ArenaMRAdaptorTest` |
|
`cpp/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu`
| Update `make_arena()` |
| `cpp/benchmarks/random_allocations/random_allocations.cpp` | Update
`make_arena()` |
| `cpp/benchmarks/replay/replay.cpp` | Update `make_arena()` |
| `python/rmm/rmm/librmm/memory_resource.pxd` | Remove `[Upstream]`
template from `arena_memory_resource` |
| `python/rmm/rmm/pylibrmm/memory_resource/_memory_resource.pyx` |
Remove template instantiation syntax for arena |
@bdice bdice mentioned this pull request Mar 10, 2026
51 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaking change improvement Improvement / enhancement to an existing function

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants