Skip to content

switch to const ref for CRTP then allow lambda to copy capture #509

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

Merged
merged 2 commits into from
May 27, 2025

Conversation

Yurlungur
Copy link
Collaborator

@Yurlungur Yurlungur commented May 23, 2025

PR Summary

@Yannicked reported in issue #508 that the copies int he base class were impacting the vector API performance. One copy is necessary (on GPUs) as the EOS object, rather than the pointer, must be captured by value. This requires either pulling out the object or capturing *this with, e.g., KOKKOS_CLASS_LAMBDA.

However, we are currently performing two copies: 1 when we perform CRTP to typecast the object to the child type, and one when we capture. It turns out the first copy can be eliminated. We can simply create the CRTP by reference, as [=] in the lambda implies assignment operator and so the underlying object is captured by value even if it is a reference in scope. See here for an example.

This MR eliminates that extraneous copy.

PR Checklist

  • Adds a test for any bugs fixed. Adds tests for new features.
  • Format your changes by using the make format command after configuring with cmake.
  • Document any new features, update documentation for changes made.
  • Make sure the copyright notice on any files you modified is up to date.
  • After creating a pull request, note it in the CHANGELOG.md file.
  • LANL employees: make sure tests pass both on the github CI and on the Darwin CI

If preparing for a new release, in addition please check the following:

  • Update the version in cmake.
  • Move the changes in the CHANGELOG.md file under a new header for the new release, and reset the categories.
  • Ensure that any when='@main' dependencies are updated to the release version in the package.py

@Yurlungur Yurlungur self-assigned this May 23, 2025
@Yurlungur Yurlungur added the Performance Improving performance label May 23, 2025
Copy link
Collaborator

@jhp-lanl jhp-lanl left a comment

Choose a reason for hiding this comment

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

As long as this passes our internal GPU tests, I'm happy. Great find @Yurlungur !

@Yurlungur Yurlungur merged commit 6e9280c into main May 27, 2025
9 checks passed
@Yurlungur Yurlungur deleted the jmm/ref-in-crtp branch May 27, 2025 19:10
@Yurlungur Yurlungur mentioned this pull request May 28, 2025
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Improving performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EOS copies impacting performance with small array calls
3 participants