Skip to content

feature: method to get reference to tuple elements satisfying type_trait #174

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

johnbowen42
Copy link
Collaborator

@johnbowen42 johnbowen42 commented May 8, 2025

For context, this is a function I wrote for LLNL/RAJA#1799, where we need to easily extract reference to kernel parameters that are reducers. The interface requires passing a tuple typed object that the user desires to extract elements from, as well as a class-template that inherits from std::true_type for desired elements. Here are some alternatives I considered:

  • Adding ability to return pointer to element, copy of element, or reference to element. Right now the method only returns references to elements
  • Instead of the type-trait interface, passing the template class directly as a parameter to the method. This has a number of pitfalls, including the case where the desired template class itself is dependent upon other instantiations of template classes for its definition

I am not committed to the name get_refs_to_elements_by_type_trait and would like to hear alternative ideas

@trws
Copy link
Member

trws commented May 8, 2025

Interesting, not a bad idea. Would you be willing to add a link to where it's used in that PR? I'm curious about the usage pattern, the implementation looks easy to follow, which is great, but we might be able to make it a bit faster on template expansion depending on the usage.

@johnbowen42
Copy link
Collaborator Author

johnbowen42 commented May 9, 2025

Interesting, not a bad idea. Would you be willing to add a link to where it's used in that PR? I'm curious about the usage pattern, the implementation looks easy to follow, which is great, but we might be able to make it a bit faster on template expansion depending on the usage.

@trws here https://github.com/LLNL/RAJA/blob/18f2b9142081167656e8afeaab039eb3461bd7f5/include/RAJA/pattern/params/forall.hpp#L21

This method gets used by every call of resolve and combine. I changed my PR to reflect these changes, but this will break CI for the RAJA PR. Also, we will need to rewrite camps' git history a little bit and bring in this PR prior to the cxx17 change.

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.

2 participants