[FEA] Migrate libcudf to use (cuda::)std::span and remove custom span implementations
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
**Is your feature request related to a problem? Please describe.**
Currently, libcudf maintains custom `host_span` and `device_span` implementations to emulate the behavior of `std::span` and `cuda::std::span` because:
1. libcudf was previously on C++17, which lacks `std::span`.
2. CCCL did not provide `cuda::std::span` at the time.
3. Some custom functionality, such as making `host_span` accessible from the device for efficient copy operations, is not supported by the standard spans.
4. Automatic construction from non-standard containers like `thrust::host_vector`, `rmm::device_uvector`, or `column_view` is not supported by standard spans.
This leads to additional maintenance burden and complexity in the codebase.
**Describe the solution you'd like**
1. **Device span:**
* Replace `cudf::device_span` with `cuda::std::span` throughout libcudf.
* Remove the custom `device_span` implementation entirely.
2. **Host span:**
* Refactor `host_span` to use `cuda::std::span` internally.
* Retain any necessary custom logic to support device-accessible host spans for copy engine optimizations.
* Remove `span_base` if it is no longer needed once `device_span` is removed.
3. **Auto-construction from containers:**
* Introduce conversion operators in upstream projects (CCCL, RMM) as well as in libcudf for container types like `thrust::host_vector`, `rmm::device_uvector`, and `column_view` to enable seamless construction of spans:
* https://github.com/rapidsai/rmm/pull/2132
**Describe alternatives you've considered**
* Keeping the current custom span implementations: this preserves all current features but continues the maintenance burden and prevents using standard utilities.
* Using only `std::span`/`cuda::std::span` without addressing `host_span` device-access: this simplifies the code but loses the optimization for device copy engine.
* Incremental migration: replacing `device_span` first while keeping `host_span` custom logic until upstream projects support conversion operators for containers.
* Implicit conversion from custom containers: one could argue that conversion operators to allow automatic span construction risks unintended implicit conversions. A safer alternative is to provide explicit member functions (e.g., `.span()` or `.device_span()`) or free helper functions (`to_span(container)`), which allow easy span construction without implicit conversion risks.
Contributor guide
Assessment
This issue has not been assessed yet.