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

GPU-capable Thomas algorithm applied directly to StencilCoefs #1345

Closed
simonbyrne opened this issue Jun 22, 2023 · 0 comments · Fixed by #1348
Closed

GPU-capable Thomas algorithm applied directly to StencilCoefs #1345

simonbyrne opened this issue Jun 22, 2023 · 0 comments · Fixed by #1348
Assignees
Labels
enhancement New feature or request

Comments

@simonbyrne
Copy link
Member

Is your feature request related to a problem? Please describe.
We need a columnwise tridiagonal solver for the GPU: with that, we can plug it into CliMA/ClimaAtmos.jl#1813, which from what I can tell is the main blocker of running the implicit solver on GPUs.

Describe the solution you'd like
I want a function:

column_thomas_solve!(S_column, xᶠ𝕄)

where S_column is a Field of StencilCoefs representing a tridiagonal operator, and xᶠ𝕄 is a scalar Field on the same space, which applies the in-place Thomas algorithm

  • It should not allocate any additional arrays (i.e. it can mutate both args)
  • It should work on both CPUs and GPUs
  • It should work on both columns, 2D extruded fields (CPU only for now) and 3D extruded fields
  • It needs tests.

The easiest way to do it is to write a function which takes an extra hidx arg and applies it to a single column, e.g.

function column_thomas_solve!(S_column, xᶠ𝕄, hidx)
    # if operating on Fields, use Operators.getidx/Operators.setidx!
    # if using DataLayouts, use getindex(data, CartesianIndex((i,j,k,v,h))) / setindex!
end

then on the CPU you can call it from a loop over columns, or on the GPU make a simple kernel function which calls it:

function knl_column_thomas_solve!(S_column, xᶠ𝕄)
    hidx = threadIdx.x ...
    column_thomas_solve!(S_column, xᶠ𝕄, hidx)
    return nothing
end
@simonbyrne simonbyrne added the enhancement New feature or request label Jun 22, 2023
@sriharshakandala sriharshakandala linked a pull request Jun 27, 2023 that will close this issue
4 tasks
@bors bors bot closed this as completed in #1348 Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants