Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rationalise names used for gpu things #321

Merged
merged 24 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dust
Title: Iterate Multiple Realisations of Stochastic Models
Version: 0.11.4
Version: 0.11.5
Authors@R: c(person("Rich", "FitzJohn", role = c("aut", "cre"),
email = "[email protected]"),
person("John", "Lees", role = "aut"),
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ clean:
tests/testthat/example/*.o tests/testthat/example/*.so \
src/*.gcov src/*.gcda src/*.gcno

vignettes/cuda.Rmd: vignettes_src/cuda.Rmd
./scripts/build_cuda_vignette
vignettes/gpu.Rmd: vignettes_src/gpu.Rmd
./scripts/build_gpu_vignette

vignettes: vignettes/dust.Rmd vignettes/rng.Rmd
${RSCRIPT} -e 'tools::buildVignettes(dir = ".")'
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# dust 0.11.5

* Major header reorganisation, the `dust::cuda` namespace is now `dust::gpu`, most user-facing uses of "cuda" and "device" now replaced with "gpu (#298, #317)
richfitz marked this conversation as resolved.
Show resolved Hide resolved
* New (static) method `real_size` on every dust class for accessing the size of `real_type`, in bits (#301)

# dust 0.11.1

* Support for the multinomial distribution. This differs from most other random number support because it returns a *vector* of values not a single number (#307)
Expand Down
4 changes: 2 additions & 2 deletions R/compile.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ dust_code <- function(data, config) {
if (config$has_gpu_support) {
data_gpu <- data
data_gpu$target <- "gpu"
data_gpu$container <- "DustDevice"
data_gpu$container <- "dust_gpu"
dust_cpp <- c(dust_cpp,
substitute_dust_template(data_gpu, "dust_methods.cpp", NULL))
dust_hpp <- c(dust_hpp,
Expand Down Expand Up @@ -155,7 +155,7 @@ dust_template_data <- function(model, config, cuda) {
param = deparse_param(config$param),
cuda = cuda$flags,
target = "cpu",
container = "Dust",
container = "dust_cpu",
has_gpu_support = as.character(config$has_gpu_support),
methods_cpu = methods_cpu,
methods_gpu = methods_gpu)
Expand Down
52 changes: 26 additions & 26 deletions R/cpp11.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ dust_sir_capabilities <- function() {
.Call(`_dust_dust_sir_capabilities`)
}

dust_sir_device_info <- function() {
.Call(`_dust_dust_sir_device_info`)
dust_sir_gpu_info <- function() {
.Call(`_dust_dust_sir_gpu_info`)
}

dust_cpu_sir_alloc <- function(r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, device_config) {
.Call(`_dust_dust_cpu_sir_alloc`, r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, device_config)
dust_cpu_sir_alloc <- function(r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, gpu_config) {
.Call(`_dust_dust_cpu_sir_alloc`, r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, gpu_config)
}

dust_cpu_sir_run <- function(ptr, step_end) {
Expand Down Expand Up @@ -148,12 +148,12 @@ dust_sirs_capabilities <- function() {
.Call(`_dust_dust_sirs_capabilities`)
}

dust_sirs_device_info <- function() {
.Call(`_dust_dust_sirs_device_info`)
dust_sirs_gpu_info <- function() {
.Call(`_dust_dust_sirs_gpu_info`)
}

dust_cpu_sirs_alloc <- function(r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, device_config) {
.Call(`_dust_dust_cpu_sirs_alloc`, r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, device_config)
dust_cpu_sirs_alloc <- function(r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, gpu_config) {
.Call(`_dust_dust_cpu_sirs_alloc`, r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, gpu_config)
}

dust_cpu_sirs_run <- function(ptr, step_end) {
Expand Down Expand Up @@ -216,8 +216,8 @@ dust_cpu_sirs_n_state <- function(ptr) {
.Call(`_dust_dust_cpu_sirs_n_state`, ptr)
}

dust_gpu_sirs_alloc <- function(r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, device_config) {
.Call(`_dust_dust_gpu_sirs_alloc`, r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, device_config)
dust_gpu_sirs_alloc <- function(r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, gpu_config) {
.Call(`_dust_dust_gpu_sirs_alloc`, r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, gpu_config)
}

dust_gpu_sirs_run <- function(ptr, step_end) {
Expand Down Expand Up @@ -280,8 +280,8 @@ dust_gpu_sirs_n_state <- function(ptr) {
.Call(`_dust_dust_gpu_sirs_n_state`, ptr)
}

test_cuda_pars <- function(r_device_config, n_particles, n_particles_each, n_state, n_state_full, n_shared_int, n_shared_real, data_size, shared_size) {
.Call(`_dust_test_cuda_pars`, r_device_config, n_particles, n_particles_each, n_state, n_state_full, n_shared_int, n_shared_real, data_size, shared_size)
test_cuda_pars <- function(r_gpu_config, n_particles, n_particles_each, n_state, n_state_full, n_shared_int, n_shared_real, data_size, shared_size) {
.Call(`_dust_test_cuda_pars`, r_gpu_config, n_particles, n_particles_each, n_state, n_state_full, n_shared_int, n_shared_real, data_size, shared_size)
}

test_xoshiro_run <- function(name) {
Expand All @@ -296,12 +296,12 @@ dust_variable_capabilities <- function() {
.Call(`_dust_dust_variable_capabilities`)
}

dust_variable_device_info <- function() {
.Call(`_dust_dust_variable_device_info`)
dust_variable_gpu_info <- function() {
.Call(`_dust_dust_variable_gpu_info`)
}

dust_cpu_variable_alloc <- function(r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, device_config) {
.Call(`_dust_dust_cpu_variable_alloc`, r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, device_config)
dust_cpu_variable_alloc <- function(r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, gpu_config) {
.Call(`_dust_dust_cpu_variable_alloc`, r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, gpu_config)
}

dust_cpu_variable_run <- function(ptr, step_end) {
Expand Down Expand Up @@ -364,8 +364,8 @@ dust_cpu_variable_n_state <- function(ptr) {
.Call(`_dust_dust_cpu_variable_n_state`, ptr)
}

dust_gpu_variable_alloc <- function(r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, device_config) {
.Call(`_dust_dust_gpu_variable_alloc`, r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, device_config)
dust_gpu_variable_alloc <- function(r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, gpu_config) {
.Call(`_dust_dust_gpu_variable_alloc`, r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, gpu_config)
}

dust_gpu_variable_run <- function(ptr, step_end) {
Expand Down Expand Up @@ -432,12 +432,12 @@ dust_volatility_capabilities <- function() {
.Call(`_dust_dust_volatility_capabilities`)
}

dust_volatility_device_info <- function() {
.Call(`_dust_dust_volatility_device_info`)
dust_volatility_gpu_info <- function() {
.Call(`_dust_dust_volatility_gpu_info`)
}

dust_cpu_volatility_alloc <- function(r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, device_config) {
.Call(`_dust_dust_cpu_volatility_alloc`, r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, device_config)
dust_cpu_volatility_alloc <- function(r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, gpu_config) {
.Call(`_dust_dust_cpu_volatility_alloc`, r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, gpu_config)
}

dust_cpu_volatility_run <- function(ptr, step_end) {
Expand Down Expand Up @@ -504,12 +504,12 @@ dust_walk_capabilities <- function() {
.Call(`_dust_dust_walk_capabilities`)
}

dust_walk_device_info <- function() {
.Call(`_dust_dust_walk_device_info`)
dust_walk_gpu_info <- function() {
.Call(`_dust_dust_walk_gpu_info`)
}

dust_cpu_walk_alloc <- function(r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, device_config) {
.Call(`_dust_dust_cpu_walk_alloc`, r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, device_config)
dust_cpu_walk_alloc <- function(r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, gpu_config) {
.Call(`_dust_dust_cpu_walk_alloc`, r_pars, pars_multi, step, r_n_particles, n_threads, r_seed, deterministic, gpu_config)
}

dust_cpu_walk_run <- function(ptr, step_end) {
Expand Down
19 changes: 9 additions & 10 deletions R/cuda.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
##' Detect CUDA configuration. This is experimental and subject to
##' change. This function tries to compile a small program with `nvcc`
##' and confirms that this can be loaded into R, then uses that
##' program to query the presence and capabilities of your NVIDIA
##' GPUs. If this works, then you can use the GPU-enabled dust
##' features, and the information returned will help us. It's quite
##' slow to execute (several seconds) so we cache the value within a
##' session. Later versions of dust will cache this across sessions
##' too.
##' Detect CUDA configuration. This function tries to compile a small
##' program with `nvcc` and confirms that this can be loaded into R,
##' then uses that program to query the presence and capabilities of
##' your NVIDIA GPUs. If this works, then you can use the GPU-enabled
##' dust features, and the information returned will help us. It's
##' quite slow to execute (several seconds) so we cache the value
##' within a session. Later versions of dust will cache this across
##' sessions too.
##'
##' Not all installations leave the CUDA libraries on the default
##' paths, and you may need to provide it. Specifically, when we link
Expand Down Expand Up @@ -165,7 +164,7 @@ cuda_configuration <- function(path_cuda_lib = NULL, path_cub_include = NULL,
pkg <- pkgload::load_all(dat$path, export_all = FALSE, quiet = quiet,
helpers = FALSE, attach_testthat = FALSE)
on.exit(pkgload::unload(dat$name))
info <- pkg$env$dust_device_info()
info <- pkg$env$dust_gpu_info()
path_cub_include <-
cuda_path_cub_include(info$cuda_version, path_cub_include)
paths <- list(
Expand Down
Loading