[libcu++] Add resource_cast and dynamic_resource_cast - #8272
Conversation
|
I did a bit of comparison between #8269 and this PR.
|
This comment has been minimized.
This comment has been minimized.
I added static_asserts inside
I think its fine
Added test cases
I think because we also have the |
This comment has been minimized.
This comment has been minimized.
- resource_cast: explicitly static_cast to __basic_any base before calling __any_cast, working around GCC < 11 inability to deduce template arguments from derived-to-base class conversions. - basic_any test: change test_iset_dynamic_cast from _CCCL_HOST to _CCCL_HOST_DEVICE so NVRTC can compile the file.
ClangCUDA compiles _CCCL_HOST_DEVICE functions for both host and device. The try/catch code behind _CCCL_HAS_EXCEPTIONS() was included on device, causing a compilation failure. Wrap with NV_IF_TARGET to restrict it to the host path.
Replace the NV_IF_TARGET approach (which used #if inside a macro argument, breaking MSVC) with #if \!_CCCL_COMPILER(NVRTC) guards around the _CCCL_HOST function and its call site.
75c9ced to
a49f8ca
Compare
The _CCCL_HOST function was called from main outside NV_IF_TARGET, causing a host function call from the device path under nvcc.
Move #if outside NV_IF_TARGET by using a separate NV_IF_TARGET call for test_iset_dynamic_cast, guarded by #if \!_CCCL_COMPILER(NVRTC).
🥳 CI Workflow Results🟩 Finished in 1h 20m: Pass: 100%/108 | Total: 1d 01h | Max: 57m 36s | Hits: 99%/281525See results here. |
* Add resource_cast and dynamic_resource_cast * Fix format * Review feedback * Fix GCC < 11 and NVRTC build failures - resource_cast: explicitly static_cast to __basic_any base before calling __any_cast, working around GCC < 11 inability to deduce template arguments from derived-to-base class conversions. - basic_any test: change test_iset_dynamic_cast from _CCCL_HOST to _CCCL_HOST_DEVICE so NVRTC can compile the file. * Fix ClangCUDA: guard try/catch with NV_IF_TARGET ClangCUDA compiles _CCCL_HOST_DEVICE functions for both host and device. The try/catch code behind _CCCL_HAS_EXCEPTIONS() was included on device, causing a compilation failure. Wrap with NV_IF_TARGET to restrict it to the host path. * Fix MSVC: guard test_iset_dynamic_cast with NVRTC check Replace the NV_IF_TARGET approach (which used #if inside a macro argument, breaking MSVC) with #if \!_CCCL_COMPILER(NVRTC) guards around the _CCCL_HOST function and its call site. * Fix: move test_iset_dynamic_cast call inside NV_IF_TARGET The _CCCL_HOST function was called from main outside NV_IF_TARGET, causing a host function call from the device path under nvcc. * Fix MSVC: no preprocessor directives inside macro arguments Move #if outside NV_IF_TARGET by using a separate NV_IF_TARGET call for test_iset_dynamic_cast, guarded by #if \!_CCCL_COMPILER(NVRTC).
This PR updates CCCL to the latest 3.4.0 pre-release commit. Comparison of CCCL commits: NVIDIA/cccl@c5594eb...c936ad8 We specifically need these features/fixes for RAPIDS projects: - NVIDIA/cccl#8353 - NVIDIA/cccl#8272 - NVIDIA/cccl#8320 - NVIDIA/cccl#8486 Authors: - Niranda Perera (https://github.com/nirandaperera) - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) URL: #1008
This PR adds
resource_castanddynamic_resource_castwrapper for internal__any_castand__dynamic_any_castspecialized for resource wrappers.I also added validation to
__dynamic_any_castimplementation, which was right now succeeding regardless of what the destination interface was. Now it confirms destination interface is a subset of the original vtable. Tests were added to__basic_anytesting to confirm this behavior