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

More extensive disentangling of Policy Traits (Replaces #3564) #3829

Merged
merged 15 commits into from
Mar 16, 2021

Conversation

dhollman
Copy link

@dhollman dhollman commented Mar 4, 2021

  • made implementation of require and prefer much easier
  • introduced the notion of a TraitSpecification, which helper templates use to make these things easier
  • moved each trait category into its own file, further emphasizing the separation of concerns
  • moved specification of defaults to a place more directly associated with the trait itself.
  • moved require and prefer overloads to be with the traits they interact with.
  • significant reduction in the amount of boilerplate associated with a trait. Much of this should be reusable for other composable entities in Kokkos, like Views

D. S. Hollman added 2 commits March 3, 2021 10:16
Right now, the size of the code for AnalyzePolicy scales quadratically
with the number of traits we analyze. With this change, the scaling is
linear and adding a new trait doesn't have to touch any other code.
The details of the runtime storage that may be associated with
a policy trait is now implemented only as part of the
trait-specific specializations. Traits are now fully disjoint with
the exception of defaults in AnalyzePolicy<void> and
PolicyTraitsWithDefaults
- made implementation of `require` and `prefer` much easier
- introduced the notion of a TraitSpecification, which helper
    templates use to make these things easier
- moved specification of defaults to a place more directly
    associated with the trait itself.
@dhollman dhollman force-pushed the analyze-policy-refactor-2 branch 6 times, most recently from d21c7b4 to 435e71b Compare March 5, 2021 01:15
core/src/traits/Kokkos_Traits_fwd.hpp Show resolved Hide resolved
core/src/traits/Kokkos_PolicyTraitAdaptor.hpp Outdated Show resolved Hide resolved
core/src/traits/Kokkos_OccupancyControlTrait.hpp Outdated Show resolved Hide resolved
core/src/traits/Kokkos_GraphKernelTrait.hpp Show resolved Hide resolved
core/src/traits/Kokkos_IndexTypeTrait.hpp Outdated Show resolved Hide resolved
core/src/traits/Kokkos_ScheduleTrait.hpp Outdated Show resolved Hide resolved
core/src/traits/Kokkos_WorkItemPropertyTrait.hpp Outdated Show resolved Hide resolved
core/src/traits/Kokkos_OccupancyControlTrait.hpp Outdated Show resolved Hide resolved
core/src/impl/Kokkos_AnalyzePolicy.hpp Outdated Show resolved Hide resolved
core/src/impl/Kokkos_AnalyzePolicy.hpp Outdated Show resolved Hide resolved
D. S. Hollman added 2 commits March 8, 2021 12:42
Reproducer: https://godbolt.org/z/r7GT6c
Toy example of workaround strategy: https://godbolt.org/z/YWjx83

Basically, we need to linearize the series of base classes to get
MSVC to do empty base optimization. It makes things a little uglier,
but I've tried to isolate as much of the workaround as possible
@dhollman dhollman changed the title (Depends on #3564) More extensive disentangling of Policy Traits (Replaces #3564) More extensive disentangling of Policy Traits Mar 8, 2021
@dhollman dhollman changed the title (Replaces #3564) More extensive disentangling of Policy Traits More extensive disentangling of Policy Traits (Replaces #3564) Mar 8, 2021
@crtrott
Copy link
Member

crtrott commented Mar 8, 2021

Retest this please.

Copy link
Contributor

@DavidPoliakoff DavidPoliakoff left a comment

Choose a reason for hiding this comment

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

Functionally, this all looks good. I'm temporarily putting a block on this, I've seen some (not-verified, likely-just-me-screwing-up-methodology) bad results on compile times and binary sizes

@DavidPoliakoff
Copy link
Contributor

Frustratingly, the results are compiler-dependent. Clang, this performs just fine with. Intel 19, it does pretty poorly, unfortunately. Daisy and I are discussing

@dhollman
Copy link
Author

@DavidPoliakoff's results appear to be in error, and we've talked about them. For Intel 19.0.5 with OpenMP and Serial enabled and CMAKE_BUILD_TYPE=Debug (with tests enabled) on kokkos-dev-2, I've got:

dshollm on kokkos-dev-2 in kokkos/build/develop
❯ du -s intel-19.0.5-*
2218676 intel-19.0.5-3829_debug
2250004 intel-19.0.5-3832_debug
2275740 intel-19.0.5-develop_debug

Both #3829 and #3832 reduce the size of the compiled output. The build times for all three are within the noise; about 2:10 seconds for make -j12 for all three (+/- 10 seconds, which was about the noise on repeat attempts in each case).

@dhollman dhollman requested a review from dalg24 March 11, 2021 22:06
@DavidPoliakoff
Copy link
Contributor

I'd cosign that, actually. I could see a methodology error that leads to different build times, but not binary sizes. I frankly don't have the time to reproduce, so go with Daisy's time, write it up to methodology errors, my bad

@DavidPoliakoff DavidPoliakoff dismissed their stale review March 11, 2021 22:13

Think this was mistaken

Comment on lines +99 to +100
template <class Policy, class ScheduleType>
constexpr auto require(Policy const& p, Kokkos::Schedule<ScheduleType>) {
Copy link
Member

Choose a reason for hiding this comment

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

Note that this is a new functionality. (I do not have any objection just wanted to highlight it.)

core/src/traits/Kokkos_WorkTagTrait.hpp Show resolved Hide resolved
core/unit_test/TestPolicyConstruction.hpp Show resolved Hide resolved
@masterleinad
Copy link
Contributor

Retest this please.

@masterleinad
Copy link
Contributor

Retest this please.

@dalg24 dalg24 merged commit 5a025f2 into kokkos:develop Mar 16, 2021
crtrott added a commit that referenced this pull request Apr 12, 2021
(Builds on #3829) More disentangling of AnalyzePolicy
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

5 participants