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

Consider replacing ternary expressions with multiplicative conditionals #319

Open
jhp-lanl opened this issue Oct 27, 2023 · 2 comments
Open
Labels
good first issue Good for newcomers Performance Improving performance

Comments

@jhp-lanl
Copy link
Collaborator

Per @Yurlungur we may want to replace

x = cond ? a : b

with

x = (cond) * a + (1 - cond) * b

to reduce branching and improve GPU performance.

This might be premature optimization, but it also might be a good way to specify default handling of NaNs as well.

@jhp-lanl jhp-lanl mentioned this issue Oct 27, 2023
6 tasks
@jhp-lanl jhp-lanl added good first issue Good for newcomers Performance Improving performance labels Oct 27, 2023
@dholladay00
Copy link
Collaborator

This definitely seems like a premature optimization and I'd really want to see performance data to know which method to prefer. I'm not convinced that one expression is better than the other WRT performance.

@Yurlungur
Copy link
Collaborator

I am fine not acting on this now. That transformation has shown good performance in riot, so that's where my intuition is coming from.

That said the improvement was actually on intel, not GPUs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Performance Improving performance
Projects
None yet
Development

No branches or pull requests

3 participants