Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of no_unique_address #7

Closed
dhollman opened this issue Sep 3, 2019 · 5 comments
Closed

Backport of no_unique_address #7

dhollman opened this issue Sep 3, 2019 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@dhollman
Copy link
Contributor

dhollman commented Sep 3, 2019

Right now, on non-C++20 compilers, mdspan and other parts of the implementation are space inefficient because the [[no_unique_address]] (written as _MDSPAN_NO_UNIQUE_ADDRESS) does nothing. We need to find a way to backport to the EBO version of no_unique_address without introducing overhead on the newer compilers (and without going crazy with bifurcating the implementation using #ifdefs).

@dhollman dhollman self-assigned this Sep 3, 2019
@dhollman dhollman added the enhancement New feature or request label Sep 3, 2019
@nliber
Copy link
Contributor

nliber commented Sep 3, 2019

Both libc++ and libstdc++ implement EBO for empty types in a tuple. One way to accomplish this is to use tuple and write private const and non-const getters to return references to the various members.

Just a thought...

@dhollman
Copy link
Contributor Author

dhollman commented Sep 3, 2019

Unfortunately, not all of the things we would want to use mdspan for have reliable support for tuple (e.g., Cuda, HIP). It's not much harder to just manually do this, but I just have to get around to doing it. Also, we need to make sure that this happens without increasing the cost to the inliner in the case of the modern attribute (even if we force inline, we have to be sure the extra layer of abstraction isn't adding to the compilers internal inlining limits for functions that use it).

@dhollman
Copy link
Contributor Author

dhollman commented Sep 3, 2019

Also, this strategy doesn't work transitively, since some of the uses of _MDSPAN_NO_UNIQUE_ADDRESS are on the only data member of the class template.

[[no_unique_address]] is quietly one of my favorite C++20 features, though maybe that's a sign I do way too much generic programming.

@crtrott
Copy link
Member

crtrott commented Sep 4, 2019

@dhollman yes and yes.
(it is a sign you do too much generic programming, but I also like this feature ;-) )

@dhollman
Copy link
Contributor Author

Done and merged (#19). There is still a bug with some things not being recognized as empty by some implementations, but I'll open a separate issue for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants