From b2b4395f5935e5a47fa13ae5bb1b21514e07b90d Mon Sep 17 00:00:00 2001 From: antoinemeyer5 Date: Thu, 19 Jan 2023 15:58:20 +0100 Subject: [PATCH 1/5] kokkos#120: API/core/builtinreducers/Sum init --- docs/source/API/core/builtinreducers/Sum.rst | 99 ++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 docs/source/API/core/builtinreducers/Sum.rst diff --git a/docs/source/API/core/builtinreducers/Sum.rst b/docs/source/API/core/builtinreducers/Sum.rst new file mode 100644 index 000000000..dfe55d705 --- /dev/null +++ b/docs/source/API/core/builtinreducers/Sum.rst @@ -0,0 +1,99 @@ +``Sum`` +======= + +.. role::cpp(code) + :language: cpp + +.. role:: cppkokkos(code) + :language: cppkokkos + +Specific implementation of `ReducerConcept `_ performing an ``add`` operation + +Header File: ```` + +Usage +----- + +.. code-block:: cpp + + T result; + parallel_reduce(N,Functor,Sum(result)); + +Synopsis +-------- + +.. code-block:: cpp + + template + class Sum{ + public: + typedef Sum reducer; + typedef typename std::remove_cv::type value_type; + typedef Kokkos::View result_view_type; + + KOKKOS_INLINE_FUNCTION + void join(value_type& dest, const value_type& src) const; + + KOKKOS_INLINE_FUNCTION + void init( value_type& val) const; + + KOKKOS_INLINE_FUNCTION + value_type& reference() const; + + KOKKOS_INLINE_FUNCTION + result_view_type view() const; + + KOKKOS_INLINE_FUNCTION + Sum(value_type& value_); + + KOKKOS_INLINE_FUNCTION + Sum(const result_view_type& value_); + }; + +Public Class Members +-------------------- + +Typedefs +~~~~~~~~ + +* ``reducer``: The self type. +* ``value_type``: The reduction scalar type. +* ``result_view_type``: A ``Kokkos::View`` referencing the reduction result + +Constructors +~~~~~~~~~~~~ + +.. cppkokkos:kokkosinlinefunction:: Sum(value_type& value_); + +* Constructs a reducer which references a local variable as its result location. + +.. cppkokkos:kokkosinlinefunction:: Sum(const result_view_type& value_); + +* Constructs a reducer which references a specific view as its result location. + +Functions +~~~~~~~~~ + +.. cppkokkos:kokkosinlinefunction:: void join(value_type& dest, const value_type& src) const; + +* Add ``src`` into ``dest``: ``dest+=src;``. + +.. cppkokkos:kokkosinlinefunction:: void init(value_type& val) const; + +* Initialize ``val`` using the Kokkos::reduction_identity::sum() method. The default implementation sets ``val=0``. + +.. cppkokkos:kokkosinlinefunction:: value_type& reference() const; + +* Returns a reference to the result provided in class constructor. + +.. cppkokkos:kokkosinlinefunction:: result_view_type view() const; + +* Returns a view of the result place provided in class constructor. + +Additional Information +~~~~~~~~~~~~~~~~~~~~~~ + +* ``Sum::value_type`` is non-const ``T`` +* ``Sum::result_view_type`` is ``Kokkos::View>``. Note that the S (memory space) must be the same as the space where the result resides. +* Requires: ``Scalar`` has ``operator =`` and ``operator +=`` defined. ``Kokkos::reduction_identity::sum()`` is a valid expression. +* In order to use Sum with a custom type, a template specialization of ``Kokkos::reduction_identity`` must be defined. See `Built-In Reducers with Custom Scalar Types <../../../ProgrammingGuide/Custom-Reductions-Built-In-Reducers-with-Custom-Scalar-Types.html>`_ for details From 169d355b408f433876cecb45114965d22cb66042 Mon Sep 17 00:00:00 2001 From: antoinemeyer5 Date: Thu, 19 Jan 2023 15:59:01 +0100 Subject: [PATCH 2/5] kokkos#120: API/core/builtinreducers/Sum remove .md file --- docs/source/API/core/builtinreducers/Sum.md | 88 --------------------- 1 file changed, 88 deletions(-) delete mode 100644 docs/source/API/core/builtinreducers/Sum.md diff --git a/docs/source/API/core/builtinreducers/Sum.md b/docs/source/API/core/builtinreducers/Sum.md deleted file mode 100644 index dcdf012cc..000000000 --- a/docs/source/API/core/builtinreducers/Sum.md +++ /dev/null @@ -1,88 +0,0 @@ -# `Sum` - -Specific implementation of [ReducerConcept](ReducerConcept) performing an `add` operation - -Header File: `Kokkos_Core.hpp` - -Usage: -```c++ -T result; -parallel_reduce(N,Functor,Sum(result)); -``` - -## Synopsis -```c++ -template -class Sum{ - public: - typedef Sum reducer; - typedef typename std::remove_cv::type value_type; - typedef Kokkos::View result_view_type; - - KOKKOS_INLINE_FUNCTION - void join(value_type& dest, const value_type& src) const - - KOKKOS_INLINE_FUNCTION - void init( value_type& val) const; - - KOKKOS_INLINE_FUNCTION - value_type& reference() const; - - KOKKOS_INLINE_FUNCTION - result_view_type view() const; - - KOKKOS_INLINE_FUNCTION - Sum(value_type& value_); - - KOKKOS_INLINE_FUNCTION - Sum(const result_view_type& value_); -}; -``` - -## Public Class Members - -### Typedefs - - * `reducer`: The self type. - * `value_type`: The reduction scalar type. - * `result_view_type`: A `Kokkos::View` referencing the reduction result - -### Constructors - - * ```c++ - Sum(value_type& result) - ``` - Constructs a reducer which references a local variable as its result location. - - * ```c++ - Sum(const result_view_type result) - ``` - Constructs a reducer which references a specific view as its result location. - -### Functions - - * ```c++ - void join(value_type& dest, const value_type& src) const; - ``` - Add `src` into `dest`: `dest+=src;`. - - * ```c++ - void init( value_type& val) const; - ``` - Initialize `val` using the Kokkos::reduction_identity::sum() method. The default implementation sets `val=0`. - - * ```c++ - value_type& reference() const; - ``` - Returns a reference to the result provided in class constructor. - - * ```c++ - result_view_type view() const; - ``` - Returns a view of the result place provided in class constructor. - -### Additional Information - * `Sum::value_type` is non-const `T` - * `Sum::result_view_type` is `Kokkos::View>`. Note that the S (memory space) must be the same as the space where the result resides. - * Requires: `Scalar` has `operator =` and `operator +=` defined. `Kokkos::reduction_identity::sum()` is a valid expression. - * In order to use Sum with a custom type, a template specialization of `Kokkos::reduction_identity` must be defined. See [Built-In Reducers with Custom Scalar Types](../../../ProgrammingGuide/Custom-Reductions-Built-In-Reducers-with-Custom-Scalar-Types) for details From 0c024485c9700e7955930c7bc85167c6e947ca2b Mon Sep 17 00:00:00 2001 From: antoinemeyer5 Date: Sat, 21 Jan 2023 15:37:22 +0100 Subject: [PATCH 3/5] kokkos#120: API/core/builtinreducers/Sum new word choice --- docs/source/API/core/builtinreducers/Sum.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/API/core/builtinreducers/Sum.rst b/docs/source/API/core/builtinreducers/Sum.rst index dfe55d705..ad51d75ef 100644 --- a/docs/source/API/core/builtinreducers/Sum.rst +++ b/docs/source/API/core/builtinreducers/Sum.rst @@ -88,7 +88,7 @@ Functions .. cppkokkos:kokkosinlinefunction:: result_view_type view() const; -* Returns a view of the result place provided in class constructor. +* Returns a view of the result referenced in class constructor. Additional Information ~~~~~~~~~~~~~~~~~~~~~~ From 598e85b8f2ac0e9c7b7eb9d3f45f4c91bd5ae099 Mon Sep 17 00:00:00 2001 From: antoinemeyer5 Date: Tue, 24 Jan 2023 21:32:20 +0100 Subject: [PATCH 4/5] kokkos#120: API/core/builtinreducers/Sum fix tabs --- docs/source/API/core/builtinreducers/Sum.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/source/API/core/builtinreducers/Sum.rst b/docs/source/API/core/builtinreducers/Sum.rst index ad51d75ef..651fd8c07 100644 --- a/docs/source/API/core/builtinreducers/Sum.rst +++ b/docs/source/API/core/builtinreducers/Sum.rst @@ -65,30 +65,30 @@ Constructors .. cppkokkos:kokkosinlinefunction:: Sum(value_type& value_); -* Constructs a reducer which references a local variable as its result location. + * Constructs a reducer which references a local variable as its result location. .. cppkokkos:kokkosinlinefunction:: Sum(const result_view_type& value_); -* Constructs a reducer which references a specific view as its result location. + * Constructs a reducer which references a specific view as its result location. Functions ~~~~~~~~~ .. cppkokkos:kokkosinlinefunction:: void join(value_type& dest, const value_type& src) const; -* Add ``src`` into ``dest``: ``dest+=src;``. + * Add ``src`` into ``dest``: ``dest+=src;``. .. cppkokkos:kokkosinlinefunction:: void init(value_type& val) const; -* Initialize ``val`` using the Kokkos::reduction_identity::sum() method. The default implementation sets ``val=0``. + * Initialize ``val`` using the Kokkos::reduction_identity::sum() method. The default implementation sets ``val=0``. .. cppkokkos:kokkosinlinefunction:: value_type& reference() const; -* Returns a reference to the result provided in class constructor. + * Returns a reference to the result provided in class constructor. .. cppkokkos:kokkosinlinefunction:: result_view_type view() const; -* Returns a view of the result referenced in class constructor. + * Returns a view of the result referenced in class constructor. Additional Information ~~~~~~~~~~~~~~~~~~~~~~ From 9684ef56efa55ccb57982bc70d1c0f52feb33939 Mon Sep 17 00:00:00 2001 From: antoinemeyer5 Date: Tue, 24 Jan 2023 21:34:19 +0100 Subject: [PATCH 5/5] kokkos#120: API/core/builtinreducers/Sum fix monospace --- docs/source/API/core/builtinreducers/Sum.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/API/core/builtinreducers/Sum.rst b/docs/source/API/core/builtinreducers/Sum.rst index 651fd8c07..c7d76ad18 100644 --- a/docs/source/API/core/builtinreducers/Sum.rst +++ b/docs/source/API/core/builtinreducers/Sum.rst @@ -80,7 +80,7 @@ Functions .. cppkokkos:kokkosinlinefunction:: void init(value_type& val) const; - * Initialize ``val`` using the Kokkos::reduction_identity::sum() method. The default implementation sets ``val=0``. + * Initialize ``val`` using the ``Kokkos::reduction_identity::sum()`` method. The default implementation sets ``val=0``. .. cppkokkos:kokkosinlinefunction:: value_type& reference() const;