-
Notifications
You must be signed in to change notification settings - Fork 33
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
Example GPU kernels #121
Comments
Comments on the examples
|
Thanks Milan! About the time stepping, so 1b we have to talk separately, at least for the AD compatibility, so should do that as one of the last things. The options are either something along the lines of using Checkpointing.jl, or looking if it possible to use the leapfrog solver from DifferentialEquations.jl |
Sure, happy to move the simplicity of that kernel further down |
@katharinamaetschke quick test whether you get pinged by github if we @ you in |
closed in favour of #575 |
Compute-intensive loops for which we'll define GPU kernels basically fall into one of the three categories (sorted from simple to complex)
for lm in eachharmonic. These kernels loop over the non-zero indices of one or several$l,m$ harmonic
LowerTriangularMatrix
s but only access/write into thelm
on every iteration. No cross dependencies to other harmonics. May include scalar constants. All input arrays are of the same size.for i,j in eachentry(::Matrix) with vec[j]. These kernels loop over all entries$i,j$ of a matrix (can be $j$ . There's at least two different indices used in the loop. Input matrices are of the same size, but the (precomputed) vectors are (obviously) smaller.
LowerTriangularMatrix
) but also pull data from vector at indexfor l,m in eachharmonic with A[l+1,m] and A[l-1,m]. These kernels loop over the non-zero indices$l,m$ of several $l,m$ also $l+1,m$ and $l-1,m$ , meaning there are cross dependencies to other harmonics. These loops usually involve a separate loop for the diagonal (as $l-1,m$ is zero) and for the last row (as $l+1,m$ is out of bounds).
LowerTriangularMatrix
s and access for everyspherical harmonic transforms. Like 2) but with signs depending on odd and even modes, and combined with Fourier transforms.
Examples
for lm in eachharmonic
a) The horizontal diffusion
https://github.com/milankl/SpeedyWeather.jl/blob/e1c1e79fe43cf5c23603a87039b27c4fc59d4250/src/diffusion.jl#L12-L21
b) The leapfrog time integration
https://github.com/milankl/SpeedyWeather.jl/blob/e1c1e79fe43cf5c23603a87039b27c4fc59d4250/src/time_integration.jl#L13-L43
for i,j in eachentry(::Matrix) with vec[j]
a) The vorticity fluxes (in grid-point space)
https://github.com/milankl/SpeedyWeather.jl/blob/e1c1e79fe43cf5c23603a87039b27c4fc59d4250/src/tendencies_dynamics.jl#L287-L313
b) The Bernoulli potential (in grid-point space)
https://github.com/milankl/SpeedyWeather.jl/blob/e1c1e79fe43cf5c23603a87039b27c4fc59d4250/src/tendencies_dynamics.jl#L349-L373
c) The Laplace operator (in spectral space)
https://github.com/milankl/SpeedyWeather.jl/blob/e1c1e79fe43cf5c23603a87039b27c4fc59d4250/src/spectral_gradients.jl#L263-L289
for l,m in eachharmonic with A[l+1,m] and A[l-1,m]$U,V$ from vorticity and divergence (inverse Laplace combined with horizontal gradients)
a) The divergence/curl operator
https://github.com/milankl/SpeedyWeather.jl/blob/e1c1e79fe43cf5c23603a87039b27c4fc59d4250/src/spectral_gradients.jl#L68-L99
b)
https://github.com/milankl/SpeedyWeather.jl/blob/e1c1e79fe43cf5c23603a87039b27c4fc59d4250/src/spectral_gradients.jl#L166-L210
spherical harmonic transforms
a) spectral to grid
https://github.com/milankl/SpeedyWeather.jl/blob/e1c1e79fe43cf5c23603a87039b27c4fc59d4250/src/spectral_transform.jl#L279-L335
b) grid to spectral
https://github.com/milankl/SpeedyWeather.jl/blob/e1c1e79fe43cf5c23603a87039b27c4fc59d4250/src/spectral_transform.jl#L384-L435
@maximilian-gelbrecht
The text was updated successfully, but these errors were encountered: