Repository navigation
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
miscco
left a comment
There was a problem hiding this comment.
Already looks good, great job!
I would love some minor improvements / cleanups
| template <typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename InitType> | ||
| _CCCL_HOST_DEVICE ::cuda::std::__accumulator_t<::cuda::std::plus<>, | ||
| ::cuda::std::__accumulator_t<::cuda::std::multiplies<>, | ||
| ::cuda::std::iter_value_t<InputIterator1>, | ||
| ::cuda::std::iter_value_t<InputIterator2>>, | ||
| InitType> | ||
| inner_product(const thrust::detail::execution_policy_base<DerivedPolicy>& exec, | ||
| InputIterator1 first1, | ||
| InputIterator1 last1, | ||
| InputIterator2 first2, | ||
| InitType init) |
There was a problem hiding this comment.
This breaks the interface with the C++ standard library. See: https://en.cppreference.com/w/cpp/algorithm/inner_product
template< class InputIt1, class InputIt2, class T >
T inner_product( InputIt1 first1, InputIt1 last1, InputIt2 first2, T init );
std::inner_product returns T.
Do we really want to do that? Thrust is no longer a drop-in replacement for the (parallel) STL. I think we would need a super strong motivation for that.
There was a problem hiding this comment.
this is basically the discussion in #153. I would say that std::inner_product returns T is not the best solution. We can provide something better and align it with CUB
There was a problem hiding this comment.
I would say that
std::inner_productreturnsTis not the best solution.
It's the solution that has existed for more than 2 decades in the STL. I would not dare to break that interface.
We can provide something better and align it with CUB
CUB is much younger and less widely used than the STL, so I would not take it as reference here.
There was a problem hiding this comment.
We can add a similarly named function though as a Thrust-only extension. Strawman: thrust::inner_product_accum. This way we can provide the new functionality and retain STL compatibility.
There was a problem hiding this comment.
that's fine with me. @gevtushenko any thought?
There was a problem hiding this comment.
I'm starting thinking that duplicating the same functionality makes little sense. This also affects reduce and transform_reduce, while scan seems fine
There was a problem hiding this comment.
- Should we change the signatures of standard algorithms? I don't think so. Thrust is not exactly a standalone library. It implements standard parallel algorithms in nvhpc. Besides that, when we expose parallel algorithms in
cuda::std::, we'd also have to conform to the standard. - Should we expose
thrust::*_accumalgorithms? I don't think it's in the scope of [FEA]: Use P2322R6 to determine accumulator type in Thrust #153 so we can safely postpone this discussion. Going forward, I'd rather wait for requirements API and use it to specify accumulator type on existing overloads.
I'd suggest to focus on algorithms which accumulator type is not defined first. Talking about reduction, it looks to be defined as returns GENERALIZED_SUM which is defined as op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, ..., aN)) which seems close to the accumulator type we have on CUB end. @fbusato @bernhardmgruber, if my reading of reduction is correct and accumulator type is not specified, is there any value in using proper accumulator type from CUB regardless of the signature and then converting it to T (init value type / input iterator value type)?
There was a problem hiding this comment.
is there any value in using proper accumulator type
yes, and no. Using accumulator type could result in better or worse performance, see reduce with implicit promotion which prevents SIMD. The opposite is also true if SIMD is not available.
I'd suggest to focus on algorithms which accumulator type is not defined first.
If we exclude reduce, transform_reduce, inner_product, then the accumulator type applies to inclusive/exclusive_scan only (if I'm not missing something). The standard defines it in the same way we are proposing
🟨 CI finished in 1h 49m: Pass: 91%/93 | Total: 2d 16h | Avg: 41m 38s | Max: 1h 20m | Hits: 61%/121441
|
| Project | |
|---|---|
| CCCL Infrastructure | |
| libcu++ | |
| CUB | |
| +/- | Thrust |
| CUDA Experimental | |
| python | |
| CCCL C Parallel Library | |
| Catch2Helper |
Modifications in project or dependencies?
| Project | |
|---|---|
| CCCL Infrastructure | |
| libcu++ | |
| +/- | CUB |
| +/- | Thrust |
| CUDA Experimental | |
| +/- | python |
| +/- | CCCL C Parallel Library |
| +/- | Catch2Helper |
🏃 Runner counts (total jobs: 93)
| # | Runner |
|---|---|
| 66 | linux-amd64-cpu16 |
| 9 | windows-amd64-cpu16 |
| 6 | linux-amd64-gpu-rtxa6000-latest-1 |
| 4 | linux-arm64-cpu16 |
| 3 | linux-amd64-gpu-h100-latest-1 |
| 3 | linux-amd64-gpu-rtx4090-latest-1 |
| 2 | linux-amd64-gpu-rtx2080-latest-1 |
🟨 CI finished in 1h 44m: Pass: 92%/93 | Total: 2d 17h | Avg: 42m 11s | Max: 1h 20m | Hits: 61%/121441
|
| Project | |
|---|---|
| CCCL Infrastructure | |
| libcu++ | |
| CUB | |
| +/- | Thrust |
| CUDA Experimental | |
| python | |
| CCCL C Parallel Library | |
| Catch2Helper |
Modifications in project or dependencies?
| Project | |
|---|---|
| CCCL Infrastructure | |
| libcu++ | |
| +/- | CUB |
| +/- | Thrust |
| CUDA Experimental | |
| +/- | python |
| +/- | CCCL C Parallel Library |
| +/- | Catch2Helper |
🏃 Runner counts (total jobs: 93)
| # | Runner |
|---|---|
| 66 | linux-amd64-cpu16 |
| 9 | windows-amd64-cpu16 |
| 6 | linux-amd64-gpu-rtxa6000-latest-1 |
| 4 | linux-arm64-cpu16 |
| 3 | linux-amd64-gpu-h100-latest-1 |
| 3 | linux-amd64-gpu-rtx4090-latest-1 |
| 2 | linux-amd64-gpu-rtx2080-latest-1 |
|
@bernhardmgruber @elstehle what is the expected behavior in CUB for std::vector input{1.5, 2.5, 3.5, 4.5};
std::vector<double> output(4);
std::inclusive_scan(input.begin(), input.end(), output.begin(), std::plus<int>{});
assert(input[0] == 1.5); // CUB returns 1.0 instead
assert(input[1] == 3.0); // ok |
🟨 CI finished in 1h 42m: Pass: 50%/93 | Total: 2d 09h | Avg: 37m 04s | Max: 1h 22m | Hits: 71%/53922
|
| Project | |
|---|---|
| CCCL Infrastructure | |
| libcu++ | |
| CUB | |
| +/- | Thrust |
| CUDA Experimental | |
| python | |
| CCCL C Parallel Library | |
| Catch2Helper |
Modifications in project or dependencies?
| Project | |
|---|---|
| CCCL Infrastructure | |
| libcu++ | |
| +/- | CUB |
| +/- | Thrust |
| CUDA Experimental | |
| +/- | python |
| +/- | CCCL C Parallel Library |
| +/- | Catch2Helper |
🏃 Runner counts (total jobs: 93)
| # | Runner |
|---|---|
| 66 | linux-amd64-cpu16 |
| 9 | windows-amd64-cpu16 |
| 6 | linux-amd64-gpu-rtxa6000-latest-1 |
| 4 | linux-arm64-cpu16 |
| 3 | linux-amd64-gpu-h100-latest-1 |
| 3 | linux-amd64-gpu-rtx4090-latest-1 |
| 2 | linux-amd64-gpu-rtx2080-latest-1 |
🟩 CI finished in 1h 39m: Pass: 100%/93 | Total: 2d 17h | Avg: 41m 57s | Max: 1h 22m | Hits: 67%/133878
|
| Project | |
|---|---|
| CCCL Infrastructure | |
| libcu++ | |
| CUB | |
| +/- | Thrust |
| CUDA Experimental | |
| python | |
| CCCL C Parallel Library | |
| Catch2Helper |
Modifications in project or dependencies?
| Project | |
|---|---|
| CCCL Infrastructure | |
| libcu++ | |
| +/- | CUB |
| +/- | Thrust |
| CUDA Experimental | |
| +/- | python |
| +/- | CCCL C Parallel Library |
| +/- | Catch2Helper |
🏃 Runner counts (total jobs: 93)
| # | Runner |
|---|---|
| 66 | linux-amd64-cpu16 |
| 9 | windows-amd64-cpu16 |
| 6 | linux-amd64-gpu-rtxa6000-latest-1 |
| 4 | linux-arm64-cpu16 |
| 3 | linux-amd64-gpu-h100-latest-1 |
| 3 | linux-amd64-gpu-rtx4090-latest-1 |
| 2 | linux-amd64-gpu-rtx2080-latest-1 |
Fixes #153