Skip to content

Use canonicalize slices in submdspan#457

Open
crtrott wants to merge 1 commit into
kokkos:stablefrom
crtrott:use-canonicalize-slice-in-submdspan
Open

Use canonicalize slices in submdspan#457
crtrott wants to merge 1 commit into
kokkos:stablefrom
crtrott:use-canonicalize-slice-in-submdspan

Conversation

@crtrott

@crtrott crtrott commented Jun 26, 2026

Copy link
Copy Markdown
Member

This is the last piece to be extracted from PR #408 to implement P3663. After this we need to introduce extent_slice.

#define MDSPAN_HAS_CXX_17 (MDSPAN_IMPL_CPLUSPLUS >= MDSPAN_CXX_STD_17)
#define MDSPAN_HAS_CXX_20 (MDSPAN_IMPL_CPLUSPLUS >= MDSPAN_CXX_STD_20)
#define MDSPAN_HAS_CXX_23 (MDSPAN_IMPL_CPLUSPLUS >= MDSPAN_CXX_STD_23)
#define MDSPAN_HAS_CXX_26 (MDSPAN_IMPL_CPLUSPLUS >= MDSPAN_CXX_STD_26)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this is for checking whether std::complex is tuple-like, should we consider having a finer-grained check? The feature test macro check would look like this,

(__cpp_lib_tuple_like >= 202311L)

as P2819 updated the value from 202207L.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, we might later want to use this macro for other C++26 features like parameter pack indexing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we could test more finely for the tuple-like I guess? But we can have the CXX26 thing anyway.

SliceSpecifiers... slices) {
const auto sub_submdspan_mapping_result = submdspan_mapping(src.mapping(), slices...);

// Avoid instantiating expensive slice mandate check here for known layouts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the known layouts just calling this function anyway? If so, then it might not be much more expensive to do it twice, since you've already instantiated the function once.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it actually caches that properly ...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crtrott What I'm getting at is that we're diverging from the plain wording of the Standard for the sake of an unproven optimization. It adds a compile-time check, so it's not an obvious win.

Signed-off-by: Christian Trott <crtrott@sandia.gov>
@crtrott crtrott force-pushed the use-canonicalize-slice-in-submdspan branch from 526a039 to 7bc13a6 Compare July 2, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants