Skip to content

Commit 3a74e28

Browse files
masterleinadnmm0
andauthored
parallel_reduce/scan: Clarify identity in case no reproducer was given (#487)
* parallel_reduce: Clarify identity in case no reproducer was given * Also update parallel_scan * Clarify that reduction_identity is not used. Co-authored-by: Nicolas Morales <[email protected]> --------- Co-authored-by: Nicolas Morales <[email protected]>
1 parent 2ca3705 commit 3a74e28

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docs/source/API/core/parallel-dispatch/parallel_reduce.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ Requirements:
9393

9494
- If ``ExecPolicy::work_tag`` is ``void``, the overload without a ``WorkTag`` argument is used.
9595
- ``N`` must match ``ExecPolicy::rank``.
96-
* If the ``functor`` is a lambda, ``ReducerArgument`` must satisfy the ``Reducer`` concept or ``ReducerArgumentNonConst`` must be a POD type with ``operator +=`` and ``operator =`` or a ``Kokkos::View``. In the latter case, the default ``Sum`` reduction is applied. If provided, the ``init``/ ``join``/ ``final`` member functions must not take a ``WorkTag`` argument even for tagged reductions.
97-
* If ``ExecPolicy`` is ``TeamThreadRange`` a "reducing" ``functor`` is not allowed and the ``ReducerArgument`` must satisfy the ``Reducer`` concept or ``ReducerArgumentNonConst`` must be a POD type with ``operator +=`` and ``operator =`` or a ``Kokkos::View``. In the latter case, the default ``Sum`` reduction is applied.
96+
* If the ``functor`` is a lambda, ``ReducerArgument`` must satisfy the ``Reducer`` concept or ``ReducerArgumentNonConst`` must be a POD type with ``operator +=`` and ``operator =`` or a ``Kokkos::View``. In the latter case, a sum reduction is applied where the identity is assumed to be given by the default constructor of the value type (and not by ``reduction_identity```). If provided, the ``init``/ ``join``/ ``final`` member functions must not take a ``WorkTag`` argument even for tagged reductions.
97+
* If ``ExecPolicy`` is ``TeamThreadRange`` a "reducing" ``functor`` is not allowed and the ``ReducerArgument`` must satisfy the ``Reducer`` concept or ``ReducerArgumentNonConst`` must be a POD type with ``operator +=`` and ``operator =`` or a ``Kokkos::View``. In the latter case, a sum reduction is applied where the identity is assumed to be given by the default constructor of the value type (and not by ``reduction_identity```).
9898
* The reduction argument type ``ReducerValueType`` of the ``functor`` operator must be compatible with the ``ReducerArgument`` (or ``ReducerArgumentNonConst``) and must match the arguments of the ``init``, ``join`` and ``final`` functions of the functor if those exist and no reducer is specified (``ReducerArgument`` doesn't satisfy the ``Reducer`` concept but is a scalar, array or ``Kokkos::View``). In case of tagged reductions, i.e., when specifying a tag in the policy, the functor's potential ``init``/ ``join``/ ``final`` member functions must also be tagged.
9999
* If ``ReducerArgument`` (or ``ReducerArgumentNonConst``)
100100

docs/source/API/core/parallel-dispatch/parallel_scan.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Requirements:
4949

5050
- The ``WorkTag`` free form of the operator is used if ``ExecPolicy`` is an ``IntegerType`` or ``ExecPolicy::work_tag`` is ``void``.
5151
- ``HandleType`` is an ``IntegerType`` if ``ExecPolicy`` is an ``IntegerType`` else it is ``ExecPolicy::member_type``.
52-
* The type ``ReturnType`` of the ``functor`` operator must be compatible with the ``ReturnType`` of the parallel_scan and must match the arguments of the ``init`` and ``join`` functions of the functor.
52+
* The type ``ReturnType`` of the ``functor`` operator must be compatible with the ``ReturnType`` of the parallel_scan and must match the arguments of the ``init`` and ``join`` functions of the functor if provided. If the functor doesn't have an ``init`` member function, it is assumed that the identity for the scan operation is given by the default constructor of the value type (and not by ``reduction_identity```).
5353
* the functor must define FunctorType::value_type the same as ReturnType
5454

5555
Semantics

0 commit comments

Comments
 (0)