Skip to content

Python like Range#2006

Open
artv3 wants to merge 16 commits intodevelopfrom
artv3/zeroTo
Open

Python like Range#2006
artv3 wants to merge 16 commits intodevelopfrom
artv3/zeroTo

Conversation

@artv3
Copy link
Copy Markdown
Member

@artv3 artv3 commented Mar 25, 2026

#Summary

Many of my loops start at zero, this gives users a shortcut to generate the desired range segment.

@artv3 artv3 requested a review from a team March 25, 2026 22:49
@artv3 artv3 changed the title Add ZeroTo RangeSegment Python like Range Mar 31, 2026
@artv3
Copy link
Copy Markdown
Member Author

artv3 commented Mar 31, 2026

Hi @llnl/raja-core I've pushed up the discussed changes.

``RAJA::TypedRangeStrideSegment``.
* When one of the bounds is a RAJA strong index type, such as a type created
with ``RAJA_INDEX_VALUE``, that strong type is preserved for the loop
variable when possible.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When possible? Doesn't it always use the strong type if one is provided?
The only case I'm worried about is something like a strong index type with underlying type int combined with a long choosing long instead of being an error.

with ``RAJA_INDEX_VALUE``, that strong type is preserved for the loop
variable when possible.
* Providing an explicit template argument, such as
``RAJA::range<MyIndex>(end)``, overrides the deduced storage type.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It should still be an error to, for example, explicitly ask for int but provide a strong index type as an argument, or explicitly ask for a strong index type and provide a different strong index type as an argument.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if we can use c++20's require to test that these cases fail?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You definitely can, you could even make concepts to make it easier most likely.

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.

4 participants