Skip to content

Add SubView class#1915

Draft
gberg617 wants to merge 24 commits intodevelopfrom
feature/bergel1/subview
Draft

Add SubView class#1915
gberg617 wants to merge 24 commits intodevelopfrom
feature/bergel1/subview

Conversation

@gberg617
Copy link
Contributor

@gberg617 gberg617 commented Sep 19, 2025

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.

@gberg617 gberg617 marked this pull request as draft September 19, 2025 21:12
@gberg617
Copy link
Contributor Author

This PR is still a WIP!

@gberg617 gberg617 self-assigned this Sep 19, 2025
Comment on lines +42 to +49
RAJA_INLINE RAJA_HOST_DEVICE constexpr auto array_to_tuple_impl(const camp::array<T, N>& arr, camp::idx_seq<Is...>) {
return camp::make_tuple(arr[Is]...);
}

template <typename T, size_t N>
RAJA_INLINE RAJA_HOST_DEVICE constexpr auto array_to_tuple(const camp::array<T, N>& arr) {
return array_to_tuple_impl(arr, camp::make_idx_seq_t<N>{});
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we not have this somewhere?

Copy link
Member

Choose a reason for hiding this comment

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

If not it would be good to add it in a more general header.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I'll look into moving this to camp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function wasn't eventually needed. That said, I can still add something like this to camp if you think it could be useful.

@gberg617 gberg617 force-pushed the feature/bergel1/subview branch from 804abcd to 5ba920d Compare September 30, 2025 01:08

}

// void test_subviewGPU() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To Do: Fix GPU tests.

@gberg617 gberg617 changed the title Feature/bergel1/subview Add SubView class Sep 30, 2025
@gberg617
Copy link
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?

@gberg617 gberg617 force-pushed the feature/bergel1/subview branch from 1e928d3 to efa96d5 Compare February 28, 2026 01:09
…pen interval [start, end) and added more checks for StridedSlice size
using NonConstView =
MultiView<nc_value_type, layout_type, P2Pidx, nc_pointer_type>;

static constexpr size_t n_dims = layout_type::n_dims + 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rchen20 Does this look right for MultiViews?

gberg617 added 3 commits March 4, 2026 17:26
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.
}

template<size_t DIM>
RAJA_INLINE RAJA_HOST_DEVICE constexpr auto get_parent_dim_stride() const {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how useful get_parent_dim_stride() is.

@gberg617 gberg617 force-pushed the feature/bergel1/subview branch from 7323aa3 to 5fb6dd0 Compare March 5, 2026 23:17
@gberg617 gberg617 force-pushed the feature/bergel1/subview branch from 0c1e1dc to be6df15 Compare March 5, 2026 23:20
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.

5 participants