From 974c5c8812b0c578cab315972a21d16659a61baa Mon Sep 17 00:00:00 2001 From: antoinemeyer5 Date: Wed, 4 Jan 2023 18:48:06 +0100 Subject: [PATCH 1/5] kokkos#120: API/core/policies/TeamVectorRange transition from .md to .rst init --- .../API/core/policies/TeamVectorRange.md | 86 ----------------- .../API/core/policies/TeamVectorRange.rst | 93 +++++++++++++++++++ 2 files changed, 93 insertions(+), 86 deletions(-) delete mode 100644 docs/source/API/core/policies/TeamVectorRange.md create mode 100644 docs/source/API/core/policies/TeamVectorRange.rst diff --git a/docs/source/API/core/policies/TeamVectorRange.md b/docs/source/API/core/policies/TeamVectorRange.md deleted file mode 100644 index 2b5efc80d..000000000 --- a/docs/source/API/core/policies/TeamVectorRange.md +++ /dev/null @@ -1,86 +0,0 @@ -# `TeamVectorRange` - -Header File: `Kokkos_Core.hpp` - -Usage: -```c++ -parallel_for(TeamVectorRange(team,range), [=] (int i) {...}); -parallel_reduce(TeamVectorRange(team,begin,end), - [=] (int i, double& lsum) {...},sum); -``` - -TeamVectorRange is a [nested execution policy](NestedPolicies) used inside hierarchical parallelism. -In contrast to global policies, the public interface for nested policies is implemented -as functions, in order to enable implicit templating on the execution space type via -the team handle. - -## Synopsis -```c++ -template -/* implementation defined */ TeamVectorRange(TeamMemberType team, iType count); -template -/* implementation defined */ TeamVectorRange(TeamMemberType team, iType1 begin, iType2 end); -``` - -## Description - - * ```c++ - template - /* Implementation defined */ TeamVectorRange(TeamMemberType team, iType count); - ``` - Splits the index range `0` to `count-1` over the threads of the team and their vector lanes. - * **Arguments** - * `team`: a handle to the calling team execution context. - * `count`: index range length. - - * **Returns** - * Implementation defined type. - - * **Requirements** - * `TeamMemberType` is a type that models [TeamHandle](TeamHandleConcept) - * `std::is_integral::value` is true. - * Every member thread of `team` must call the operation in the same branch, i.e. it is not legal to have some - threads call this function in one branch, and the other threads of `team` call it in another branch. - * `count >= 0 ` is true; - - * ```c++ - template - /* Implementation defined */ TeamVectorRange(TeamMemberType team, iType1 begin, iType2 end); - ``` - Splits the index range `begin` to `end-1` over the threads of the team and their vector lanes. - * **Arguments** - * `team`: a handle to the calling team execution context. - * `begin`: index range begin. - * `end`: index range end. - - * **Returns** - * Implementation defined type. - - * **Requirements** - - * `TeamMemberType` is a type that models [TeamHandle](TeamHandleConcept) - * `std::is_integral::value` is true. - * `std::is_integral::value` is true. - * Every member thread of `team` must call the operation in the same branch, i.e. it is not legal to have some - threads call this function in one branch, and the other threads of `team` call it in another branch.. - * `end >= begin ` is true; - -## Examples - -```c++ -typedef TeamPolicy<>::member_type team_handle; -parallel_for(TeamPolicy<>(N,AUTO,4), KOKKOS_LAMBDA (const team_handle& team) { - int n = team.league_rank(); - parallel_for(TeamVectorRange(team,M), [&] (const int& i) { - A(n,i) = B(n) + i; - }); - team.team_barrier(); - int team_sum; - parallel_reduce(TeamVectorRange(team,M), [&] (const int& i, int& lsum) { - lsum += A(n,i); - },team_sum); - single(PerTeam(team),[&] () { - A_rowsum(n) += team_sum; - }); -}); -``` diff --git a/docs/source/API/core/policies/TeamVectorRange.rst b/docs/source/API/core/policies/TeamVectorRange.rst new file mode 100644 index 000000000..74785f51f --- /dev/null +++ b/docs/source/API/core/policies/TeamVectorRange.rst @@ -0,0 +1,93 @@ +``TeamVectorRange`` +=================== + +.. role::cpp(code) + :language: cpp + +Header File: ```` + +Usage +----- + +.. code-block:: cpp + + parallel_for(TeamVectorRange(team,range), [=] (int i) {...}); + parallel_reduce(TeamVectorRange(team,begin,end), + [=] (int i, double& lsum) {...},sum); + +TeamVectorRange is a `nested execution policy `_ used inside hierarchical parallelism. +In contrast to global policies, the public interface for nested policies is implemented +as functions, in order to enable implicit templating on the execution space type via +the team handle. + +Synopsis +-------- + +.. code-block:: cpp + + template + /* implementation defined */ TeamVectorRange(TeamMemberType team, iType count); + template + /* implementation defined */ TeamVectorRange(TeamMemberType team, iType1 begin, iType2 end); + +Description +----------- + +.. cpp:function:: template TeamVectorRange(TeamMemberType team, iType count); + + Splits the index range ``0`` to ``count-1`` over the threads of the team and their vector lanes. + + * **Arguments** + - ``team``: a handle to the calling team execution context. + - ``count``: index range length. + + * **Returns** + - Implementation defined type. + + * **Requirements** + - ``TeamMemberType`` is a type that models `TeamHandle `_ + - ``std::is_integral::value`` is true. + - Every member thread of ``team`` must call the operation in the same branch, i.e. it is not legal to have some + threads call this function in one branch, and the other threads of ``team`` call it in another branch. + - ``count >= 0`` is true; + +.. cpp:function:: template TeamVectorRange(TeamMemberType team, iType1 begin, iType2 end); + + Splits the index range ``begin`` to ``end-1`` over the threads of the team and their vector lanes. + + * **Arguments** + - ``team``: a handle to the calling team execution context. + - ``begin``: index range begin. + - ``end``: index range end. + + * **Returns** + - Implementation defined type. + + * **Requirements** + - ``TeamMemberType`` is a type that models `TeamHandle `_ + - ``std::is_integral::value`` is true. + - ``std::is_integral::value`` is true. + - Every member thread of ``team`` must call the operation in the same branch, i.e. it is not legal to have some + threads call this function in one branch, and the other threads of ``team`` call it in another branch.. + - ``end >= begin`` is true; + +Examples +-------- + +.. code-block:: cpp + + typedef TeamPolicy<>::member_type team_handle; + parallel_for(TeamPolicy<>(N,AUTO,4), KOKKOS_LAMBDA (const team_handle& team) { + int n = team.league_rank(); + parallel_for(TeamVectorRange(team,M), [&] (const int& i) { + A(n,i) = B(n) + i; + }); + team.team_barrier(); + int team_sum; + parallel_reduce(TeamVectorRange(team,M), [&] (const int& i, int& lsum) { + lsum += A(n,i); + },team_sum); + single(PerTeam(team),[&] () { + A_rowsum(n) += team_sum; + }); + }); From 8b4e42b07be10d4e1f73479d68ff3570f426ddde Mon Sep 17 00:00:00 2001 From: antoinemeyer5 Date: Sun, 8 Jan 2023 22:52:50 +0100 Subject: [PATCH 2/5] kokkos#120: API/core/policies/TeamVectorRange transition from .md to .rst fix return type --- .../API/core/policies/TeamVectorRange.rst | 74 ++++++++++--------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/docs/source/API/core/policies/TeamVectorRange.rst b/docs/source/API/core/policies/TeamVectorRange.rst index 74785f51f..41ce4f3e0 100644 --- a/docs/source/API/core/policies/TeamVectorRange.rst +++ b/docs/source/API/core/policies/TeamVectorRange.rst @@ -33,43 +33,49 @@ Synopsis Description ----------- -.. cpp:function:: template TeamVectorRange(TeamMemberType team, iType count); - - Splits the index range ``0`` to ``count-1`` over the threads of the team and their vector lanes. +.. code-block:: cpp - * **Arguments** - - ``team``: a handle to the calling team execution context. - - ``count``: index range length. - - * **Returns** - - Implementation defined type. - - * **Requirements** - - ``TeamMemberType`` is a type that models `TeamHandle `_ - - ``std::is_integral::value`` is true. - - Every member thread of ``team`` must call the operation in the same branch, i.e. it is not legal to have some - threads call this function in one branch, and the other threads of ``team`` call it in another branch. - - ``count >= 0`` is true; - -.. cpp:function:: template TeamVectorRange(TeamMemberType team, iType1 begin, iType2 end); + template + /* implementation defined */ TeamVectorRange(TeamMemberType team, iType count); + +Splits the index range ``0`` to ``count-1`` over the threads of the team and their vector lanes. + +* **Arguments** + - ``team``: a handle to the calling team execution context. + - ``count``: index range length. + +* **Returns** + - Implementation defined type. - Splits the index range ``begin`` to ``end-1`` over the threads of the team and their vector lanes. +* **Requirements** + - ``TeamMemberType`` is a type that models `TeamHandle `_ + - ``std::is_integral::value`` is true. + - Every member thread of ``team`` must call the operation in the same branch, i.e. it is not legal to have some + threads call this function in one branch, and the other threads of ``team`` call it in another branch. + - ``count >= 0`` is true; + +.. code-block:: cpp - * **Arguments** - - ``team``: a handle to the calling team execution context. - - ``begin``: index range begin. - - ``end``: index range end. - - * **Returns** - - Implementation defined type. - - * **Requirements** - - ``TeamMemberType`` is a type that models `TeamHandle `_ - - ``std::is_integral::value`` is true. - - ``std::is_integral::value`` is true. - - Every member thread of ``team`` must call the operation in the same branch, i.e. it is not legal to have some - threads call this function in one branch, and the other threads of ``team`` call it in another branch.. - - ``end >= begin`` is true; + template + /* implementation defined */ TeamVectorRange(TeamMemberType team, iType1 begin, iType2 end); + +Splits the index range ``begin`` to ``end-1`` over the threads of the team and their vector lanes. + +* **Arguments** + - ``team``: a handle to the calling team execution context. + - ``begin``: index range begin. + - ``end``: index range end. + +* **Returns** + - Implementation defined type. + +* **Requirements** + - ``TeamMemberType`` is a type that models `TeamHandle `_ + - ``std::is_integral::value`` is true. + - ``std::is_integral::value`` is true. + - Every member thread of ``team`` must call the operation in the same branch, i.e. it is not legal to have some + threads call this function in one branch, and the other threads of ``team`` call it in another branch.. + - ``end >= begin`` is true; Examples -------- From cc29c13522d3e706fc977558db78f06d035486b4 Mon Sep 17 00:00:00 2001 From: antoinemeyer5 Date: Wed, 1 Feb 2023 11:12:16 +0100 Subject: [PATCH 3/5] kokkos#120: API/core/policies/TeamVectorRange fix cppkokkos:function --- docs/source/API/core/policies/TeamVectorRange.rst | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/docs/source/API/core/policies/TeamVectorRange.rst b/docs/source/API/core/policies/TeamVectorRange.rst index 41ce4f3e0..2e53ce5dd 100644 --- a/docs/source/API/core/policies/TeamVectorRange.rst +++ b/docs/source/API/core/policies/TeamVectorRange.rst @@ -1,8 +1,8 @@ ``TeamVectorRange`` =================== -.. role::cpp(code) - :language: cpp +.. role::cppkokkos(code) + :language: cppkokkos Header File: ```` @@ -33,10 +33,7 @@ Synopsis Description ----------- -.. code-block:: cpp - - template - /* implementation defined */ TeamVectorRange(TeamMemberType team, iType count); +.. cppkokkos:function:: template /* implementation defined */ TeamVectorRange(TeamMemberType team, iType count); Splits the index range ``0`` to ``count-1`` over the threads of the team and their vector lanes. @@ -54,10 +51,7 @@ Splits the index range ``0`` to ``count-1`` over the threads of the team and the threads call this function in one branch, and the other threads of ``team`` call it in another branch. - ``count >= 0`` is true; -.. code-block:: cpp - - template - /* implementation defined */ TeamVectorRange(TeamMemberType team, iType1 begin, iType2 end); +.. cppkokkos:function:: template /* implementation defined */ TeamVectorRange(TeamMemberType team, iType1 begin, iType2 end); Splits the index range ``begin`` to ``end-1`` over the threads of the team and their vector lanes. From 01b38ba5b11323ff75584f2b07430855cc3850e1 Mon Sep 17 00:00:00 2001 From: antoinemeyer5 Date: Wed, 1 Feb 2023 11:15:12 +0100 Subject: [PATCH 4/5] kokkos#120: API/core/policies/TeamVectorRange cant use cppkokkos with commentary /**/ so keep code block cpp --- docs/source/API/core/policies/TeamVectorRange.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/source/API/core/policies/TeamVectorRange.rst b/docs/source/API/core/policies/TeamVectorRange.rst index 2e53ce5dd..614456fd4 100644 --- a/docs/source/API/core/policies/TeamVectorRange.rst +++ b/docs/source/API/core/policies/TeamVectorRange.rst @@ -33,7 +33,10 @@ Synopsis Description ----------- -.. cppkokkos:function:: template /* implementation defined */ TeamVectorRange(TeamMemberType team, iType count); +.. code-block:: cpp + + template + /* implementation defined */ TeamVectorRange(TeamMemberType team, iType count); Splits the index range ``0`` to ``count-1`` over the threads of the team and their vector lanes. @@ -51,7 +54,10 @@ Splits the index range ``0`` to ``count-1`` over the threads of the team and the threads call this function in one branch, and the other threads of ``team`` call it in another branch. - ``count >= 0`` is true; -.. cppkokkos:function:: template /* implementation defined */ TeamVectorRange(TeamMemberType team, iType1 begin, iType2 end); +.. code-block:: cpp + + template + /* implementation defined */ TeamVectorRange(TeamMemberType team, iType1 begin, iType2 end); Splits the index range ``begin`` to ``end-1`` over the threads of the team and their vector lanes. From 1ead899a7e9b673d9d99d2b0ea250e7dd3e292b8 Mon Sep 17 00:00:00 2001 From: Francesco Rizzi Date: Sun, 5 Feb 2023 10:57:52 +0100 Subject: [PATCH 5/5] fix spurious line change and indentation --- .../API/core/policies/TeamVectorRange.rst | 83 +++++++++---------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/docs/source/API/core/policies/TeamVectorRange.rst b/docs/source/API/core/policies/TeamVectorRange.rst index 614456fd4..f595593d7 100644 --- a/docs/source/API/core/policies/TeamVectorRange.rst +++ b/docs/source/API/core/policies/TeamVectorRange.rst @@ -2,7 +2,7 @@ =================== .. role::cppkokkos(code) - :language: cppkokkos + :language: cppkokkos Header File: ```` @@ -11,38 +11,38 @@ Usage .. code-block:: cpp - parallel_for(TeamVectorRange(team,range), [=] (int i) {...}); - parallel_reduce(TeamVectorRange(team,begin,end), - [=] (int i, double& lsum) {...},sum); + parallel_for(TeamVectorRange(team,range), [=] (int i) {...}); + parallel_reduce(TeamVectorRange(team,begin,end), + [=] (int i, double& lsum) {...},sum); -TeamVectorRange is a `nested execution policy `_ used inside hierarchical parallelism. -In contrast to global policies, the public interface for nested policies is implemented -as functions, in order to enable implicit templating on the execution space type via +TeamVectorRange is a `nested execution policy `_ used inside hierarchical parallelism. +In contrast to global policies, the public interface for nested policies is implemented +as functions, in order to enable implicit templating on the execution space type via the team handle. Synopsis -------- .. code-block:: cpp - - template - /* implementation defined */ TeamVectorRange(TeamMemberType team, iType count); - template - /* implementation defined */ TeamVectorRange(TeamMemberType team, iType1 begin, iType2 end); + + template + /* implementation defined */ TeamVectorRange(TeamMemberType team, iType count); + template + /* implementation defined */ TeamVectorRange(TeamMemberType team, iType1 begin, iType2 end); Description ----------- .. code-block:: cpp - - template - /* implementation defined */ TeamVectorRange(TeamMemberType team, iType count); -Splits the index range ``0`` to ``count-1`` over the threads of the team and their vector lanes. + template + /* implementation defined */ TeamVectorRange(TeamMemberType team, iType count); + +Splits the index range ``0`` to ``count-1`` over the threads of the team and their vector lanes. * **Arguments** - ``team``: a handle to the calling team execution context. - - ``count``: index range length. + - ``count``: index range length. * **Returns** - Implementation defined type. @@ -50,20 +50,20 @@ Splits the index range ``0`` to ``count-1`` over the threads of the team and the * **Requirements** - ``TeamMemberType`` is a type that models `TeamHandle `_ - ``std::is_integral::value`` is true. - - Every member thread of ``team`` must call the operation in the same branch, i.e. it is not legal to have some + - Every member thread of ``team`` must call the operation in the same branch, i.e. it is not legal to have some threads call this function in one branch, and the other threads of ``team`` call it in another branch. - ``count >= 0`` is true; - + .. code-block:: cpp - - template - /* implementation defined */ TeamVectorRange(TeamMemberType team, iType1 begin, iType2 end); -Splits the index range ``begin`` to ``end-1`` over the threads of the team and their vector lanes. + template + /* implementation defined */ TeamVectorRange(TeamMemberType team, iType1 begin, iType2 end); + +Splits the index range ``begin`` to ``end-1`` over the threads of the team and their vector lanes. * **Arguments** - ``team``: a handle to the calling team execution context. - - ``begin``: index range begin. + - ``begin``: index range begin. - ``end``: index range end. * **Returns** @@ -73,27 +73,26 @@ Splits the index range ``begin`` to ``end-1`` over the threads of the team and t - ``TeamMemberType`` is a type that models `TeamHandle `_ - ``std::is_integral::value`` is true. - ``std::is_integral::value`` is true. - - Every member thread of ``team`` must call the operation in the same branch, i.e. it is not legal to have some - threads call this function in one branch, and the other threads of ``team`` call it in another branch.. + - Every member thread of ``team`` must call the operation in the same branch, i.e. it is not legal to have some threads call this function in one branch, and the other threads of ``team`` call it in another branch.. - ``end >= begin`` is true; Examples -------- .. code-block:: cpp - - typedef TeamPolicy<>::member_type team_handle; - parallel_for(TeamPolicy<>(N,AUTO,4), KOKKOS_LAMBDA (const team_handle& team) { - int n = team.league_rank(); - parallel_for(TeamVectorRange(team,M), [&] (const int& i) { - A(n,i) = B(n) + i; - }); - team.team_barrier(); - int team_sum; - parallel_reduce(TeamVectorRange(team,M), [&] (const int& i, int& lsum) { - lsum += A(n,i); - },team_sum); - single(PerTeam(team),[&] () { - A_rowsum(n) += team_sum; - }); - }); + + typedef TeamPolicy<>::member_type team_handle; + parallel_for(TeamPolicy<>(N,AUTO,4), KOKKOS_LAMBDA (const team_handle& team) { + int n = team.league_rank(); + parallel_for(TeamVectorRange(team,M), [&] (const int& i) { + A(n,i) = B(n) + i; + }); + team.team_barrier(); + int team_sum; + parallel_reduce(TeamVectorRange(team,M), [&] (const int& i, int& lsum) { + lsum += A(n,i); + },team_sum); + single(PerTeam(team),[&] () { + A_rowsum(n) += team_sum; + }); + });