Add mdspan-style template parameter support for Kokkos::View#26
Draft
Add mdspan-style template parameter support for Kokkos::View#26
Conversation
Co-authored-by: crtrott <[email protected]>
…ephrase trust directive Co-authored-by: crtrott <[email protected]>
Co-authored-by: crtrott <[email protected]>
Copilot instructions
Updated minimum CMake version requirement from 3.16 to 3.22.
Co-authored-by: crtrott <[email protected]>
… parameters Co-authored-by: crtrott <[email protected]>
Co-authored-by: crtrott <[email protected]>
Copilot
AI
changed the title
[WIP] Overhaul Kokkos::View for template parameter specification
Add mdspan-style template parameter support for Kokkos::View
Jan 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enable Kokkos::View to accept mdspan-style template parameters (
extents,layout_left/right,SpaceAwareAccessor) as an alternative to classical syntax (double**,LayoutLeft,CudaSpace), maintaining full backward compatibility.Changes
Trait detection (
Kokkos_Concepts.hpp): Addedis_mdspan_extents_v,is_mdspan_layout_v, andis_mdspan_accessor_vto identify mdspan typesType converters (
Kokkos_ViewTraits.hpp):ArrayLayoutFromMDSpanLayout: Mapslayout_left/right/stridetoLayoutLeft/Right/StrideMemorySpaceFromAccessor: Extracts memory space fromSpaceAwareAccessorSafeDataTypeFromExtents: Converts element type + extents to data type specificationViewTraits specializations: Added SFINAE specializations to process mdspan parameters alongside existing ArrayLayout/Space/MemoryTraits specializations
Primary template enhancement: Modified to detect mdspan parameters and convert them to canonical Kokkos types
Example
Known Issue
SFINAE specialization conflict occurs when processing multiple mdspan types in sequence (e.g.,
ViewTraits<void, layout_left, SpaceAwareAccessor>). The recursive template instantiation doesn't match existing specializations correctly. Requires refactoring the specialization pattern to handle combined mdspan parameter cases.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.