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

Use single kernel for pointwise functions #3399

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

Conversation

sriharshakandala
Copy link
Member

Purpose

Use single kernel for point-wise functions.


  • I have read and checked the items on the review checklist.

return nothing
end

function compute_precipitation_sources_kernel!(
Copy link
Member

Choose a reason for hiding this comment

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

Hi @sriharshakandala, thanks for looking into this. But, what do we do when a user wants to add a new term in here that requires a derivative? If the answer is to split up the kernel, then this seems like a very inflexible solution compared to #3371, which should be able to achieve the same thing as what is done here. One of my bigger concerns, however, is that we cannot easily unit test and refactor compute_precipitation_sources_kernel!, as we move towards a more lazy representation that will allow us to fuse more kernels still.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is only for pointwise functions. Spectral element derivatives are not pointwise functions!

Copy link
Member Author

Choose a reason for hiding this comment

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

I do not see any limitations with testing code with this approach.

Copy link
Member

Choose a reason for hiding this comment

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

This is only for pointwise functions. Spectral element derivatives are not pointwise functions!

Yeah, but that means that if a user wants to try adding a gradient somewhere that they would need to break up this function, which seems like a lot of work just to add one term.

Also, this example has a collection of floats, how would that look for this example? https://github.com/CliMA/ClimaAtmos.jl/pull/3371/files#diff-471fb2001bc0d6f84924896fd8c99bd3d4edcc84bd5d79da9e9f35afef17f9cdR491-R497

Copy link
Contributor

Choose a reason for hiding this comment

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

In my view, the point of what Sriharsha is doing here is not so much establish a pattern for refactoring the code, but get a relatively simple example going that allows us to quantitatively assess the performance benefits of kernel fusion. So I'd suggest we table discussions of how to realize the benefits until we have a better sense what the benefits are.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, yes, that makes sense. This would be a nice example to see the speed up.

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.

3 participants