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

Use iterators for at-grid-stride and at-block-stride traversals #88

Open
eyalroz opened this issue May 29, 2021 · 2 comments
Open

Use iterators for at-grid-stride and at-block-stride traversals #88

eyalroz opened this issue May 29, 2021 · 2 comments
Labels
fixed on development A fix for this issue has been committed to the development branch question Further information is requested

Comments

@eyalroz
Copy link
Owner

eyalroz commented May 29, 2021

Currently, we offer the at_grid_stride(), at_block_stride() and at_warp_stride() functions, which take an invokable and ensure the appropriate traversal pattern is used.

Would it not be a good idea to offer, instead or in addition, iterators corresponding to these patterns, as in range.hpp in the CUDA C++11 sample program?

@eyalroz eyalroz added the question Further information is requested label May 29, 2021
@eyalroz
Copy link
Owner Author

eyalroz commented May 31, 2021

The range in question is Mark Harris' adaptation cpp11range. I find the original to be a bit cluttered with stuff I don't need (e.g. infinite-loop range), and it "conflicts" with C++20 ranges, but it might be adaptable in a more pleasing fashion so that instead of, say:

auto f = [&] (Size pos) {
    foo(pos);
};
kat::linear_grid::collaborative::grid::at_grid_stride(length, f_inner);

we could write:

for(Size pos : kat::ranges::at_grid_stride(length)) {
    foo(pos);
}

as the latter is both shorter (even ignoring namespaces) and simpler, in not requiring a higher-order function.

@eyalroz eyalroz changed the title Use iterators for at-grid-stride and at-block-stride traversals? Use iterators for at-grid-stride and at-block-stride traversals Jun 4, 2021
@eyalroz
Copy link
Owner Author

eyalroz commented Jun 4, 2021

Ok, I won't be going with Mark Harris' code. It's a bit too clunky IMHO; it's not C++17-friendly; and it is saddled with irrelevant baggage from the repository he had modified.

Instead, I'll implement my own integer and strided-integer ranges - which will be constexpr, and host+device; then on top of that I'll add named constructor idioms for warp, block and grid stride iteration.

eyalroz pushed a commit that referenced this issue Jun 4, 2021
* Host+device-side constexpr ranges of integers: simple and strided.
* Device-side named constructor idioms for iterating at warp, block and grid stride.
* Using the strided device-side ranges for ranged-for loops in collaboration primitives (mostly linear-grid).
* Using the strided device-side ranges for ranged-for loops in sequence operations (linear-grid).
* CAVEAT: Minimal direct unit test coverage, although indirectly the device-side code is tested via warp-, block- and grid-collaborative functions.
@eyalroz eyalroz added the fixed on development A fix for this issue has been committed to the development branch label Jun 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed on development A fix for this issue has been committed to the development branch question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant