Skip to content

Commit

Permalink
finalize
Browse files Browse the repository at this point in the history
  • Loading branch information
fnrizzi committed Dec 1, 2023
1 parent a66e55b commit 732fca4
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 116 deletions.
32 changes: 16 additions & 16 deletions docs/source/API/algorithms/std-algorithms/all/StdFill.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ Header: ``<Kokkos_StdAlgorithms.hpp>``
Description
-----------

Copy-assigns ``value`` to each element in the range ``[first, last)`` (overloads 1,2)
or in ``view`` (overloads 3,4).
Assigns a given ``value`` to each element in a given range or rank-1 ``View``.


Interface
---------

.. warning:: This is currently inside the ``Kokkos::Experimental`` namespace.


Overload set accepting execution space
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: cpp
//
// overload set accepting execution space
//
template <class ExecutionSpace, class IteratorType, class T>
void fill(const ExecutionSpace& exespace, (1)
IteratorType first, IteratorType last,
Expand All @@ -41,20 +41,22 @@ Interface
const Kokkos::View<DataType, Properties...>& view,
const T& value);
//
// overload set accepting a team handle
// Note: for now omit the overloads accepting a label
// since they cause issues on device because of the string allocation.
//
Overload set accepting a team handle
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. versionadded:: 4.2

