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

Update vector conversions #1392

Merged
merged 1 commit into from
Jul 26, 2023
Merged

Update vector conversions #1392

merged 1 commit into from
Jul 26, 2023

Conversation

sriharshakandala
Copy link
Member

@sriharshakandala sriharshakandala commented Jul 24, 2023

Add custom CovariantVector to Contravariant123Vector transformation functions

  • Code follows the style guidelines OR N/A.
  • Unit tests are included OR N/A.
  • Code is exercised in an integration test OR N/A.
  • Documentation has been added/updated OR N/A.

@sriharshakandala
Copy link
Member Author

bors try

bors bot added a commit that referenced this pull request Jul 25, 2023
@sriharshakandala sriharshakandala marked this pull request as ready for review July 25, 2023 23:20
@bors
Copy link
Contributor

bors bot commented Jul 25, 2023

try

Build failed:

@sriharshakandala sriharshakandala changed the title Update tensor conversions Update vector conversions Jul 25, 2023
@sriharshakandala
Copy link
Member Author

Split off from PR #1385

Copy link
Member

@charleskawczynski charleskawczynski left a comment

Choose a reason for hiding this comment

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

This PR looks good to me. It's a bit unfortunate that these are not captured in the axis tensor benchmarks. Can you point to the methods that these new functions are overriding / specializing on?

I'm curious if we can write a more general overloading, like we did before for project / transform. It seems that one crux of this is to cache ∂x∂ξ' * ∂x∂ξ, which seems like a good idea (I forgot that we left that on the table before).

Related issue: #867

@sriharshakandala
Copy link
Member Author

This PR looks good to me. It's a bit unfortunate that these are not captured in the axis tensor benchmarks. Can you point to the methods that these new functions are overriding / specializing on?

I'm curious if we can write a more general overloading, like we did before for project / transform. It seems that one crux of this is to cache ∂x∂ξ' * ∂x∂ξ, which seems like a good idea (I forgot that we left that on the table before).

In the context of the GPU version, we noticed that this function uses much less register space per thread compared to the pre-existing version. Looking at the Nsight Systems profile for the pre-existing version, the fundamental bottleneck seems to be register space. This helps us use more threads per block or enable the GPU to schedule multiple blocks on the same SM resulting in significant speedup.

@sriharshakandala
Copy link
Member Author

sriharshakandala commented Jul 26, 2023

This PR looks good to me. It's a bit unfortunate that these are not captured in the axis tensor benchmarks. Can you point to the methods that these new functions are overriding / specializing on?

I'm curious if we can write a more general overloading, like we did before for project / transform. It seems that one crux of this is to cache ∂x∂ξ' * ∂x∂ξ, which seems like a good idea (I forgot that we left that on the table before).

I believe we provide a specialization that overrides https://github.com/CliMA/ClimaCore.jl/blob/main/src/Geometry/conversions.jl#L102 for this specific case. Please correct me if I am missing something!

Add specializations for CovariantVector to Contravariant123Vector transformation functions
@sriharshakandala
Copy link
Member Author

bors try

bors bot added a commit that referenced this pull request Jul 26, 2023
@bors
Copy link
Contributor

bors bot commented Jul 26, 2023

try

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@charleskawczynski
Copy link
Member

https://github.com/CliMA/ClimaCore.jl/blob/main/src/Geometry/conversions.jl#L102 for this specific case. Please correct me if I am missing something!

Ah, yeah, that's a pretty bad method (it calls project twice). In fact, all of the generic ones look pretty bad (cc @bloops)

https://github.com/CliMA/ClimaCore.jl/blob/main/src/Geometry/conversions.jl#L73-L109

Copy link
Member

@charleskawczynski charleskawczynski left a comment

Choose a reason for hiding this comment

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

This is fine for now, but we should really improving the performance of these operators more systematically (like we did with project / transform).

And add unit tests (I think GFlops.jl would work well here).

@sriharshakandala
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Jul 26, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit d893ee6 into main Jul 26, 2023
6 checks passed
@bors bors bot deleted the sk/update_conversions branch July 26, 2023 23:05
Comment on lines +34 to +38
Contravariant123Vector(
u::CovariantVector{T, (3,)},
local_geometry::LocalGeometry{(1, 2, 3)},
) where {T} =
local_geometry.gⁱʲ * Covariant123Vector(zero(u[1]), zero(u[1]), u[1])
Copy link
Member

Choose a reason for hiding this comment

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

@sriharshakandala, can we hand-write this and avoid the dense mul?

bors bot added a commit to CliMA/ClimaAtmos.jl that referenced this pull request Jul 27, 2023
1922: Update manifest files r=charleskawczynski a=charleskawczynski

This PR updates the dependencies, which includes CliMA/ClimaCore.jl#1392

Co-authored-by: Charles Kawczynski <[email protected]>
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