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

CTAD Deduction guides for TeamPolicy v2 #6117

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from

Conversation

nliber
Copy link
Contributor

@nliber nliber commented May 10, 2023

Seeing if adding an Impl::TeamPolicyCommon between TeamPolicy and Impl::TeamPolicyInternal will get around the compiler ICEing bugs.

@nliber nliber force-pushed the ctad-teampolicy-crtp branch 2 times, most recently from ddafb16 to 8c9f00a Compare June 23, 2023 18:07
@nliber
Copy link
Contributor Author

nliber commented Jun 26, 2023

In order to get around various compiler bugs with regards to deduction guides, the following changes were made to TeamPolicy:

Introduction of Impl::TeamPolicyCommon, and move the implementation of TeamPolicy into it. This is done so as not to have duplicate code. The public inheritance hierarchy looks like

Before: TeamPolicy <- TeamPolicyInternal
After: TeamPolicy <- TeamPolicyCommon <- TeamPolicyInternal

TeamPolicyInternal could not be used for this. While it may look like there is a primary template for TeamPolicyInternal with common code, it turns out that it is specialized for every backend. The primary template definition for TeamPolicyInternal is not used for anything, other than being an archetype for anyone implementing a backend.

TeamPolicyCommon deliberately does not have a primary template, as this combined with a parameter pack was causing the deduction guides to ICE under certain compilers (nvcc). It only has a partial specialization.

In the partial specialization of TeamPolicyCommon, the first template parameter is the ExecutionSpace. This was picked because it is also the first template parameter needed for TeamPolicyInternal, although any parameter could have been used (including just ignoring it). The key part is that this implementation is a specialization of the undefined primary template.

Initially, when the constructors were moved from TeamPolicy into TeamPolicyCommon, the TeamPolicy constructors were replaced with inheriting constructors. This resulted in a compiler bug (icpc) due to inheriting constructors not working correctly when the inherited constructors had defaulted parameters, so the constructors in TeamPolicyCommon were changed so that none of them include defaulted parameters.

For some compilers, an inline static variable isn't considered as used when only in an unevaluated context (as they are in the compile time tests), so they are now marked as [[maybe_unused]].

@nliber
Copy link
Contributor Author

nliber commented Jul 3, 2023

retest this please

@nliber nliber force-pushed the ctad-teampolicy-crtp branch 2 times, most recently from 25e2e0d to 7ee8129 Compare July 11, 2023 17:51
@nliber nliber marked this pull request as ready for review July 12, 2023 17:54
core/src/Kokkos_ExecPolicy.hpp Outdated Show resolved Hide resolved
core/src/Kokkos_ExecPolicy.hpp Outdated Show resolved Hide resolved
@nliber nliber force-pushed the ctad-teampolicy-crtp branch 2 times, most recently from 7c9afe9 to e10abac Compare March 13, 2024 17:26
@nliber nliber changed the title Deduction guides for TeamPolicy v2 CTAD Deduction guides for TeamPolicy v2 Mar 13, 2024
Copy link
Contributor

@nmm0 nmm0 left a comment

Choose a reason for hiding this comment

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

Some initial comments

core/src/Kokkos_ExecPolicy.hpp Outdated Show resolved Hide resolved
core/src/Kokkos_ExecPolicy.hpp Show resolved Hide resolved
core/src/Kokkos_ExecPolicy.hpp Show resolved Hide resolved
core/src/Kokkos_ExecPolicy.hpp Show resolved Hide resolved
nliber and others added 13 commits April 2, 2024 16:32
a forward declaration requiring at least one (defaulted)
template parameter and two partial specializations TeamPolicy<P> and
TeamPolicy<P1, P2, Properties...>.
TestTeamPolicyConstructors to avoid internal linkage problems
with various compilers and compile time tests
Added some static_asserts enforcing TeamPolicyCommon usage assumptions
parameters to see if this fixes the issue with icpc and OPENMP builds
in TestTeamPolicyCTAD, as they are never referenced
outside of unevaluated contexts.
nliber and others added 11 commits April 2, 2024 16:32
into TeamPolicy, as TeamPolicyCommon is not an execution policy.
Added the private typedef "team_policy" for use inside TeamPolicyCommon.
        ImplicitlyConvertibleToDefaultExecutionSpace::operator Kokkos::DefaultExecutionSpace" was declared but never referenced
because it is only referenced in unevaluated contexts.
Marking it as [[maybe_unused]]
…d]] on

ImplicitlyConvertibleToDefaultExecutionSpace::operator
Kokkos::DefaultExecutionSpace() const

by defining it and implicitly calling it in another [[maybe_unused]] static inline
variable.
Copy link
Contributor

@masterleinad masterleinad left a comment

Choose a reason for hiding this comment

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

OK with me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants