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

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft

Reshape method #1760

wants to merge 2 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
Comment on lines +29 to +30
* to correspond to the matrix entry in the row, r,
* column, c, of matrix, e. Below we describe the two
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what the right way to put commas here is, it feels a bit awkward to have so many commas so close together.

Comment on lines +118 to +119
// make_permuted_layout takes the number of entries in each dimension and a
// templated array indicating index arguments with slowest to fastest stride.
Copy link
Member

Choose a reason for hiding this comment

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

Should this just be an array? Do you mean to say that any array-like class can be used or that it has to be a std::array but the types stored in the array can vary but have to be convertible to integers, or something else?

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?

//
// _permutedlayout_permviews_start
#if 0
std::array<RAJA::idx_t, 3> perm2 {{0, 1, 2}};
Copy link
Member

Choose a reason for hiding this comment

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

Isn't perm 2 the same as perm 1?

Copy link
Member Author

Choose a reason for hiding this comment

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

hey.. .thats right. Sorry this was just a scratch pad to prototype the reshape methods. I can give a 2 mins overview at the meeting on the general direction I was going.

Comment on lines +217 to +219
Cview(e, 0, 0) = Aview(e, 0, 0) * Bview(e, 0, 0)
+ Aview(e, 0, 1) * Bview(e, 1, 0)
+ Aview(e, 0, 2) * Bview(e, 2, 0);
Copy link
Member

Choose a reason for hiding this comment

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

This spacing does not spark joy.

Comment on lines +322 to +323
{
constexpr int N = sizeof...(Ts);
Copy link
Member

Choose a reason for hiding this comment

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

spacing

Comment on lines +327 to +329
///Should be a away to do this at compile time...
std::array<RAJA::idx_t, N> reverse_indices_array;
for(int i = N-1, j=0; i>-1; --i, j++) {reverse_indices_array[j] = i; }
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.

Make an array of {s...} and an integer_sequence of 0...(N-1), pass them into a function, and then you'll have all the information you need to do the re-indexing.

static auto get(T *ptr, Ts... s)
{
constexpr int N = sizeof...(Ts);
return RAJA::View<T, RAJA::Layout<N, RAJA::Index_type, N-1>>(ptr, s...);
Copy link
Member

Choose a reason for hiding this comment

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

Can you add an alias for the view_type?

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?

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.

2 participants