Skip to content
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

parallel_reduce/scan: Clarify identity in case no reproducer was given #487

Merged
merged 3 commits into from
Jul 30, 2024

Conversation

masterleinad
Copy link
Contributor

Related to kokkos/kokkos#6760.

@masterleinad masterleinad changed the title parallel_reduce: Clarify identity in case no reproducer was given parallel_reduce/scan: Clarify identity in case no reproducer was given Jan 31, 2024
Comment on lines +96 to +97
* 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```).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can be clearer to mention the case where reduction_identity is used and when default constructor value is.
For a user perspective it is not even clear why identity is needed. Are you talking about initial value for the reduction or for some other operations in the algorithms?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial value is the identity (internally) so that we don't have to treat the first iteration as special.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path forward:

  • accept as is, and document future behavior once refactor is in place

@masterleinad
Copy link
Contributor Author

Waiting for @crtrott's proposal for a different behavior.

Copy link
Contributor

@ajpowelsnl ajpowelsnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Post - Merge TODO:

  • Update once parallel_reduce , parallel_scan (identity) changes in place
  • Create documentation issue once behavior updated, add a tag saying in version xyz reduction / scan identity can be used

Comment on lines +96 to +97
* 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```).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path forward:

  • accept as is, and document future behavior once refactor is in place

Copy link
Contributor

@nmm0 nmm0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor addition

docs/source/API/core/parallel-dispatch/parallel_scan.rst Outdated Show resolved Hide resolved
@masterleinad masterleinad merged commit 3a74e28 into kokkos:main Jul 30, 2024
1 check passed
@masterleinad masterleinad deleted the document_parallel_reduce_init branch July 30, 2024 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants