Skip to content

Commit

Permalink
parallel_reduce/scan: Clarify identity in case no reproducer was given (
Browse files Browse the repository at this point in the history
#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]>
  • Loading branch information
masterleinad and nmm0 authored Jul 30, 2024
1 parent 2ca3705 commit 3a74e28
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/source/API/core/parallel-dispatch/parallel_reduce.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ Requirements:

- If ``ExecPolicy::work_tag`` is ``void``, the overload without a ``WorkTag`` argument is used.
- ``N`` must match ``ExecPolicy::rank``.
* 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.
* 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.
* 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.
* 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```).
* 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.
* If ``ReducerArgument`` (or ``ReducerArgumentNonConst``)

Expand Down
2 changes: 1 addition & 1 deletion docs/source/API/core/parallel-dispatch/parallel_scan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Requirements:

- The ``WorkTag`` free form of the operator is used if ``ExecPolicy`` is an ``IntegerType`` or ``ExecPolicy::work_tag`` is ``void``.
- ``HandleType`` is an ``IntegerType`` if ``ExecPolicy`` is an ``IntegerType`` else it is ``ExecPolicy::member_type``.
* 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.
* 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```).
* the functor must define FunctorType::value_type the same as ReturnType

Semantics
Expand Down

0 comments on commit 3a74e28

Please sign in to comment.