Skip to content

[FEA] Delete cccl_adaptors.hpp and use raw CCCL resource_ref types #2323

@bdice

Description

@bdice

Delete cccl_adaptors.hpp and use raw CCCL resource_ref types

Part of #2011. Depends on removal of bridge infrastructure (#2296).

Problem

After #2296, device_memory_resource and its bridge infrastructure are deleted,
but RMM still uses wrapper types from cccl_adaptors.hpp instead of CCCL's
native resource_ref and any_resource types directly. Three issues remain:

  1. cccl_adaptors.hpp still defines cccl_resource_ref<T> and
    cccl_async_resource_ref<T> wrappers that add an unnecessary indirection
    layer. With no DMR compatibility needed, these wrappers serve no purpose.

  2. CCCL #8037 recursive constraint cycle: When a class has a 1-arg
    constructor taking resource_ref or any_resource, checking
    is_move_constructible<Class> recurses infinitely. This must be fixed with
    SFINAE on 1-arg constructors before cccl_adaptors.hpp can be deleted.

  3. polymorphic_allocator and thrust_allocator store resource_ref
    internally but should store any_resource to be self-contained owning types.

Goal

After this work:

  • cccl_adaptors.hpp is deleted
  • resource_ref.hpp contains direct type aliases to CCCL types:
    using device_async_resource_ref = cuda::mr::resource_ref<cuda::mr::device_accessible>;
  • All 1-arg constructors taking resource_ref or any_resource use SFINAE to
    exclude the self type (CCCL #8037 workaround)
  • polymorphic_allocator and thrust_allocator store any_resource members
  • device_check_resource_adaptor stores any_resource member

Branch

delete-cccl-adaptors (based on delete-device-memory-resource)

9 commits (#2296's 5 + 4):

  • Commits from [FEA] Remove bridge infrastructure and device_memory_resource #2296 (see that issue)
  • cfbbaf13 Use template constructors with SFINAE to break CCCL #8037 recursive constraint cycle (49 files)
  • cfc294d1 Change polymorphic_allocator, thrust_allocator, and device_check_resource_adaptor to store any_resource members (4 files)
  • cf79ae18 Delete cccl_adaptors.hpp and use raw CCCL resource_ref types (4 files)
  • 8a3dfa67 Suppress nvcc host/device diagnostic in multi_stream_allocations benchmark (1 file)

Tasks

1. Add SFINAE to 1-arg constructors (CCCL #8037 workaround)

All memory resources with a 1-arg constructor taking resource_ref or
any_resource need a template SFINAE guard to exclude construction from the
self type, preventing infinite recursion in is_move_constructible checks.

49 files across cpp/include/rmm/mr/ and impl files.

Pattern:

// Before:
explicit arena_memory_resource(device_async_resource_ref upstream, ...);

// After:
template <typename T = device_async_resource_ref,
          std::enable_if_t<!std::is_same_v<std::remove_cvref_t<T>,
                                            arena_memory_resource>, int> = 0>
explicit arena_memory_resource(T&& upstream, ...);

2. Change allocators to store any_resource members

Files:

  • cpp/include/rmm/mr/polymorphic_allocator.hpp
  • cpp/tests/mr/thrust_allocator_tests.cu (thrust_allocator)
  • cpp/tests/device_check_resource_adaptor.hpp

These types currently store resource_ref (non-owning) internally. Change to
any_resource (owning) so they are self-contained.

3. Delete cccl_adaptors.hpp and simplify resource_ref.hpp

Files:

  • Delete cpp/include/rmm/detail/cccl_adaptors.hpp
  • Simplify cpp/include/rmm/resource_ref.hpp to direct CCCL type aliases
  • Update cpp/tests/mr/cccl_adaptor_tests.cpp

Replace all 6 type aliases:

RMM alias Final definition
device_resource_ref cuda::mr::synchronous_resource_ref<cuda::mr::device_accessible>
device_async_resource_ref cuda::mr::resource_ref<cuda::mr::device_accessible>
host_resource_ref cuda::mr::synchronous_resource_ref<cuda::mr::host_accessible>
host_async_resource_ref cuda::mr::resource_ref<cuda::mr::host_accessible>
host_device_resource_ref cuda::mr::synchronous_resource_ref<cuda::mr::host_accessible, cuda::mr::device_accessible>
host_device_async_resource_ref cuda::mr::resource_ref<cuda::mr::host_accessible, cuda::mr::device_accessible>

4. Suppress nvcc host/device diagnostic in .cu benchmark

File: cpp/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu

The any_resource internals use __host__ __device__ functions that call
shared_resource copy/move constructors which are __host__ only. Add
#pragma nv_diag_suppress 20011 since the factory functions are only called
from host code.

Validation

  • build-rmm-cpp -j0 succeeds (with -DBUILD_BENCHMARKS=ON)
  • All 103 C++ tests pass (test-rmm-cpp)
  • build-rmm-python -j0 succeeds
  • All 1781 Python tests pass (test-rmm-python)
  • grep -r cccl_adaptors cpp/ returns no results
  • grep -r cccl_resource_ref cpp/ returns no results
  • grep -r cccl_async_resource_ref cpp/ returns no results

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    To-do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions