[libcu++] Add resource_cast and dynamic_resource_cast#8272
[libcu++] Add resource_cast and dynamic_resource_cast#8272pciolkosz wants to merge 8 commits intoNVIDIA:mainfrom
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. |
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