Skip to content

Fix layout stride converting explicit clause - #445

Merged
crtrott merged 4 commits into
kokkos:stablefrom
nmm0:fix-layout-stride-converting-explicit-clause
Jan 28, 2026
Merged

crtrott merged 4 commits into
kokkos:stablefrom
nmm0:fix-layout-stride-converting-explicit-clause

Conversation

@nmm0

@nmm0 nmm0 commented Jan 19, 2026

Copy link
Copy Markdown
Contributor

We forgot to add the padded layouts to the layout_stride converting constructor, see https://eel.is/c++draft/mdspan.layout#stride.cons-9

This PR adds tests for all the strided layout conversions/constructions/assignments from other layouts

@mhoemmen mhoemmen left a comment

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.

Thanks for the fix!

Comment thread include/experimental/__p0009_bits/layout_stride.hpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes the layout_stride converting constructor to properly handle conversions from padded layouts (layout_left_padded and layout_right_padded). The fix ensures that conversions from padded layouts to layout_stride are implicit (when extents are convertible), consistent with how conversions from layout_left, layout_right, and layout_stride itself are handled.

Changes:

  • Added include for layout_padded_fwd.hpp to access padded layout type traits
  • Extended the MDSPAN_CONDITIONAL_EXPLICIT clause to include padded layout mappings in the list of layouts that should have implicit conversion
  • Added compile-time tests to verify constructibility, convertibility, and assignability for conversions between layout_stride and padded layouts

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
include/experimental/__p0009_bits/layout_stride.hpp Added include for padded layout traits and extended the converting constructor's explicit clause to handle padded layouts
compilation_tests/ctest_layout_convertible.cpp Added compile-time tests (guarded with C++17 check) to verify bidirectional conversion support between layout_stride and padded layouts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/experimental/__p0009_bits/layout_stride.hpp
Comment thread include/experimental/__p0009_bits/layout_stride.hpp Outdated
Comment thread compilation_tests/ctest_layout_convertible.cpp
@crtrott
crtrott merged commit 8b4eea2 into kokkos:stable Jan 28, 2026
15 checks passed
dalg24 pushed a commit to dalg24/kokkos that referenced this pull request Aug 13, 2026
Includes:
* kokkos/mdspan#445
* kokkos/mdspan#447
* kokkos/mdspan#459
* kokkos/mdspan#462
* kokkos/mdspan#463
* kokkos/mdspan#464
* kokkos/mdspan#465

Signed-off-by: Damien L-G <dalg24@gmail.com>
Co-authored-by: Nicolas Morales <nmmoral@sandia.gov>
Co-authored-by: Roger Pawlowski <rppawlo@sandia.gov>
Co-authored-by: Seyong Lee <lees2@ornl.gov
Co-authored-by: Namjae Choi <Namjae.Choi@inl.gov>
Co-authored-by: Quntized <mdsajid-09-2021911491@ne.du.ac.bd>
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.

4 participants