NVIDIA/cccl

[FEA]: Add out of bound assertion to cuda::std::mdspan on operator()

Closed this issue · 2 comments

Is this a duplicate?

Area

Thrust

Is your feature request related to a problem? Please describe.

cuda::std::mdspan doesn't trigger, in debug, an assertion when an out of bound access is performed via operator(), contrary to cuda::std::span (with its operator[]).

Describe the solution you'd like

cuda::std::mdspan should trigger an assertion, in debug, in both host and device just like cuda::std::span.

We will also have to update the following: https://github.com/NVIDIA/cccl/blob/main/docs/libcudacxx/standard_api/container_library/mdspan.rst

Describe alternatives you've considered

Using cuda::std::span but we want to promote cuda::std::mdspan as a safe multi-dimensional accessor

Additional context

Came in a discussion with @bernhardmgruber on slack. The goal is for it to be used in the "The Modern CUDA Developer’s Toolbox" future blogpost.

@fbusato since you are working on mdspan at the moment, maybe you have time to add an assertion to operator() and operator[].

@fbusato it seems @miscco was faster.