Repository navigation
Add examples for the ReSolve SUNLinSol interface - #13
Conversation
…e and the matrix object, and modify SUNMatZero to only zero out the data array.
|
Please add summary how solutions to the problem compare. |
|
What is the command to run the examples? |
shakedregev
left a comment
There was a problem hiding this comment.
I still need to test this.
| * 1 2 ns | ||
| * c = (c , c , ..., c ) , ns = 2 * np | ||
| * | ||
| * and the PDE's are as follows: |
There was a problem hiding this comment.
This is hard to follow. Maybe better to have it rendered in readthedocs or something.
There was a problem hiding this comment.
This was a hold over from how the other built in examples explained the example. They have a better rendered explanation of the examples here https://sundials.readthedocs.io/en/latest/examples/ida/index-superbuild.html
|
Why is there one version for CPU/HIP/CUDA + another version of the code just for CUDA? |
shakedregev
left a comment
There was a problem hiding this comment.
I'm not sure if I am running the correct thing. Please specify exactly which examples to run. But:
./idaHeat2D_kry
idaHeat2D_kry: Heat equation, serial example problem for IDA
Discretized heat equation on 2D unit square.
Zero boundary conditions, polynomial initial conditions.
Mesh dimensions: 10 x 10 Total system size: 100
Tolerance parameters: rtol = 0 atol = 0.001
Constraints set to force all solution components >= 0.
Linear solver: SPGMR, preconditioner using diagonal elements.
Case 1: gsytpe = SUN_MODIFIED_GS
Output Summary (umax = max-norm of solution)
time umax k nst nni nje nre nreLS h npe nps
----------------------------------------------------------------------
0.01 8.24106e-01 2 12 14 7 14 7 2.56e-03 8 21
0.02 6.88134e-01 3 15 18 12 18 12 5.12e-03 8 30
0.04 4.70711e-01 3 18 24 21 24 21 6.58e-03 9 45
0.08 2.16509e-01 3 22 29 30 29 30 1.32e-02 9 59
0.16 4.57687e-02 4 28 36 44 36 44 1.32e-02 9 80
0.32 2.09938e-03 4 35 44 67 44 67 2.63e-02 10 111
0.64 0.00000e+00 1 39 51 77 51 77 1.05e-01 12 128
1.28 0.00000e+00 1 41 53 77 53 77 4.21e-01 14 130
2.56 0.00000e+00 1 43 55 77 55 77 1.69e+00 16 132
5.12 0.00000e+00 1 44 56 77 56 77 3.37e+00 17 133
10.24 0.00000e+00 1 45 57 77 57 77 6.74e+00 18 134
Error test failures = 1
Nonlinear convergence failures = 0
Linear convergence failures = 0
Case 2: gstype = SUN_CLASSICAL_GS
Output Summary (umax = max-norm of solution)
time umax k nst nni nje nre nreLS h npe nps
----------------------------------------------------------------------
0.01 8.24106e-01 2 12 14 7 14 7 2.56e-03 8 21
0.02 6.88134e-01 3 15 18 12 18 12 5.12e-03 8 30
0.04 4.70711e-01 3 18 24 21 24 21 6.58e-03 9 45
0.08 2.16509e-01 3 22 29 30 29 30 1.32e-02 9 59
0.16 4.57687e-02 4 28 36 44 36 44 1.32e-02 9 80
0.32 2.09938e-03 4 35 44 67 44 67 2.63e-02 10 111
0.64 0.00000e+00 1 39 51 77 51 77 1.05e-01 12 128
1.28 0.00000e+00 1 41 53 77 53 77 4.21e-01 14 130
2.56 0.00000e+00 1 43 55 77 55 77 1.69e+00 16 132
5.12 0.00000e+00 1 44 56 77 56 77 3.37e+00 17 133
10.24 0.00000e+00 1 45 57 77 57 77 6.74e+00 18 134
Error test failures = 1
Nonlinear convergence failures = 0
Linear convergence failures = 0
|
I updated the pull request to add instructions to make the ReSolve examples install. The example that you ran was for SUNDIALS's built in Krylov Solver. The specific examples to run are located under The version of the examples that is for CPU/HIP/CUDA just uses ReSolve for the linear solves and leaves everything else to be done on the host, but the CUDA only examples uses CUDA kernels to do work in the example like updating the Jacobian for the Heat Equation example. |
|
Are we expecting some failures: |
|
@pelesh - are we ok with no HIP functionality? |
|
This is the result from I will look more into the step solver failures, but I think the error test failures and nonlinear convergence failures are normal, at least compared to the banded solver. For the heat equation, the failures should be normal. The built in KLU solver has the exact same result as the ReSolve solver. |
|
If these failures are expected, we can merge this. |
|
My understanding of the step solver failures is that: At some step of the non linear solver there was a non convergence error. When the solver gets this error it increments the step solver failure counter. If this error was non-recoverable, the entire solver will terminate. However, if it is recoverable, the solver will reduce the step size at that step and attempt it again. I think since the solver converged, it should be fine but I'm not sure if these failures are inherent to solving the food web problem with the KLU solver, or some error in my implementation since there's no benchmark to check the performance of the KLU solver with like with the heat example. |
|
@shakedregev @pelesh I believe the pull request is ready to merge now. The fortran check fails because the check fails to install something necessary to start the check, and the build and test checks also fail on the initial fork of SUNDIALS without my changes so I think these failures are outside of my control. I didn't make the change to the explanation of the foodweb example to have it rendered because I don't think the rendered version of the comment in the |
This pull request adds 4 examples that are located under
examples/ida/resolve:When building SUNDIALS the flags
-D SUNDIALS_ENABLE_RESOLVE=ON-D ReSolve_DIR= <path/to/resolve/installation>-D SUNDIALS_ENABLE_CXX_EXAMPLES=ONneed to be enabled for the ReSolve examples to be built.
To build SUNDIALS with CUDA, enable
-D SUNDIALS_RESOLVE_BACKENDS=CUDA-D SUNDIALS_ENABLE_CUDA=ONidaHeat2D_resolve.cpp: A heat equation example that runs on CPU, CUDA and HIP. This example works on CUDA and HIP by doing all work on the host and sending data to the device as necessary.idaHeat2D_resolve_cuda.cu: A heat equation example that uses CUDA kernels to perform work on the device where possible.Both heat examples have identical results to
idaHeat2D_klu.clocated underexamples/ida/serial.The results are as follows:
Number of Error Test Failures: 2
Number of Nonlinear Solver convergence failures: 0
idaFoodWeb_resolve.cpp: A food web example that runs on CPU, CUDA and HIP. This example works on CUDA and HIP by doing all work on the host and sending data to the device as necessary.idaFoodWeb_resolve_cuda.cu: A food web example that uses CUDA kernels to perform work on the device where possible.Although both converge, these two examples vary in performance.
idaFoodWeb_resolve.cpp (CPU)
idaFoodWeb_resolve_cuda.cu
Following are the solver statistics
In addition to these examples, the following modifications are made to the
SUNMatrix_ReSolveclassAdd getters for the Re::Solve memory space object and the ReSolve CSR matrix object
Changed the behaviour of
SUNMatZeroto only zero out the data array, keeping the sparsity pattern.Please target the
developbranch notmain.Review our Contributing Guide, and ensure that you sign your last commit (at minimum) as per the guide.
Provide a concise description of what your pull request does, and why it is needed/benefical.
Add a note about your change to the
CHANGELOG.mdanddocs/shared/RecentChanges.rstfiles. Notice that the former is a markdown file and the latter is reStructuredText, so the formatting is slightly different.After your PR is opened, ensure that all of the tests are passing (a SUNDIALS developer will have to allow the testing to run).