Skip to content

Migrate device memory resource headers - #2140

Merged
rapids-bot[bot] merged 7 commits into
rapidsai:mainfrom
bdice:migrate-memory-resources
Nov 13, 2025
Merged

rapids-bot[bot] merged 7 commits into
rapidsai:mainfrom
bdice:migrate-memory-resources

Conversation

@bdice

@bdice bdice commented Nov 12, 2025 •

Copy link
Copy Markdown
Collaborator

Description

This PR reorganizes the RMM header structure by moving all device memory resource headers from cpp/include/rmm/mr/device/ to cpp/include/rmm/mr/. This change simplifies the header hierarchy and improves the developer experience by reducing nested directory structures.

This implements a proposal from #2103 to flatten the memory resource hierarchy, because host and device are no longer meaningful distinctions as we adopt the CCCL memory resource design (#2011).

The vast majority of this PR is purely code movement. The only meaningful changes are adding deprecation warnings to the old header locations that can be controlled with the CMake option (or preprocessor definition) RMM_DEPRECATE_MR_DEVICE_HEADERS.

Changes Made

1. Header Files Moved (30 files)

Main headers moved from cpp/include/rmm/mr/device/ → cpp/include/rmm/mr/:

  • aligned_resource_adaptor.hpp
  • arena_memory_resource.hpp
  • binning_memory_resource.hpp
  • callback_memory_resource.hpp
  • cuda_async_managed_memory_resource.hpp
  • cuda_async_memory_resource.hpp
  • cuda_async_view_memory_resource.hpp
  • cuda_memory_resource.hpp
  • device_memory_resource.hpp
  • failure_callback_resource_adaptor.hpp
  • fixed_size_memory_resource.hpp
  • limiting_resource_adaptor.hpp
  • logging_resource_adaptor.hpp
  • managed_memory_resource.hpp
  • owning_wrapper.hpp
  • per_device_resource.hpp
  • polymorphic_allocator.hpp
  • pool_memory_resource.hpp
  • prefetch_resource_adaptor.hpp
  • sam_headroom_memory_resource.hpp
  • statistics_resource_adaptor.hpp
  • system_memory_resource.hpp
  • thread_safe_resource_adaptor.hpp
  • thrust_allocator_adaptor.hpp
  • tracking_resource_adaptor.hpp

Detail headers moved from cpp/include/rmm/mr/device/detail/ → cpp/include/rmm/mr/detail/:

  • arena.hpp
  • coalescing_free_list.hpp
  • fixed_size_free_list.hpp
  • free_list.hpp
  • stream_ordered_memory_resource.hpp

2. Backward Compatibility (30 forwarding headers)

Created deprecated forwarding headers in cpp/include/rmm/mr/device/ that:

  • Include the new header locations
  • Emit compiler warnings: "rmm/mr/device/[header].hpp is deprecated in 25.12 and will be removed in 26.02. Use rmm/mr/[header].hpp instead."
  • Ensure existing code continues to compile with deprecation warnings

3. Include Path Updates

Updated all include statements throughout the codebase (53 occurrences across 23 files):

  • C++ source files: cpp/benchmarks/, cpp/examples/, cpp/tests/
  • Python bindings: python/rmm/rmm/librmm/_torch_allocator.cpp
  • Public API headers: device_buffer.hpp, device_scalar.hpp, device_uvector.hpp, device_vector.hpp, exec_policy.hpp
  • Test utilities: device_check_resource_adaptor.hpp, mock_resource.hpp

Changed from: #include <rmm/mr/device/xxx.hpp>
Changed to: #include <rmm/mr/xxx.hpp>

4. Test Directory Reorganization (22 files)

Moved test files from cpp/tests/mr/device/ → cpp/tests/mr/:

  • All device memory resource test files (.cpp and .cu)
  • Test helper headers (mr_ref_test.hpp, test_utils.hpp)
  • Updated relative includes from ../../ to ../
  • Updated cpp/tests/CMakeLists.txt with new test file paths (20 ConfigureTest entries)

5. Python/Cython Bindings (3 files)

Updated Cython declaration files with new header paths (23 total header references):

  • python/rmm/rmm/librmm/memory_resource.pxd (20 headers)
  • python/rmm/rmm/librmm/per_device_resource.pxd (2 headers)
  • python/rmm/rmm/librmm/device_buffer.pxd (1 header)

Migration Guide

Old code (still works with deprecation warning):

#include <rmm/mr/device/cuda_memory_resource.hpp>
#include <rmm/mr/device/pool_memory_resource.hpp>

New code (recommended):

#include <rmm/mr/cuda_memory_resource.hpp>
#include <rmm/mr/pool_memory_resource.hpp>

Deprecation Timeline

  • 25.12: Old paths deprecated, forwarding headers emit warnings
  • 26.02: Old paths (forwarding headers) will be removed

Impact

  • Breaking change: No (backward compatible via forwarding headers)
  • Build impact: Deprecation warnings will appear for code using old paths
  • Runtime impact: None
  • API changes: None (only file locations changed)

cpp/include/rmm/mr/host/ is already deprecated in 25.12, pending deletion in 26.02, so it has not been modified.

Testing

All existing tests pass with the new header structure. The forwarding headers ensure backward compatibility during the deprecation period.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@copy-pr-bot

copy-pr-bot Bot commented Nov 12, 2025

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 added non-breaking Non-breaking change improvement Improvement / enhancement to an existing function labels Nov 12, 2025
@bdice

bdice commented Nov 12, 2025

Copy link
Copy Markdown
Collaborator Author

I'll be opening this for review as soon as I finish testing a build with all of RAPIDS.

@bdice
bdice marked this pull request as ready for review November 12, 2025 20:02
@bdice
bdice requested review from a team as code owners November 12, 2025 20:02
@bdice
bdice requested review from lamarrr and miscco November 12, 2025 20:02

@miscco miscco left a comment

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.

Looks great to me

@bdice bdice self-assigned this Nov 13, 2025
@bdice bdice moved this to In Progress in RMM Project Board Nov 13, 2025
@bdice

bdice commented Nov 13, 2025

Copy link
Copy Markdown
Collaborator Author

/merge

@rapids-bot
rapids-bot Bot merged commit 71ea3e5 into rapidsai:main Nov 13, 2025
@github-project-automation github-project-automation Bot moved this from In Progress to Done in RMM Project Board Nov 13, 2025
rapids-bot Bot pushed a commit that referenced this pull request Nov 18, 2025
Removes deprecated device memory resources in `<rmm/mr/device/...>`. Users should use `<rmm/mr/...>` instead.

Closes #2141. Follows up on #2140.

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

Approvers:
  - Vyas Ramasubramani (https://github.com/vyasr)
  - Lawrence Mitchell (https://github.com/wence-)

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

Labels

improvement Improvement / enhancement to an existing function non-breaking Non-breaking change

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants