Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/utkarsh530/mixedprecisiondiffeq.jl
Mixed Precision ODE solvers in Julia
https://github.com/utkarsh530/mixedprecisiondiffeq.jl
Last synced: about 1 month ago
JSON representation
Mixed Precision ODE solvers in Julia
- Host: GitHub
- URL: https://github.com/utkarsh530/mixedprecisiondiffeq.jl
- Owner: utkarsh530
- License: mit
- Created: 2023-04-27T19:41:46.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-16T21:30:13.000Z (9 months ago)
- Last Synced: 2024-11-10T08:34:33.402Z (2 months ago)
- Language: Julia
- Size: 639 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![CI](https://github.com/utkarsh530/MixedPrecisionDiffEq.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/utkarsh530/MixedPrecisionDiffEq.jl/actions/workflows/CI.yml) [![codecov](https://codecov.io/gh/utkarsh530/MixedPrecisionDiffEq.jl/branch/main/graph/badge.svg?token=30TQNN2BL6)](https://codecov.io/gh/utkarsh530/MixedPrecisionDiffEq.jl)
# MixedPrecisionDiffEq.jl
Mixed Precision ODE solvers in Julia compatible with SciML ecosystem support!# Setup
For GPU usage, ensure that you have a NVIDIA GPU working. While in the directory, run:
```
$ julia --project=. --threads=auto
julia> using Pkg
julia> Pkg.instantiate()
julia> Pkg.precompile()
```# Usage
## Mixed precision methods in linear systems
```julia
using LinearSolve, MixedPrecisionDiffEq
prob = LinearProblem(rand(100,100), rand(100))
sol = solve(prob, MixedPrecisionLinsolve())
```The default matrix factorization choice is `RFLUFactorization`, which is a recursive LU factorization.
However, you can simply use any factorization used by `LinearSolve.jl` by simply changing the argument as:
```julia
sol = solve(prob, MixedPrecisionLinsolve(FastLUFactorization()))
```## Using mixed precision methods in ODEs
```julia
using OrdinaryDiffEq, MixedPrecisionDiffEq
function f!(du, u, p, t)
du[1] = -p[1]*u[1] + p[2]*u[2]*u[3]
du[2] = p[1]*u[1] - p[2]*u[2]*u[3] - p[3]*u[2]*u[2]
du[3] = p[3]*u[2]*u[2]
endu0 = [1.0,0.0,0.0]
tspan = (0.0, 1e5)
p = [0.04, 1e4, 3e7]prob = ODEProblem(f!,u0, tspan, p)
sol = solve(prob, TRBDF2(;linsolve = MixedPrecisionLinsolve()))
```## GPU acceleration of linear solve with mixed precision
To use GPU acceleration, run:
```julia
sol = solve(prob, TRBDF2(;linsolve = MixedPrecisionCudaOffloadFactorization()))
```The GPU method only supports LU factorization as of now.