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

core: add is_team_handle and test #5375

Merged
merged 18 commits into from
Dec 12, 2022
Merged

Conversation

fnrizzi
Copy link
Contributor

@fnrizzi fnrizzi commented Aug 23, 2022

Content

Impl of is_team_handle (based on this concept syntax) and a test.

Notes/caveats

  • test is disabled for OpenMPTarget because it would fail due to this :
  // FIXME_OPENMPTARGET this function has the wrong interface and currently
  // ignores the reducer passed.
  template <class ValueType, class JoinOp>
  KOKKOS_INLINE_FUNCTION ValueType team_reduce(const ValueType& value,
                                               const JoinOp&) const {
  • disabled for OpenACC because the team handle impl does not conform to the concept (must be fixed) will open issue for this

@fnrizzi fnrizzi changed the title core: add is_team_handle and test [ready] core: add is_team_handle and test Aug 23, 2022
@fnrizzi fnrizzi changed the title [ready] core: add is_team_handle and test core: add is_team_handle and test Aug 23, 2022
@fnrizzi fnrizzi marked this pull request as draft August 23, 2022 13:07
@fnrizzi
Copy link
Contributor Author

fnrizzi commented Aug 23, 2022

retest this please

@fnrizzi fnrizzi changed the title core: add is_team_handle and test [ready] core: add is_team_handle and test Aug 23, 2022
@fnrizzi fnrizzi marked this pull request as ready for review August 23, 2022 15:03
@fnrizzi
Copy link
Contributor Author

fnrizzi commented Aug 23, 2022

retest this please

@fnrizzi
Copy link
Contributor Author

fnrizzi commented Aug 24, 2022

retest this please

@fnrizzi
Copy link
Contributor Author

fnrizzi commented Aug 24, 2022

CI failures are due to outofspace

core/src/Kokkos_Concepts.hpp Outdated Show resolved Hide resolved
core/unit_test/TestConcepts.hpp Outdated Show resolved Hide resolved
core/unit_test/TestConcepts.hpp Outdated Show resolved Hide resolved
core/unit_test/TestConcepts.hpp Outdated Show resolved Hide resolved
core/src/Kokkos_Concepts.hpp Outdated Show resolved Hide resolved
core/src/Kokkos_Concepts.hpp Outdated Show resolved Hide resolved
core/src/Kokkos_Concepts.hpp Outdated Show resolved Hide resolved
Copy link
Contributor

@JBludau JBludau left a comment

Choose a reason for hiding this comment

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

It is good, that we check the interface of team_handle . But do we actually require the values the team_handle returns to fulfill comply with an expected behavior?

core/src/Kokkos_Concepts.hpp Outdated Show resolved Hide resolved
@masterleinad
Copy link
Contributor

What is this used for?

@fnrizzi fnrizzi marked this pull request as draft August 25, 2022 18:11
@fnrizzi
Copy link
Contributor Author

fnrizzi commented Sep 5, 2022

decided to:

  • simplify trait detection to conform to how all other concepts are done
  • use the full trait detection to write a test

@jstrzebonski
Copy link

jstrzebonski commented Oct 27, 2022

decided to:

* simplify trait detection to conform to how all other concepts are done

* use the full trait detection to write a test

@dalg24 @masterleinad
In that case should we implement is_team_handle with KOKKOS_IMPL_IS_CONCEPT, similary to, for example, is_execution_space?

As far as I understand, that implementation would add KOKKOS_IMPL_IS_CONCEPT(team_handle) to Kokkos_Concepts.hpp, and then for every Team that we expect is_team_handle<T> to return true, we should add alias using team_handle = .... And basically, that's it.

@fnrizzi
Copy link
Contributor Author

fnrizzi commented Oct 27, 2022

@jstrzebonski can you please post also the snippets you showed me today? So that is more clear what we propose

@jstrzebonski
Copy link

For example is_execution_space for Kokkos::Cuda gives true, because of the alias added to Cuda class:

class Cuda {
 public:
  //! \name Type declarations that all Kokkos execution spaces must provide.
  //@{

  //! Tag this class as a kokkos execution space
  using execution_space = Cuda;

...

Similary is_team_handle for CudaTeamMember would require adding team_handle alias, for example:

class CudaTeamMember {
 public:
  using execution_space      = Kokkos::Cuda;
  using scratch_memory_space = execution_space::scratch_memory_space;

  using team_handle = CudaTeamMember;

  ...

@fnrizzi fnrizzi changed the title [ready] core: add is_team_handle and test core: add is_team_handle and test Nov 28, 2022
@fnrizzi fnrizzi added this to In progress in Developer: FRANCESCO RIZZI Nov 28, 2022
@fnrizzi fnrizzi marked this pull request as ready for review November 28, 2022 11:12
@fnrizzi
Copy link
Contributor Author

fnrizzi commented Nov 28, 2022

failure is unrelated

Copy link
Member

@crtrott crtrott left a comment

Choose a reason for hiding this comment

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

Not sure that we want to get into the business of implementing tests of tests?

core/unit_test/TestConcepts.hpp Show resolved Hide resolved
@fnrizzi
Copy link
Contributor Author

fnrizzi commented Dec 6, 2022

failure is unrelated

core/unit_test/TestConcepts.hpp Show resolved Hide resolved
core/unit_test/TestConcepts.hpp Outdated Show resolved Hide resolved
core/unit_test/TestConcepts.hpp Outdated Show resolved Hide resolved
Comment on lines 62 to 81
/*-------------------------------------------------
begin test for team_handle concept

Read before moving on to the test below:
The implementation inside Kokkos/core of the team_handle concept follows
that of execution space, memory space, etc as shown here:

https://github.com/kokkos/kokkos/blob/61d7db55fceac3318c987a291f77b844fd94c165/core/src/Kokkos_Concepts.hpp#L160

which has a key aspect: for performance reasons, it does *not* check the
complete trait. So below we also provide a complete team handle concept trait
based on this

https://kokkos.github.io/kokkos-core-wiki/API/core/policies/TeamHandleConcept.html

which completely checks the trait and we use to validate things.
This complete trait was originally used as implementation but was moved
here as discussed in this PR: https://github.com/kokkos/kokkos/pull/5375

------------------------------------------------- */
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/*-------------------------------------------------
begin test for team_handle concept
Read before moving on to the test below:
The implementation inside Kokkos/core of the team_handle concept follows
that of execution space, memory space, etc as shown here:
https://github.com/kokkos/kokkos/blob/61d7db55fceac3318c987a291f77b844fd94c165/core/src/Kokkos_Concepts.hpp#L160
which has a key aspect: for performance reasons, it does *not* check the
complete trait. So below we also provide a complete team handle concept trait
based on this
https://kokkos.github.io/kokkos-core-wiki/API/core/policies/TeamHandleConcept.html
which completely checks the trait and we use to validate things.
This complete trait was originally used as implementation but was moved
here as discussed in this PR: https://github.com/kokkos/kokkos/pull/5375
------------------------------------------------- */

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why you want to remove this? 12 months from now somebody will look at this and wonder why the full trait is here... the comment helps IMO

Copy link
Member

Choose a reason for hiding this comment

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

20 lines to say something (arguably) obvious. Can you say in one or two lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it quite a bit, hope it is ok now

core/unit_test/TestConcepts.hpp Outdated Show resolved Hide resolved
core/unit_test/TestConcepts.hpp Outdated Show resolved Hide resolved
Comment on lines 188 to 197
// actual test begins here

/*
disabling as follows:

- OpenMPTARGET: due to this
https://github.com/kokkos/kokkos/blob/2d6cbad7e079eb45ae69ac6a59929d9fcf10409a/core/src/OpenMPTarget/Kokkos_OpenMPTarget_Exec.hpp#L860

- OpenACC: not supporting teams yet
*/
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// actual test begins here
/*
disabling as follows:
- OpenMPTARGET: due to this
https://github.com/kokkos/kokkos/blob/2d6cbad7e079eb45ae69ac6a59929d9fcf10409a/core/src/OpenMPTarget/Kokkos_OpenMPTarget_Exec.hpp#L860
- OpenACC: not supporting teams yet
*/
// FIXME_OPENMPTARGET https://github.com/kokkos/kokkos/blob/2d6cbad7e079eb45ae69ac6a59929d9fcf10409a/core/src/OpenMPTarget/Kokkos_OpenMPTarget_Exec.hpp#L860-L864

@rgayatri23 please advise why the interface departure is not something that can be fixed now

There is some support for teams that was merged in the OpenACC backend. Did you check since that change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

trying now again

Copy link
Contributor Author

@fnrizzi fnrizzi Dec 6, 2022

Choose a reason for hiding this comment

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

https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/11320/pipeline/47

OpenACCTeamMember is missing the following method:

    template <typename ReducerType>
    KOKKOS_INLINE_FUNCTION std::enable_if_t<is_reducer<ReducerType>::value>
    team_reduce(ReducerType const& reducer) const noexcept;


template <class T>
inline constexpr bool is_team_handle_complete_trait_check_v =
is_team_handle_complete_trait_check<T>::value;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
is_team_handle_complete_trait_check<T>::value;
is_team_handle_complete_trait_check<T>::value && Kokkos::is_team_handle_v<T>;

that way you don't need to duplicate all that code below

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 its fine. Makes it more obvious that the primary team handle is tested.


template <class T>
inline constexpr bool is_team_handle_complete_trait_check_v =
is_team_handle_complete_trait_check<T>::value;
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 its fine. Makes it more obvious that the primary team handle is tested.

@crtrott crtrott merged commit 6a49537 into kokkos:develop Dec 12, 2022
@fnrizzi fnrizzi mentioned this pull request Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

6 participants