.. code-block:: cpp
template <class TeamHandleType, class IteratorType, class T>
KOKKOS_FUNCTION
void fill(const TeamHandleType& th,
void fill(const TeamHandleType& teamHandle, (5)
IteratorType first, IteratorType last,
const T& value);
template <class TeamHandleType, class DataType, class... Properties, class T>
KOKKOS_FUNCTION
void fill(const TeamHandleType& th,
void fill(const TeamHandleType& teamHandle, (6)
const Kokkos::View<DataType, Properties...>& view,
const T& value);
Expand All @@ -74,13 +76,11 @@ Parameters and Requirements

- NOTE: overloads accepting a team handle do not use a label internally

- ``first, last``: range of elements to search in

- range of elements to assign to
- ``first, last``: range of elements to modify

- must be *random access iterators*, e.g., ``Kokkos::Experimental::begin/end``

- must represent a valid range, i.e., ``last >= first`` (checked in debug mode)
- must represent a valid range, i.e., ``last >= first``

- must be accessible from ``exespace`` or from the execution space associated with the team handle

Expand Down
51 changes: 28 additions & 23 deletions docs/source/API/algorithms/std-algorithms/all/StdFill_n.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ Header: ``<Kokkos_StdAlgorithms.hpp>``
Description
-----------

Copy-assigns ``value`` to the first ``n`` elements in the range starting at ``first`` (overloads 1,2)
or the first ``n`` elements in ``view`` (overloads 3,4).
Assigns a given ``value`` to the first ``n`` elements in a given range or rank-1 ``View``.


Interface
---------

.. warning:: This is currently inside the ``Kokkos::Experimental`` namespace.


Overload set accepting execution space
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: cpp
//
// overload set accepting execution space
//
template <class ExecutionSpace, class IteratorType, class SizeType, class T>
IteratorType fill_n(const ExecutionSpace& exespace, (1)
IteratorType first,
Expand All @@ -31,41 +31,46 @@ Interface
IteratorType first,
SizeType n, const T& value);
template <class ExecutionSpace, class DataType, class... Properties, class SizeType, class T>
template <
class ExecutionSpace, class DataType, class... Properties,
class SizeType, class T>
auto fill_n(const ExecutionSpace& exespace, (3)
const Kokkos::View<DataType, Properties...>& view,
SizeType n, const T& value);
template <class ExecutionSpace, class DataType, class... Properties, class SizeType, class T>
template <
class ExecutionSpace, class DataType, class... Properties,
class SizeType, class T>
auto fill_n(const std::string& label, const ExecutionSpace& exespace, (4)
const Kokkos::View<DataType, Properties...>& view,
SizeType n, const T& value);
//
// overload set accepting a team handle
//
Overload set accepting a team handle
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. versionadded:: 4.2


.. code-block:: cpp
template <class TeamHandleType, class IteratorType, class SizeType, class T>
KOKKOS_FUNCTION
IteratorType fill_n(const TeamHandleType& th,
IteratorType first, SizeType n,
const T& value);
IteratorType fill_n(const TeamHandleType& teamHandle, (5)
IteratorType first, SizeType n, const T& value);
template <
class TeamHandleType, class DataType, class... Properties, class SizeType,
class T, int>
class TeamHandleType, class DataType, class... Properties, class SizeType,
class T>
KOKKOS_FUNCTION
IteratorType fill_n(const TeamHandleType& th,
const Kokkos::View<DataType, Properties...>& view,
SizeType n,
const T& value);
auto fill_n(const TeamHandleType& teamHandle, (6)
const Kokkos::View<DataType, Properties...>& view,
SizeType n, const T& value);
Parameters and Requirements
~~~~~~~~~~~~~~~~~~~~~~~~~~~

- ``exespace``, ``first``, ``view``, ``value``: same as in [``fill``](./StdFill): execution space instance

- ``teamHandle``: team handle instance given inside a parallel region when using a TeamPolicy
- ``exespace``, ``teamHandle``, ``first``, ``view``, ``value``: same as in [``fill``](./StdFill): execution space instance

- ``label``: used to name the implementation kernels for debugging purposes

Expand All @@ -84,7 +89,7 @@ Return Value

If ``n > 0``, returns an iterator to the element *after* the last element assigned.

Otherwise, it returns ``first`` (for 1,2) or ``Kokkos::begin(view)`` (for 3,4).
Otherwise, it returns ``first`` (for 1,2,5) or ``Kokkos::begin(view)`` (for 3,4,6).


Example
Expand Down
30 changes: 16 additions & 14 deletions docs/source/API/algorithms/std-algorithms/all/StdReplace.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@ Header: ``<Kokkos_StdAlgorithms.hpp>``
Description
-----------

Replaces with ``new_value`` all elements that are equal to ``old_value`` in the
range ``[first, last)`` (overloads 1,2) or in ``view`` (overloads 3,4).
Equality is checked using ``operator==``.
Replaces with ``new_value`` all elements that are equal to ``old_value`` in
a given range or rank-1 ``View``. Equality is checked using ``operator==``.

Interface
---------

.. warning:: This is currently inside the ``Kokkos::Experimental`` namespace.


Overload set accepting execution space
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: cpp
//
// overload set accepting execution space
//
template <class ExecutionSpace, class IteratorType, class T>
void replace(const ExecutionSpace& exespace, (1)
IteratorType first, IteratorType last,
Expand All @@ -42,19 +41,24 @@ Interface
const Kokkos::View<DataType, Properties...>& view,
const T& old_value, const T& new_value);
//
// overload set accepting a team handle
//
Overload set accepting a team handle
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. versionadded:: 4.2

.. code-block:: cpp
template <class TeamHandleType, class Iterator, class ValueType>
KOKKOS_FUNCTION
void replace(const TeamHandleType& teamHandle,
void replace(const TeamHandleType& teamHandle, (5)
Iterator first, Iterator last,
const ValueType& old_value, const ValueType& new_value);
template <class TeamHandleType, class DataType1, class... Properties1,
class ValueType>
KOKKOS_FUNCTION
void replace(const TeamHandleType& teamHandle,
void replace(const TeamHandleType& teamHandle, (6)
const ::Kokkos::View<DataType1, Properties1...>& view,
const ValueType& old_value, const ValueType& new_value);
Expand All @@ -74,9 +78,7 @@ Parameters and Requirements

- NOTE: overloads accepting a team handle do not use a label internally

- ``first, last``:

- range of elements to search in
- ``first, last``: range of elements to search in

- must be *random access iterators*, e.g., ``Kokkos::Experimental::begin/end``

Expand Down
48 changes: 24 additions & 24 deletions docs/source/API/algorithms/std-algorithms/all/StdReplaceCopy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Header: ``<Kokkos_StdAlgorithms.hpp>``
Description
-----------

Copies the elements from range ``[first_from, last_from)`` to another range
beginning at ``first_to`` (overloads 1,2) or from ``view_from`` to ``view_to``
(overloads 3,4) replacing with ``new_value`` all elements that equal ``old_value``.
Copies the elements from a given range ``[first_from, last_from)`` to another range
beginning at ``first_to`` or from ``view_from`` to ``view_to`` replacing
with ``new_value`` all elements that equal ``old_value``.
Comparison between elements is done using ``operator==``.

Interface
Expand All @@ -18,20 +18,20 @@ Interface
.. warning:: This is currently inside the ``Kokkos::Experimental`` namespace.


Overload set accepting execution space
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: cpp
//
// overload set accepting execution space
//
template <class ExecutionSpace, class InputIteratorType, class OutputIteratorType, class T>
OutputIteratorType replace_copy(const ExecutionSpace& exespace, (1)
OutputIteratorType replace_copy(const ExecutionSpace& exespace, (1)
InputIteratorType first_from,
InputIteratorType last_from,
OutputIteratorType first_to,
const T& old_value, const T& new_value);
template <class ExecutionSpace, class InputIteratorType, class OutputIteratorType, class T>
OutputIteratorType replace_copy(const std::string& label, (2)
OutputIteratorType replace_copy(const std::string& label, (2)
const ExecutionSpace& exespace,
OutputIteratorType first_to,
const T& old_value, const T& new_value);
Expand All @@ -42,7 +42,7 @@ Interface
class DataType2, class... Properties2,
class T
>
auto replace_copy(const ExecutionSpace& exespace, (3)
auto replace_copy(const ExecutionSpace& exespace, (3)
const Kokkos::View<DataType1, Properties1...>& view_from,
const Kokkos::View<DataType2, Properties2...>& view_to,
const T& old_value, const T& new_value);
Expand All @@ -54,18 +54,22 @@ Interface
class T
>
auto replace_copy(const std::string& label,
const ExecutionSpace& exespace, (4)
const ExecutionSpace& exespace, (4)
const Kokkos::View<DataType1, Properties1...>& view_from,
const Kokkos::View<DataType2, Properties2...>& view_to,
const T& old_value, const T& new_value);
//
// overload set accepting a team handle
//
Overload set accepting a team handle
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. versionadded:: 4.2

.. code-block:: cpp
template <class TeamHandleType, class InputIterator, class OutputIterator,
class ValueType>
KOKKOS_FUNCTION
OutputIterator replace_copy(const TeamHandleType& teamHandle,
OutputIterator replace_copy(const TeamHandleType& teamHandle, (5)
InputIterator first_from, InputIterator last_from,
OutputIterator first_dest,
const ValueType& old_value, const ValueType& new_value);
Expand All @@ -74,7 +78,7 @@ Interface
class TeamHandleType, class DataType1, class... Properties1,
class DataType2, class... Properties2, class ValueType, int>
KOKKOS_FUNCTION
auto replace_copy(const TeamHandleType& teamHandle,
auto replace_copy(const TeamHandleType& teamHandle, (6)
const Kokkos::View<DataType1, Properties1...>& view_from,
const Kokkos::View<DataType2, Properties2...>& view_dest,
const ValueType& old_value, const ValueType& new_value);
Expand All @@ -95,31 +99,27 @@ Parameters and Requirements

- NOTE: overloads accepting a team handle do not use a label internally

- ``first_from, last_from``:

- range of elements to copy from
- ``first_from, last_from``: range of elements to copy from

- must be *random access iterators*

- must represent a valid range, i.e., ``last_from >= first_from`` (checked in debug mode)

- must be accessible from ``exespace``

- ``first_to``:
- must be accessible from ``exespace`` or from the execution space associated with the team handle

- beginning of the range to copy to
- ``first_to``: beginning of the range to copy to

- must be a *random access iterator*

- must be accessible from ``exespace``
- must be accessible from ``exespace`` or from the execution space associated with the team handle

- ``view_from``, ``view_to``:

- source and destination views

- must be rank-1, and have ``LayoutLeft``, ``LayoutRight``, or ``LayoutStride``

- must be accessible from ``exespace``
- must be accessible from ``exespace`` or from the execution space associated with the team handle

- ``old_value``, ``new_value``: self-explanatory

Expand Down
Loading

0 comments on commit 732fca4

Please sign in to comment.