Skip to content

Add SubView class - #1915

Open
gberg617 wants to merge 31 commits into
developfrom
feature/bergel1/subview
Open

Add SubView class#1915
gberg617 wants to merge 31 commits into
developfrom
feature/bergel1/subview

Conversation

@gberg617

@gberg617 gberg617 commented Sep 19, 2025

Copy link
Copy Markdown
Contributor

Summary

  • This WIP PR adds the SubView class. This class stores a view-type object and a tuple of slices that indicate how to access the view's underlying data. The following slice types are supported:
    • range slice: Indexes a subset of the original dimension's extents. Does not reduce dimensionality.
    • fixed slice: Indexes along a fixed value of a given dimension. Reduces dimensionality.
    • no slice: Indexes according to the original view's layout along the given dimension. Does not reduce dimensionality.

A few simple examples are provided below:

    View<Index_type, Layout<2>> view(&my_data[0][0], Layout<2>(3,3));

    // "sv1 = View[1:3,:]"
    auto sv1 = SubView(view, RangeSlice{1,3}, NoSlice{});

    // "sv2 = View[1:3,1]"
    auto sv2 = SubView(view, RangeSlice{1,3}, FixedSlice{1});

Here, sv1 and sv2 are subviews of dimensions (2,3) and (2) respectively.

Future tasks:

  • Add Slices whose extents are determined at compile time
  • Add Slice types that use non-affine mappings (e.g. index lists)
  • Add ability to collapse nested sub-layouts into a single sub-layout for slices that have affine mappings
  • Add ability to distinguish between projected dimension and an empty slice (e.g. RangeSlice{2,2})

@gberg617
gberg617 marked this pull request as draft September 19, 2025 21:12
@gberg617

Copy link
Copy Markdown
Contributor Author

This PR is still a WIP!

@gberg617 gberg617 self-assigned this Sep 19, 2025
Comment thread include/RAJA/util/SubView.hpp Outdated
Comment thread include/RAJA/util/SubView.hpp Outdated
Comment thread include/RAJA/util/SubView.hpp Outdated
Comment thread include/RAJA/util/SubView.hpp Outdated
@gberg617
gberg617 force-pushed the feature/bergel1/subview branch from 804abcd to 5ba920d Compare September 30, 2025 01:08
Comment thread test/unit/view-layout/test-subview.cpp Outdated
@gberg617 gberg617 changed the title Feature/bergel1/subview Add SubView class Sep 30, 2025
Comment thread include/RAJA/util/SubView.hpp Outdated
Comment thread include/RAJA/util/SubView.hpp Outdated
Comment thread include/RAJA/util/SubView.hpp Outdated
Comment thread include/RAJA/util/SubView.hpp Outdated
Comment thread include/RAJA/util/SubView.hpp Outdated
Comment thread include/RAJA/util/SubView.hpp Outdated
Comment thread include/RAJA/util/SubView.hpp Outdated
Comment thread test/unit/view-layout/test-subview.cpp
@gberg617

Copy link
Copy Markdown
Contributor Author

I'm considering separating the SubView holding the view from the slices that are used to access the view, somewhat analogous to the approach of having layouts and Views be separate classes. Any thoughts on this?

Comment thread include/RAJA/util/SubView.hpp Outdated
Comment thread include/RAJA/util/SubView.hpp Outdated
Comment thread include/RAJA/util/SubView.hpp Outdated
Comment thread include/RAJA/util/SubView.hpp Outdated
Comment thread include/RAJA/util/SubView.hpp Outdated
Comment thread include/RAJA/util/for_each.hpp Outdated
Comment thread include/RAJA/util/for_each.hpp Outdated
gberg617 added 28 commits July 22, 2026 10:10
…pen interval [start, end) and added more checks for StridedSlice size
2. Replaced camp::array usage with std::array.
3. Fixed and simplified get_dim_stride and get_parent_dim_stride.
4. Replaced usage of IndexType with size_t where appropriate.
@gberg617
gberg617 force-pushed the feature/bergel1/subview branch from 91eca15 to 2442033 Compare July 22, 2026 17:23
@@ -26,6 +26,9 @@
#include <type_traits>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I need to fix this rebased file.

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.

6 participants