Document solving a stiff PDE on the GPU with a sparse Jacobian - #4453
Open
AJ0070 wants to merge 1 commit into
Open
Document solving a stiff PDE on the GPU with a sparse Jacobian#4453AJ0070 wants to merge 1 commit into
AJ0070 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a page on solving a stiff PDE on the GPU with a sparse Jacobian, using the Brusselator from #1566 as a complete worked example.
Three separate things have to line up for this to work, and all three report the same
Scalar indexing is disallowed, which makes them hard to tell apart. The page covers each and ends with a short guide to reading the stack trace to decide which one you have hit.The one that is easy to miss is that the right-hand side has to execute on the device. In the #1566 script every array is
Ref-wrapped, so the index set is the only broadcastable argument and it alone decides where the loop runs. With a hostCartesianIndicesthe whole RHS runs on the CPU and reads the device arrays element by element, before autodiff or the linear solver are involved. The page also notes thatmul!against aCuSparseMatrixCSRhas noForwardDiff.Dualkernel, which is a second way to write an RHS that cannot be differentiated on the device.The example was run on a T4: Rosenbrock23, Rosenbrock23 with
KrylovJL_GMRES, and FBDF all match a CPU reference to about 1e-10. It needs #4452 for theRosenbrock23results shown, so this is best merged after that one.AI Disclosure: Used Opus 5