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

Strided Iterators and 'Skip' Iterators #706

Open
cdeterman opened this issue May 23, 2018 · 5 comments
Open

Strided Iterators and 'Skip' Iterators #706

cdeterman opened this issue May 23, 2018 · 5 comments
Labels
thrust For all items related to Thrust.

Comments

@cdeterman
Copy link

Is there anything equivalent in Thrust that corresponds to the strided_iterator found in boost compute? On the same topic of operating on specific elements of a buffer, is there a way to operator on 'padded' objects? Note, I also have this same question posted in boost compute For example, take the row-wise padded matrix:

8 2 7 0 0 0
6 5 4 0 0 0
1 3 9 0 0 0 

So the internal flat buffer would be

8 2 7 0 0 0 6 5 4 0 0 0 1 3 9 0 0 0

As an example, how could I use sort on just the 'non-padded' elements?

Likewise, the column wise may also be padded (less common but might as well include here)

8 2 7 0 0 0
6 5 4 0 0 0
1 3 9 0 0 0 
0 0 0 0 0 0
0 0 0 0 0 0 
0 0 0 0 0 0
@henryiii
Copy link

I think it only exists as an example: https://github.com/thrust/thrust/blob/master/examples/strided_range.cu

@cdeterman
Copy link
Author

@henryiii thanks, I wonder why it hasn't been formally added in to thrust. Any additional thoughts regarding the 'padding' problem?

@brycelelbach
Copy link
Collaborator

This falls into the broader category of "multi-dimensional" support, I think, although a skip iterator could be useful for a linear sequence.

We don't have a firm design for what we're going to do in this space. But, I imagine we'll eventually want a family of strided iterators.

Note, however, that traditionally such iterators have all sorts of performance problems.

SEE ALSO: https://www.youtube.com/watch?v=EVGenON6p9g
SEE ALSO: https://github.com/brycelelbach/mditerator
SEE ALSO: https://github.com/brycelelbach/mdspan
SEE ALSO: wg21.link/P0009

@jrhemstad
Copy link
Collaborator

@brycelelbach @allisonvacanti there have been several times where I've wanted something very simple like this for linear sequences. I don't think we need a full on md-span or multi-dimensional iterator for something this simple. Similarly, I've wanted a counting_iterator that takes a "step" value.

I imagine these would look something like this:

template <typename InputIterator, typename Stride>
auto make_strided_iterator(InputIterator it, Stride stride);

template <typename Incrementable>
auto make_counting_iterator(Incremenetable begin, Incrementable step);

@jrhemstad
Copy link
Collaborator

@jrhemstad jrhemstad added the thrust For all items related to Thrust. label Feb 22, 2023
@jarmak-nv jarmak-nv transferred this issue from NVIDIA/thrust Nov 8, 2023
elstehle pushed a commit to elstehle/cccl that referenced this issue Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
thrust For all items related to Thrust.
Projects
Status: Todo
Development

No branches or pull requests

4 participants