Skip to content

Commit

Permalink
bump to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Oct 20, 2023
1 parent cb646f4 commit 0db73d9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
Package: diffeqr
Type: Package
Title: Solving Differential Equations (ODEs, SDEs, DDEs, DAEs)
Version: 1.1.3
Version: 2.0.0
Authors@R: person("Christopher", "Rackauckas", email = "[email protected]", role = c("aut", "cre", "cph"))
Description: An interface to 'DifferentialEquations.jl' <https://diffeq.sciml.ai/dev/> from the R programming language.
It has unique high performance methods for solving ordinary differential equations (ODE), stochastic differential equations (SDE),
delay differential equations (DDE), differential-algebraic equations (DAE), and more. Much of the functionality,
including features like adaptive time stepping in SDEs, are unique and allow for multiple orders of magnitude speedup over more common methods.
Supports GPUs, with support for CUDA (NVIDIA), AMD GPUs, Intel oneAPI GPUs, and Apple's Metal (M-series chip GPUs).
'diffeqr' attaches an R interface onto the package, allowing seamless use of this tooling by R users. For more information,
see Rackauckas and Nie (2017) <doi:10.5334/jors.151>.
Depends: R (>= 3.4.0)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Release v2.0.0

Support new DiffEqGPU syntax. This requires passing a backend. Supports NVIDIA CUDA, Intel OneAPI,
AMD GPUs, and Apple Metal GPUs. Also much faster GPU compilation and runtime performance.

## Release v1.1.2

Bugfixes for newer Julia versions.
Expand Down
26 changes: 20 additions & 6 deletions vignettes/gpu.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ knitr::opts_chunk$set(
)
```

## GPU-Accelerated ODE Solving of Ensembles

In many cases one is interested in solving the same ODE many times over many
different initial conditions and parameters. In diffeqr parlance this is called
an ensemble solve. diffeqr inherits the parallelism tools of the
an ensemble solve. diffeqr inherits the parallelism tools of the
[SciML ecosystem](https://sciml.ai/) that are used for things like
[automated equation discovery and acceleration](https://arxiv.org/abs/2001.04385).
Here we will demonstrate using these parallel tools to accelerate the solving
Expand All @@ -43,7 +41,7 @@ prob <- de$ODEProblem(lorenz,u0,tspan,p)
fastprob <- diffeqr::jitoptimize_ode(de,prob)
```

Now we use the `EnsembleProblem` as defined on the
Now we use the `EnsembleProblem` as defined on the
[ensemble parallelism page of the documentation](https://diffeq.sciml.ai/stable/features/ensemble/):
Let's build an ensemble by utilizing uniform random numbers to randomize the
initial conditions and parameters:
Expand All @@ -62,13 +60,15 @@ sol = de$solve(ensembleprob,de$Tsit5(),de$EnsembleSerial(),trajectories=10000,sa
```

To add GPUs to the mix, we need to bring in [DiffEqGPU](https://github.com/SciML/DiffEqGPU.jl).
The `diffeqr::diffeqgpu_setup` helper function will install CUDA for you and
The `diffeqr::diffeqgpu_setup()` helper function will install CUDA for you and
bring all of the bindings into the returned object:

```R
degpu <- diffeqr::diffeqgpu_setup(backend="CUDA")
degpu <- diffeqr::diffeqgpu_setup("CUDA")
```

#### Note: `diffeqr::diffeqgpu_setup` can take awhile to run the first time as it installs the drivers!

Now we simply use `EnsembleGPUKernel(degpu$CUDABackend())` with a
GPU-specialized ODE solver `GPUTsit5()` to solve 10,000 ODEs on the GPU in
parallel:
Expand All @@ -77,6 +77,20 @@ parallel:
sol <- de$solve(ensembleprob,degpu$GPUTsit5(),degpu$EnsembleGPUKernel(degpu$CUDABackend()),trajectories=10000,saveat=0.01)
```

For the full list of choices for specialized GPU solvers, see
[the DiffEqGPU.jl documentation](https://docs.sciml.ai/DiffEqGPU/stable/manual/ensemblegpukernel/).

Note that `EnsembleGPUArray` can be used as well, like:

```R
sol <- de$solve(ensembleprob,de$Tsit5(),degpu$EnsembleGPUArray(degpu$CUDABackend()),trajectories=10000,saveat=0.01)
```

though we highly recommend the `EnsembleGPUKernel` methods for more speed. Given
the way the JIT compilation performed will also ensure that the faster kernel
generation methods work, `EnsembleGPUKernel` is almost certainly the
better choice in most applications.

### Benchmark

To see how much of an effect the parallelism has, let's test this against R's
Expand Down

0 comments on commit 0db73d9

Please sign in to comment.