Skip to content

Commit

Permalink
Merge pull request #43 from SciML/gpu
Browse files Browse the repository at this point in the history
Update GPU syntax to allow for backend choices
  • Loading branch information
ChrisRackauckas authored Oct 20, 2023
2 parents 79f83a6 + 1335e3f commit bf6f136
Show file tree
Hide file tree
Showing 8 changed files with 831 additions and 745 deletions.
6 changes: 3 additions & 3 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 1.1.3
Date: 2022-12-24 06:05:19 UTC
SHA: 4bb05b0a4dd334ff96db8db1a4fbf5b8f61a3db7
Version: 2.0.0
Date: 2023-10-20 04:03:09 UTC
SHA: 0db73d96940765d14af0154b85d419edc5b71b55
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
31 changes: 29 additions & 2 deletions R/diffeqr.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,47 @@ jitoptimize_sde <- function (de,prob){
#' This function initializes the DiffEqGPU package for GPU-parallelized ensembles.
#' The first time will be long since it includes precompilation.
#'
#' @param backend the backend for the GPU computation. Choices are "CUDA", "AMDGPU", "Metal", or "oneAPI"
#'
#' @examples
#'
#' \dontrun{ ## diffeq_setup() is time-consuming and requires Julia+DifferentialEquations.jl
#'
#' degpu <- diffeqr::diffeqgpu_setup()
#' degpu <- diffeqr::diffeqgpu_setup(backend="CUDA")
#'
#' }
#'
#' @export
diffeqgpu_setup <- function (){
diffeqgpu_setup <- function (backend){
JuliaCall::julia_install_package_if_needed("DiffEqGPU")
JuliaCall::julia_library("DiffEqGPU")
functions <- JuliaCall::julia_eval("filter(isascii, replace.(string.(propertynames(DiffEqGPU)),\"!\"=>\"_bang\"))")
degpu <- julia_pkg_import("DiffEqGPU",functions)

if (backend == "CUDA") {
JuliaCall::julia_install_package_if_needed("CUDA")
JuliaCall::julia_library("CUDA")
backend <- julia_pkg_import("CUDA",c("CUDABackend"))
degpu$CUDABackend <- backend$CUDABackend
} else if (backend == "AMDGPU") {
JuliaCall::julia_install_package_if_needed("AMDGPU")
JuliaCall::julia_library("AMDGPU")
backend <- julia_pkg_import("AMDGPU",c("AMDGPUBackend"))
degpu$AMDGPUBackend <- backend$AMDGPUBackend
} else if (backend == "Metal") {
JuliaCall::julia_install_package_if_needed("Metal")
JuliaCall::julia_library("Metal")
backend <- julia_pkg_import("Metal",c("MetalBackend"))
degpu$MetalBackend <- backend$MetalBackend
} else if (backend == "oneAPI") {
JuliaCall::julia_install_package_if_needed("oneAPI")
JuliaCall::julia_library("oneAPI")
backend <- julia_pkg_import("oneAPI",c("oneAPIBackend"))
degpu$oneAPIBackend <- backend$oneAPIBackend
} else {
stop(paste("Illegal backend choice found. Allowed choices: CUDA, AMDGPU, Metal, and oneAPI. Chosen backend: ", backend))
}
degpu
}

julia_function <- function(func_name, pkg_name = "Main",
Expand Down
Loading

0 comments on commit bf6f136

Please sign in to comment.