mdspan icon indicating copy to clipboard operation
mdspan copied to clipboard

mdarray: Apply no_unique_address optimization to members of mdarray

Open mhoemmen opened this issue 3 years ago • 0 comments

@johan-overbye reports that:

mdarrays with all static extents seem to require an extra 4 bytes on top of the container. (Latest MSVC for x86-64 with /std:c++latest.)

The reference implementation of mdarray doesn't currently use any of various techniques (such as [[no_unique_address]]) for not using space for members with no data,

https://github.com/kokkos/mdspan/blob/9ccf361e13dcc3bff2791fda327c2b10e081cb12/include/experimental/__p1684_bits/mdarray.hpp#L454

but the reference implementation of mdspan uses a "compressed pair" abstraction for this purpose.

  • https://github.com/kokkos/mdspan/blob/9ccf361e13dcc3bff2791fda327c2b10e081cb12/include/experimental/__p0009_bits/mdspan.hpp#L116

  • https://github.com/kokkos/mdspan/blob/9ccf361e13dcc3bff2791fda327c2b10e081cb12/include/experimental/__p0009_bits/mdspan.hpp#L380

We should consider using this abstraction for mdarray as well.

mhoemmen avatar Aug 01 '22 15:08 mhoemmen