NVIDIA / NVIDIA/cccl

[FEA]: Cast any_resource to underlying type

Open
#7,994 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.5k
Forks
486
Avg merge
2d 6h
Merged PRs (30d)
295

Description

### Is this a duplicate?

- [x] I confirmed there appear to be no [duplicate issues](https://github.com/NVIDIA/cccl/issues) for this request and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)

### Area

libcu++

### Is your feature request related to a problem? Please describe.

With RMM memory resources (prior to adopting CCCL's memory resource design), we can dynamic-cast a `device_memory_resource*` to determine if the MR is of a given type (e.g. a pool memory resource). Today there isn't a way to do the equivalent of a dynamic-cast to find what type is contained in a `resource_ref` or `any_resource`.

Examples of current usage of `dynamic_cast` of RMM memory resources:

https://github.com/rapidsai/cuvs/blob/53879fd1ece6c027435b16de5307e684bd44cc81/c/src/core/c_api.cpp#L159-L164

https://github.com/rapidsai/raft/blob/3d64833ed00fb472c8f8cd366f53d0d7e4efa494/cpp/include/raft/core/device_resources_manager.hpp#L160-L173

https://github.com/rapidsai/rapidsmpf/blob/0e90bd98bb9b2a9026ad4dd6277ae2ae59c9d707/cpp/src/rmm_resource_adaptor.cpp#L125-L128

https://github.com/NVIDIA/cuCascade/blob/c32d144b94d7b27502d402284ac909904cd550d3/include/cucascade/memory/memory_reservation.hpp#L223-L228

### Describe the solution you'd like

@pciolkosz mentioned that `cuda::__any_cast(&obj)` exists, but it is private. This might solve our needs, if it were promoted to a public API.

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.