Repository navigation
Make transform iterator utility in c parallel test suite - #4645
Merged
oleksandr-pavlyk merged 4 commits intoMay 9, 2025
Conversation
Contributor
🟩 CI finished in 1h 57m: Pass: 100%/5 | Total: 44m 17s | Avg: 8m 51s | Max: 21m 33s | Hits: 98%/326
|
| Project | |
|---|---|
| CCCL Infrastructure | |
| libcu++ | |
| CUB | |
| Thrust | |
| CUDA Experimental | |
| stdpar | |
| python | |
| +/- | CCCL C Parallel Library |
| Catch2Helper |
Modifications in project or dependencies?
| Project | |
|---|---|
| CCCL Infrastructure | |
| libcu++ | |
| CUB | |
| Thrust | |
| CUDA Experimental | |
| stdpar | |
| +/- | python |
| +/- | CCCL C Parallel Library |
| Catch2Helper |
🏃 Runner counts (total jobs: 5)
| # | Runner |
|---|---|
| 4 | linux-amd64-gpu-rtx2080-latest-1 |
| 1 | linux-amd64-cpu16 |
Contributor
Author
|
|
`iterator_t` stored names of advance/dereference functions
in operator_t struct members, but did not store the name of
the iterator state. This made it difficult to create another
instance of the same iterator on GPU without running into
multiple definition issues.
Used this in test_segmented_reduce.cpp, where we can now say
to reuse state and methods defined for `start_offsets_it`.
```
auto end_offsets_it = make_iterator<IndexT, HostTransformStateT>(
{start_offsets_it.state_name, empty_src},
{start_offsets_it.advance.name, empty_src},
{start_offsets_it.dereference.name, empty_src});
```
Also:
1. Introduce `name_source_t` struct that stores
name of an entity and its source code definition.
2. Introduce `make_stateful_transformed_iterator` and
`make_stateless_transformed_iterator` utilities.
These take name_source_t arguments describing
state of base iterator, base iterator advance/deref
function definitions, and state of transformation functor
and it operation definition.
3. Introduce utilities to get definition sources for
common iterators and used those in make_constant_iterator,
and other iterator makers.
Such utilities are useful for building transform iterators
from canonical iterators.
4. Applied solution to support std::string_view in operation_t,
stateful_operation_t constructors and various make_iterator
functions.
The solution was suggested to me by @ericniebler and @miscco
1. The test is based on Python test test_large_num_segments3 from test_segmented_reduce.py The test performs segments reduce of constant iterator with value of 1, with offsets being a transformed iterator over a counting iterator, where transformation computes offsets of the beginning of the next segment, assuming that segment lengths form a sequence [ min, min+1, ..., max-1, max, min, min + 1, ... ] For segments ID `k`, the segment length is `min + (k % (max + 1 - min))`. Only the result array much be allocated, resulting in substantial memory savings, given than n_segments > INT_MAX. Since expected result is known in closed form, test validation is performed using call to cccl_device_reduce, where input is a transformed iterator over counting iterator, with transformation function returning 1 is result array element agrees with expected value, and 0 otherwise. Comparsion combining binary operation is implemented as follows ( ((actual[i1] == expected(i1) ? int32_t(1) : int32_t(0)) * ((actual[i2] == expected(i2) ? int32_t(1) : int32_t(0)) ) == N.B.: In this test both transformed iterators use stateful operations. The state for computation of offsets requires min and p = max + 1 - min. The state for checking the outptu requires min, p, and result array pointer. Right now the test is deployed for n_segments smaller than INT_MAX, but it is ready to be enabled when support for incrementing indirect terators on the host is added.
oleksandr-pavlyk
force-pushed
the
make-transform-iterator-utility-in-c-paralle-test-suite
branch
from
May 7, 2025 12:47
5b1f3be to
d8564a4
Compare
Contributor
🟩 CI finished in 17m 06s: Pass: 100%/5 | Total: 43m 22s | Avg: 8m 40s | Max: 16m 49s | Hits: 98%/326
|
| Project | |
|---|---|
| CCCL Infrastructure | |
| libcu++ | |
| CUB | |
| Thrust | |
| CUDA Experimental | |
| stdpar | |
| python | |
| +/- | CCCL C Parallel Library |
| Catch2Helper |
Modifications in project or dependencies?
| Project | |
|---|---|
| CCCL Infrastructure | |
| libcu++ | |
| CUB | |
| Thrust | |
| CUDA Experimental | |
| stdpar | |
| +/- | python |
| +/- | CCCL C Parallel Library |
| Catch2Helper |
🏃 Runner counts (total jobs: 5)
| # | Runner |
|---|---|
| 4 | linux-amd64-gpu-rtx2080-latest-1 |
| 1 | linux-amd64-cpu16 |
Contributor
🟩 CI finished in 17m 18s: Pass: 100%/5 | Total: 40m 00s | Avg: 8m 00s | Max: 17m 17s | Hits: 98%/326
|
| Project | |
|---|---|
| CCCL Infrastructure | |
| libcu++ | |
| CUB | |
| Thrust | |
| CUDA Experimental | |
| stdpar | |
| python | |
| +/- | CCCL C Parallel Library |
| Catch2Helper |
Modifications in project or dependencies?
| Project | |
|---|---|
| CCCL Infrastructure | |
| libcu++ | |
| CUB | |
| Thrust | |
| CUDA Experimental | |
| stdpar | |
| +/- | python |
| +/- | CCCL C Parallel Library |
| Catch2Helper |
🏃 Runner counts (total jobs: 5)
| # | Runner |
|---|---|
| 4 | linux-amd64-gpu-rtx2080-latest-1 |
| 1 | linux-amd64-cpu16 |
shwina
reviewed
May 8, 2025
shwina
approved these changes
May 8, 2025
shwina
left a comment
Contributor
There was a problem hiding this comment.
It looks good. As discussed offline, a potential API improvement could be simply holding the sources in the iterator itself, and hiding source from the test author behind make_iterator. However this comes with challenges and other potential benefits which will be described in a subsequent issue. No need to block this PR on that work as this is already an improvement.
Separated lines to promote readability.
Contributor
🟩 CI finished in 17m 48s: Pass: 100%/5 | Total: 40m 05s | Avg: 8m 01s | Max: 17m 08s | Hits: 98%/326
|
| Project | |
|---|---|
| CCCL Infrastructure | |
| libcu++ | |
| CUB | |
| Thrust | |
| CUDA Experimental | |
| stdpar | |
| python | |
| +/- | CCCL C Parallel Library |
| Catch2Helper |
Modifications in project or dependencies?
| Project | |
|---|---|
| CCCL Infrastructure | |
| libcu++ | |
| CUB | |
| Thrust | |
| CUDA Experimental | |
| stdpar | |
| +/- | python |
| +/- | CCCL C Parallel Library |
| Catch2Helper |
🏃 Runner counts (total jobs: 5)
| # | Runner |
|---|---|
| 4 | linux-amd64-gpu-rtx2080-latest-1 |
| 1 | linux-amd64-cpu16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
closes #4643
closes #4644
This PR build on top of #4609 and should only be merged after #4609 is merged.UPD: The PR has been rebased since #4609 has been merged.Summary of changes:
make_operatorandmake_iteratornow support arguments of typestd::string_viewandconst char *(thanks @ericniebler for helping me streamline my clunky implementation)advancefunction and iterator'sdereferencefunction.make_counting_iteratorand others to use code-definition generation utilities,iterator_tto add memberstd::string state_name, and modifiedmake_iteratorutility to acceptstate_nameargument in addition tostate_def_src.name_source_tto bind entity name and its code definitionmake_stateful_transform_iteratorandmake_stateless_transform_iteratorwhich take name/source pairs for base iterator state, base iteratoradvancefunction, base iteratordereferencefunction, as well as for transform operator state, transform operator implementation function."test_segmented_reduce.cpp"to use new iterator utilities."test_segmented_reduce.cpp"that usesmake_stateful_transformed_iteratorthat is ready to test implementation of host-streaming approach to supportnum_segmentsthat exceedINT_MAXvalue.Checklist