-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from sintefmath/dev
Add high-level CUDA support, doc improvements, NLDD performance increases, CSR backend as default
- Loading branch information
Showing
46 changed files
with
1,346 additions
and
343 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "JutulDarcy" | ||
uuid = "82210473-ab04-4dce-b31b-11573c4f8e0a" | ||
authors = ["Olav Møyner <[email protected]>"] | ||
version = "0.2.35" | ||
version = "0.2.36" | ||
|
||
[deps] | ||
AlgebraicMultigrid = "2169fc97-5a83-5252-b627-83903c6c433c" | ||
|
@@ -34,20 +34,26 @@ TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f" | |
Tullio = "bc48ee85-29a4-5162-ae0b-a64e1601d4bc" | ||
|
||
[weakdeps] | ||
AMGX = "c963dde9-0319-47f5-bf0c-b07d3c80ffa6" | ||
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" | ||
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a" | ||
HYPRE = "b5ffcf37-a2bd-41ab-a3da-4bd9bc8ad771" | ||
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" | ||
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" | ||
PartitionedArrays = "5a9dfac6-5c52-46f7-8278-5e2210713be9" | ||
|
||
[extensions] | ||
JutulDarcyAMGXExt = "AMGX" | ||
JutulDarcyCUDAExt = "CUDA" | ||
JutulDarcyGLMakieExt = "GLMakie" | ||
JutulDarcyMakieExt = "Makie" | ||
JutulDarcyPartitionedArraysExt = ["PartitionedArrays", "MPI", "HYPRE"] | ||
|
||
[compat] | ||
AlgebraicMultigrid = "0.5.1, 0.6.0" | ||
Artifacts = "1" | ||
AMGX = "0.2" | ||
CUDA = "5" | ||
DataStructures = "0.18.13" | ||
Dates = "1" | ||
DelimitedFiles = "1.6" | ||
|
@@ -56,7 +62,7 @@ ForwardDiff = "0.10.30" | |
GLMakie = "0.10.13" | ||
GeoEnergyIO = "1.1.12" | ||
HYPRE = "1.6.0, 1.7" | ||
Jutul = "0.2.40" | ||
Jutul = "0.2.42" | ||
Krylov = "0.9.1" | ||
LazyArtifacts = "1" | ||
LinearAlgebra = "1" | ||
|
@@ -78,6 +84,8 @@ Tullio = "0.3.4" | |
julia = "1.7" | ||
|
||
[extras] | ||
AMGX = "c963dde9-0319-47f5-bf0c-b07d3c80ffa6" | ||
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" | ||
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a" | ||
HYPRE = "b5ffcf37-a2bd-41ab-a3da-4bd9bc8ad771" | ||
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" | ||
|
@@ -87,4 +95,4 @@ TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a" | |
TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe" | ||
|
||
[targets] | ||
test = ["Test", "TestItemRunner", "TestItems", "HYPRE", "MPI", "PartitionedArrays"] | ||
test = ["Test", "CUDA", "TestItemRunner", "TestItems", "HYPRE", "MPI", "PartitionedArrays"] |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# GPU support | ||
|
||
JutulDarcy includes experimental support for running linear solves on the GPU. For many simulations, the linear systems are the most compute-intensive part and a natural choice for acceleration. At the moment, the support is limited to CUDA GPUs through [CUDA.jl](https://github.com/JuliaGPU/CUDA.jl). For the most efficient CPR preconditioner, [AMGX.jl](https://github.com/JuliaGPU/AMGX.jl) is required which is currently limited to Linux systems. Windows users may have luck by running Julia inside [WSL](https://learn.microsoft.com/en-us/windows/wsl/install). | ||
|
||
## How to use | ||
|
||
If you have installed JutulDarcy, you should start by adding the CUDA and optionally the AMGX packages using the package manager: | ||
|
||
```julia | ||
using Pkg | ||
Pkg.add("CUDA") # Requires a CUDA-capable GPU | ||
Pkg.add("AMGX") # Requires CUDA + Linux | ||
``` | ||
|
||
Once the packages have been added to the same environment as JutulDarcy, you can load them to enable GPU support. Let us grab the first ten steps of the EGG benchmark model: | ||
|
||
```julia | ||
using Jutul, JutulDarcy | ||
dpth = JutulDarcy.GeoEnergyIO.test_input_file_path("EGG", "EGG.DATA") | ||
case = setup_case_from_data_file(dpth) | ||
case = case[1:10] | ||
``` | ||
|
||
### Running on CPU | ||
|
||
If we wanted to run this on CPU we would simply call `simulate_reservoir`: | ||
|
||
```julia | ||
result_cpu = simulate_reservoir(case); | ||
``` | ||
|
||
### Running on GPU with block ILU(0) | ||
|
||
If we now load `CUDA` we can run the same simulation using the CUDA-accelerated linear solver. By itself, CUDA only supports the ILU(0) preconditioner. JutulDarcy will automatically pick this preconditioner when CUDA is requested without AMGX, but we write it explicitly here: | ||
|
||
```julia | ||
using CUDA | ||
result_ilu0_cuda = simulate_reservoir(case, linear_solver_backend = :cuda, precond = :ilu0); | ||
``` | ||
|
||
### Running on GPU with CPR AMGX-ILU(0) | ||
|
||
Loading the AMGX package makes a pure GPU-based two-stage CPR available. Again, we are explicit in requesting CPR, but if both `CUDA` and `AMGX` are available and functional this is redundant: | ||
|
||
```julia | ||
using AMGX | ||
result_amgx_cuda = simulate_reservoir(case, linear_solver_backend = :cuda, precond = :cpr); | ||
``` | ||
|
||
In short, load `AMGX` and `CUDA` and run `simulate_reservoir(case, linear_solver_backend = :cuda)` to get GPU results. The EGG model is quite small, so if you want to see significant performance increases, a larger case will be necessary. `AMGX` also contains a large number of options that can be configured for advanced users. | ||
|
||
## Technical details and limitations | ||
|
||
The GPU implementation relies on assembly on CPU and pinned memory to transfer onto the CPU. This means that the performance can be significantly improved by launching Julia with multiple threads to speed up the non-GPU parts of the code. AMGX is currently single-GPU only and does not work with MPI. Currently, only `Float64` is supported for CPR, but pure ILU(0) solves support `Float32` as well. | ||
|
||
!!! warning "Experimental status" | ||
Multiple successive runs with different `AMGX` instances have resulted in crashes when old instances are garbage collected. This part of the code is still considered experimental, with contributions welcome if you are using it. |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
178d314
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
Release notes:
Changes
178d314
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/119311
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: