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

layout() function broken for Views with padding -- path forward #6974

Open
crtrott opened this issue May 1, 2024 · 3 comments
Open

layout() function broken for Views with padding -- path forward #6974

crtrott opened this issue May 1, 2024 · 3 comments
Assignees

Comments

@crtrott
Copy link
Member

crtrott commented May 1, 2024

We have an issue because the LayoutLeft and LayoutRight class itself (not the mapping) has no place to store stride. As a consequence the following code is wrong:

Kokkos::View<int**,Kokkos::LayoutLeft> a("A",N,M);
Kokkos::View<int**,Kokkos::LayoutLeft> a_sub =
  Kokkos::subview(a, Kokkos::pair{3,5},Kokkos::ALL());

Kokkos::View<int**,Kokkos::LayoutLeft> b_sub(a.sub.data(), a_sub.layout());
//b_sub.stride(1) != a_sub.stride(1);

Suggested path forward:

  • restrict layout() to Kokkos::LayoutLeft/Right/Stride and deprecate
    • error out when calling layout() where stride!=extent
  • introduce View::mapping() -> return mdspan mappings
  • introduce View(data_handle, mdspan_mapping_type map)
@nmm0 nmm0 self-assigned this May 1, 2024
@masterleinad
Copy link
Contributor

It's actually not stride(1) but stride(2) that fails: https://godbolt.org/z/14q5o136r

@crtrott
Copy link
Member Author

crtrott commented May 2, 2024

Because the code should have used a_sub.layout() corrected.

@crtrott
Copy link
Member Author

crtrott commented May 2, 2024

Also accessing stride(2) on a rank-2 view is kinda UB lol

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

No branches or pull requests

3 participants