Skip to content

Conversation

@yasahi-hpc
Copy link
Collaborator

This PR aims at moving compute_strides under KokkosFFT::Impl namespace. This function can be used not only for rocFFT but also for cuFFTMp with small differences.

@yasahi-hpc yasahi-hpc added enhancement New feature or request cleanup labels Oct 21, 2025
is_std_array_v<ContainerType>,
std::nullptr_t> = nullptr>
auto compute_strides(const ContainerType& extents) {
using IntType =

Choose a reason for hiding this comment

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

I would rename IntType as IndexType

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

May be called this extents_type?
Following mdspan convention

Choose a reason for hiding this comment

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

I would say no, as I understand it, in MDSpan, Extends is a composite type grouping three different informations:

  • Extents::index_type
  • Extents::size_type
  • Extents::rank_type

Here, Int_Type corresponds only to the index_type. But I may be mistaken?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is correct
What I intent was indeed index_type
https://en.cppreference.com/w/cpp/container/mdspan/extent.html

Copy link

@PaulGannay PaulGannay Oct 21, 2025

Choose a reason for hiding this comment

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

Ok, yes, I agree with you, index_type would be an even better name.

Comment on lines 396 to 398
// (n0, n1, n2) -> (1, n2, n1*n2)
// (n0, n1) -> (1, n1)
// (n0) -> (1)

Choose a reason for hiding this comment

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

I understood the old

  // (n0, n1, n2) -> (1, n0, n0*n1)
  // (n0, n1) -> (1, n0)
  // (n0) -> (1)

but I can't make sense of this example.
Could you explain what kind of stride you are computing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You may imagine Views v in LayoutRight.
If we compute the strides from Right (the contiguous dimension) to Left, it would be

  • v(n0) -> (1)
  • v(n0, n1) -> (1, n1)
  • v(n0, n1, n2) -> (1, n2, n2 * n1)

I do not know why it is given in this order though. (As you can see, in cuFFTMp the order is reversed. This makes more sense)

  • v(n0) -> (1)
  • v(n0, n1) -> (n1, 1)
  • v(n0, n1, n2) -> (n2 * n1, n2, 1)

Choose a reason for hiding this comment

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

Ok, this is clear, thank you.
Maybe it deserve an explanation in the comment too?

Otherwise it looks good to me.

@yasahi-hpc
Copy link
Collaborator Author

@PaulGannay

Thank you for approval. I will merge this after CI passes

@yasahi-hpc yasahi-hpc merged commit de3a788 into kokkos:main Oct 21, 2025
39 checks passed
@yasahi-hpc yasahi-hpc deleted the make-compute-strides-public branch October 21, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants