NVIDIA / NVIDIA/cccl

[FEA]: Provide `cuda::std::constant_wrapper`

Open
#9,108 0 comments 0 reactions 1 assignee Claimed by @davebayer View on GitHub
Dominant language
C++
Stars
2.5k
Forks
487
Avg merge
2d 7h
Merged PRs (30d)
296

Description

`std::constant_wrapper` is a fancy wrapper for constant values introduced in C++26 that tries to act like it's the original type. It could be useful in cases you want to have 1 generic kernel to which you'd like to either a constant or a value.

This is a generally useful utility. I would also suppose that more `std::` APIs would take the constant wrapper as a parameter in the future. It's already part of `std::function_ref` design.

This issue can be closed by fully implementing the `cuda::std::constant_wrapper` in libcu++. The implementation is not too complicated, but for our project, there are some challenges we need to deal with:
1. Compiler bugs. The implementation uses features that were not that popular, thus less used, thus less explored, thus less bugs were found.
2. Passing the type from host to device, making sure we don't access host memory from device.

#### Blocking nvbugs
- 6139224, no workaround found yet, clang-cuda is fine with the code
- 6207656, needs to be resolved, clang-cuda is fine with the code

#### Other reported nvbugs
- 6183205, workaround: using SFINAE instead of concepts
- 6183211, workaround: using `decltype(constant_wrapper<__cw_fixed_value(X op= Y)>{})`

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.