[FEA] Fix improper usage of relaxed constexpr in cudf spans #17797
Labels
feature request
New feature or request
good first issue
Good for newcomers
libcudf
Affects libcudf (C++/CUDA) code.
Is your feature request related to a problem? Please describe.
Related to #7795
While working on #17746, we noticed that some libcudf code depends on relaxed
constexpr
in bothspan
and2dspan
(#17746 (comment)), e.g.cudf/cpp/src/io/parquet/writer_impl.cu
Line 1971 in bbf4f78
The above code is trying to access a device span from the host side and this should be done alternatively.
Describe the solution you'd like
For both
span
and2dspan
, the[]
operator should be restricted to either host-only or device-only usage. However, it is valid to obtain a pointer to device storage on the host and vice versa. Therefore, instead of using the[]
operator, users should access the storage pointer throughdata()
. In the case of2dspan
,flat_view
serves a similar purpose asdata
does in 1D spans. To align with this naming pattern, we should introduce a new API calledflat_index
.This approach allows us to address the aforementioned improper usage and make similar adjustments in other instances where the
[]
operator is misused.Describe alternatives you've considered
Alternatively, we could follow the STL approach by introducing a mapping to our
2dspan
for calculating the "flat index." However, since our2dspan
is not designed as a general-purpose solution likemdspan
, it might be more appropriate to refactor the existingflat_view
to align with data_handle if we choose this direction. That said, replicating the full complexity of a general-purpose implementation may not worth the effort.The text was updated successfully, but these errors were encountered: