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

Reshape method #1760

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open

Reshape method #1760

wants to merge 9 commits into from

Conversation

artv3
Copy link
Member

@artv3 artv3 commented Nov 5, 2024

Summary

This PR adds helper methods to views to create Reshape methods with compile time options C and Fortran style indexing

@artv3 artv3 changed the title reshape method Reshape method Nov 5, 2024
examples/reshape.cpp Outdated Show resolved Hide resolved
examples/reshape.cpp Outdated Show resolved Hide resolved
Comment on lines 125 to 126
// RAJA::Layout objects may be templated on dimension, argument type, and
// index with unit stride. Here, the column index has unit stride (argument 2).
Copy link
Member

@MrBurmark MrBurmark Nov 5, 2024

Choose a reason for hiding this comment

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

Can you supply the permutation at compile time, via camp::list or std::index_sequence, and have it produce a view with the right unit stride index?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I pushed a version for that just now. Let me know what you think.

examples/reshape.cpp Outdated Show resolved Hide resolved
examples/reshape.cpp Outdated Show resolved Hide resolved
struct layout_left{};
struct layout_right{};

template<typename LAYOUT>
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a specialization for a generic index sequence like std::index_sequence?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I'll take a pass at this and then I'll remove the "Draft" marking from this PR.

include/RAJA/util/View.hpp Outdated Show resolved Hide resolved
examples/reshape.cpp Outdated Show resolved Hide resolved
examples/reshape.cpp Outdated Show resolved Hide resolved
@artv3
Copy link
Member Author

artv3 commented Dec 23, 2024

@MrBurmark , @rhornung67 I think the example for the reshape method can be simplified. I just pushed up a new version. I was a bit worried the previous version might have too much going on.

examples/reshape.cpp Outdated Show resolved Hide resolved
examples/reshape.cpp Outdated Show resolved Hide resolved
@artv3 artv3 marked this pull request as ready for review December 23, 2024 22:22
}

template<std::size_t...Is>
struct Reshape<std::index_sequence<Is...>>
Copy link
Member Author

Choose a reason for hiding this comment

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

@MrBurmark , this is the specialization that takes an index_sequence and identifies the correct unit stride

// Initialize memory using right most unit stride
//
//----------------------------------------------------------------------------//
std::cout << "\n\nInitialize array with right most indexing...\n";
Copy link
Member

Choose a reason for hiding this comment

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

I think these implementations are much easier to understand if your intent is just to show the mechanics of View reshaping. 👍


constexpr auto unit_stride = get_first_index<Is...>();

return RAJA::View<T, RAJA::Layout<N, RAJA::Index_type, unit_stride>>
Copy link
Member Author

Choose a reason for hiding this comment

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

Bug found here! unit_stride should be the last value of the prameter pack -- TODO: FIX

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.

3 participants