Skip to content

Fix return type of layout_padded operator - #465

Merged
mhoemmen merged 1 commit into
kokkos:stablefrom
Quntized:quntized-index-type
Jul 26, 2026
Merged

Fix return type of layout_padded operator#465
mhoemmen merged 1 commit into
kokkos:stablefrom
Quntized:quntized-index-type

Conversation

@Quntized

@Quntized Quntized commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

I was testing layout_padded while doing in layout_padded indices operator -> The return type was size_t but in compute_offset is returned by as index_type .

    using extint32 = MDSPAN_IMPL_STANDARD_NAMESPACE::extents<int, 2, 3, 4>;
    using layout_left = Kokkos::Experimental::layout_left_padded<16>::mapping<extint32>;
    layout_left l1(extint32{});
    static_assert(std::is_same_v<decltype(l1(0,0,0)),extint32::index_type>," not int");

->

/home/sajid/kokkos_internal/kokkos_tree/mdspan/kokkos_extent_inv.hpp(78): error: static assertion failed with " not int"
      static_assert(std::is_same_v<decltype(l1(0,0,0)),extint32::index_type>," not int");
      ^

Signed-off-by: Quntized <mdsajid-09-2021911491@ne.du.ac.bd>
@Quntized

Copy link
Copy Markdown
Contributor Author

I checked P2642R6 (the standard proposal this implementation follows), and it explicitly specifies constexpr size_t operator()(...) for the padded layouts, unlike the general LayoutMapping requirement of returning index_type. My test's premise was wrong. Closing this .

@Quntized Quntized closed this Jul 25, 2026
@mhoemmen mhoemmen reopened this Jul 26, 2026
@mhoemmen

mhoemmen commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

C++26 specifies the return type as index_type. See e.g., the layout_left_padded::mapping class synopsis and the paragraphs that describe its call operator.

@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!

@mhoemmen
mhoemmen merged commit 884f17a into kokkos:stable Jul 26, 2026
30 checks passed
@Quntized
Quntized deleted the quntized-index-type branch July 27, 2026 05:38
@Quntized

Quntized commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the reference. I had been checking an older draft of the proposal.
Sorry for that.

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.

2 participants