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

Detect mismatch of execution spaces in functors #4655

Merged

Conversation

masterleinad
Copy link
Contributor

Fixes #2074.

Copy link
Contributor

@ldh4 ldh4 left a comment

Choose a reason for hiding this comment

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

I was in a process of converting my initial solution, similar to this, into a runtime check in attempt to make an unit-test, but I think compile-time check is sufficient, given that it is a fairly simple check.

Copy link
Member

@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

I would prefer if you used is_detected<execution_space_t, Policy>::value instead of std::is_same<detected_t<execution_space_t, Policy>, nonesuch>::value

core/src/Kokkos_Parallel.hpp Outdated Show resolved Hide resolved
@masterleinad masterleinad added this to In progress in Kokkos Release 3.6 via automation Jan 12, 2022
@masterleinad masterleinad added this to Awaiting Feedback in Developer: Daniel Arndt Jan 12, 2022
@masterleinad masterleinad moved this from In progress to Awaiting Feedback in Kokkos Release 3.6 Jan 12, 2022
@masterleinad
Copy link
Contributor Author

@dalg24 I addressed your suggestions.

In my opinion, the changes here would be a good example of why defining detected_or would be convenient. I could use the result both for checking that the check was successful and get the referenced type in case of success.

@dalg24
Copy link
Member

dalg24 commented Jan 13, 2022

In my opinion, the changes here would be a good example of why defining detected_or would be convenient. I could use the result both for checking that the check was successful and get the referenced type in case of success.

Fair enough. I still don't like the idea of writing

using FunctorExecutionSpace = detected_or<MyDefault, execution_space_t, Functor>;
static_assert(!typename FunctorExecutionSpace::value_type::value || ...);
// or
static_assert(!std::is_same<MyDefault, typename FunctorExecutionSpace::type>::value || ...);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Developer: Daniel Arndt
Awaiting Feedback
Development

Successfully merging this pull request may close these issues.

Mismatch between execution_space tag in Functor and execution space in execution policy is silently ignored
5 participants