-
Notifications
You must be signed in to change notification settings - Fork 407
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
Allow templated functors in parallel_for, parallel_reduce and parallel_scan #5976
Conversation
00cd644
to
817ad61
Compare
Impl::ParallelScanWithTotal<FunctorType, ExecutionPolicy, | ||
typename ReturnType::value_type> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes a bug where we were passing the View
as template argument instead of the value type.
Please resolve the conflicts and improve the description |
817ad61
to
71f1a75
Compare
Done. |
@@ -85,7 +85,7 @@ void test_functor_analysis() { | |||
TestFunctorAnalysis_03 c03; | |||
using A03 = Kokkos::Impl::FunctorAnalysis< | |||
Kokkos::Impl::FunctorPatternInterface::REDUCE, | |||
Kokkos::RangePolicy<ExecSpace>, TestFunctorAnalysis_03>; | |||
Kokkos::RangePolicy<ExecSpace>, TestFunctorAnalysis_03, void>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should a non-void OverrideValueType
test be added where we static_assert the value type is the override?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I added another test.
clang-format is not happy |
b5b7585
to
fe023c6
Compare
Fixed. |
fe023c6
to
6cefceb
Compare
Only |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just posting pending comments that I had. Not a full review.
core/unit_test/incremental/Test05_ParallelReduce_RangePolicy.hpp
Outdated
Show resolved
Hide resolved
KOKKOS_FUNCTION void operator()(SizeType i) const { | ||
d_data(i) = i * 0.5; | ||
} | ||
using View_1D = typename Kokkos::View<value_type *, ExecSpace>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typename
is superfluous here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing is optional. Will merge if the CI passes.
|
…l_scan (kokkos#5976) * Allow templated functors in parallel_for, parallel_reduce and parallel_scan * Reorder template arguments for cuda_single_inter_block_reduce_scan_shmem * Add another test to TestFunctorAnalysis.hpp * Document OverrrideValueType some more * Document that reducer functor is templated on purpose * GenericScanFunctor->GenericExclusiveScanFunctor * SizeType->IndexType * Revert unnecessary changes in Test16_ParallelScan.hpp
Part of #5908. Fixes #5156, improves #2034. This is basically #5420:
Extending
FunctorAnalysis
to be able to be used with templated call operators appears to be very difficult. On the other hand, the overloads ofparallel_reduce
andparallel_scan
taking a return value already contain a hint for thevalue_type
to use so that we can avoid using the deduction inFunctorAnalysis
in those cases.This pull request does exactly that. If the functor has a
value_type
alias, we use that, otherwise, we use thevalue_type
deduced from the return type and if that is void, too, we do the deduction in FunctorAnalysis based on the functor's call operator.edit: Copied description from #5420.