-
Notifications
You must be signed in to change notification settings - Fork 61
stdalgos (3/10): team-level API, and rst update for release 4.2 #371
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
Open
fnrizzi
wants to merge
11
commits into
kokkos:main
Choose a base branch
from
fnrizzi:std_teamlevel_p3of10
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
31c4c18
progress: for_each and for_each_n
cc03c20
search
7c66852
update search_n
0330519
update pages
06c6f8d
add missing
cc1ce46
Apply suggestions from code review
crtrott f05d890
Merge remote-tracking branch 'upstream/main' into std_teamlevel_p3of10
ajpowelsnl df45dca
StdSearch.rst: correct spelling error (caught by CI)
ajpowelsnl 3e98697
Correct spelling / consistency of Mismatch struct
ajpowelsnl ecb1fca
Add indentation, line to make Sphinx happy
ajpowelsnl 40fb8f1
Fix typo
dalg24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
109 changes: 0 additions & 109 deletions
109
docs/source/API/algorithms/std-algorithms/all/StdForEach.md
This file was deleted.
Oops, something went wrong.
147 changes: 147 additions & 0 deletions
147
docs/source/API/algorithms/std-algorithms/all/StdForEach.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
|
|
||
| ``for_each`` | ||
| ============ | ||
|
|
||
| Header: ``<Kokkos_StdAlgorithms.hpp>`` | ||
|
|
||
| Description | ||
| ----------- | ||
|
|
||
| Applies a unary functor to the result of dereferencing each iterator in a range or each element in a rank-1 ``View``. | ||
|
|
||
| Interface | ||
| --------- | ||
|
|
||
| .. warning:: This is currently inside the ``Kokkos::Experimental`` namespace. | ||
|
|
||
| Overload set accepting execution space | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| .. code-block:: cpp | ||
|
|
||
| template <class ExecutionSpace, class InputIterator, class UnaryFunctorType> | ||
| UnaryFunctorType for_each(const ExecutionSpace& exespace, (1) | ||
| InputIterator first, InputIterator last, | ||
| UnaryFunctorType func); | ||
|
|
||
| template <class ExecutionSpace, class InputIterator, class UnaryFunctorType> | ||
| UnaryFunctorType for_each(const std::string& label, const ExecutionSpace& exespace, (2) | ||
| InputIterator first, InputIterator last, | ||
| UnaryFunctorType func); | ||
|
|
||
| template <class ExecutionSpace, class DataType, class... Properties, class UnaryFunctorType> | ||
| UnaryFunctorType for_each(const ExecutionSpace& exespace, (3) | ||
| const Kokkos::View<DataType, Properties...>& view, | ||
| UnaryFunctorType func); | ||
|
|
||
| template <class ExecutionSpace, class DataType, class... Properties, class PredicateType> | ||
| UnaryFunctorType for_each(const std::string& label, const ExecutionSpace& exespace, (4) | ||
| const Kokkos::View<DataType, Properties...>& view, | ||
| UnaryFunctorType func); | ||
|
|
||
| Overload set accepting a team handle | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| .. versionadded:: 4.2 | ||
|
|
||
| .. code-block:: cpp | ||
|
|
||
| template <class TeamHandleType, class InputIterator, class UnaryFunctorType> | ||
| KOKKOS_FUNCTION | ||
| UnaryFunctorType for_each(const TeamHandleType& teamHandle, (5) | ||
| InputIterator first, InputIterator last, | ||
| UnaryFunctorType func); | ||
|
|
||
| template <class TeamHandleType, class DataType, class... Properties, class UnaryFunctorType> | ||
| KOKKOS_FUNCTION | ||
| UnaryFunctorType for_each(const TeamHandleType& teamHandle, (6) | ||
| const Kokkos::View<DataType, Properties...>& view, | ||
| UnaryFunctorType func); | ||
|
|
||
| Parameters and Requirements | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| - ``exespace``: execution space instance | ||
|
|
||
| - ``teamHandle``: team handle instance given inside a parallel region when using a TeamPolicy | ||
|
|
||
| - ``label``: string forwarded to internal parallel kernels for debugging purposes | ||
|
|
||
| - for 1, the default string is: "Kokkos::for_each_iterator_api_default" | ||
|
|
||
| - for 3, the default string is: "Kokkos::for_each_view_api_default" | ||
|
|
||
| - NOTE: overloads accepting a team handle do not use a label internally | ||
|
|
||
| - ``first, last``: iterators defining the ranges to operate on | ||
|
|
||
| - must be *random access iterators* | ||
|
|
||
| - must represent a valid range, i.e., ``last >= first`` | ||
|
|
||
| - must be accessible from ``exespace`` or from the execution space associated with the team handle | ||
|
|
||
| - ``view``: | ||
|
|
||
| - must be rank-1, and have ``LayoutLeft``, ``LayoutRight``, or ``LayoutStride`` | ||
|
|
||
| - must be accessible from ``exespace`` or from the execution space associated with the team handle | ||
|
|
||
| - ``func``: function object called on the all the elements; | ||
|
|
||
| - The signature of the function should be ``func(v)`` and must be valid to be called from the execution space passed, | ||
| or the execution space associated with the team handle, and must accept every argument ``v`` of type | ||
| ``value_type``, where ``value_type`` is the value type of ``InputIterator`` or ``view`` | ||
|
|
||
| - must conform to: | ||
|
|
||
| .. code-block:: cpp | ||
|
|
||
| struct func | ||
| { | ||
| KOKKOS_INLINE_FUNCTION | ||
| void operator()(const /*type needed */ & operand) const { /* ... */; } | ||
|
|
||
| // or, also valid | ||
|
|
||
| KOKKOS_INLINE_FUNCTION | ||
| void operator()(/*type needed */ & operand) const { /* ... */; } | ||
| }; | ||
|
|
||
| Return | ||
| ~~~~~~ | ||
|
|
||
| ``func`` | ||
|
|
||
| Example | ||
| ------- | ||
|
|
||
| .. code-block:: cpp | ||
|
|
||
| namespace KE = Kokkos::Experimental; | ||
|
|
||
| template<class ValueType> | ||
| struct IncrementValFunctor | ||
| { | ||
| const ValueType m_value; | ||
| IncrementValFunctor(ValueType value) : m_value(value){} | ||
|
|
||
| KOKKOS_INLINE_FUNCTION | ||
| void operator()(ValueType & operand) const { | ||
| operand += m_value; | ||
| } | ||
| }; | ||
|
|
||
| auto exespace = Kokkos::DefaultExecutionSpace; | ||
| using view_type = Kokkos::View<exespace, int*>; | ||
| view_type a("a", 15); | ||
| // fill "a" somehow | ||
|
|
||
| // create functor | ||
| IncrementValFunctor<int> p(5); | ||
|
|
||
| // Increment each element in "a" by 5. | ||
| KE::for_each(exespace, KE::begin(a), KE::end(a), p); | ||
|
|
||
| // assuming OpenMP is enabled, then you can also explicitly call | ||
| KE::for_each(Kokkos::OpenMP(), KE::begin(a), KE::end(a), p); | ||
54 changes: 0 additions & 54 deletions
54
docs/source/API/algorithms/std-algorithms/all/StdForEachN.md
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.