dust_generate | R Documentation |
Generate a package out of a dust model. The resulting package can
be installed or loaded via pkgload::load_all()
though it
contains minimal metadata and if you want to create a persistent
package you should use dust_package()
. This function is
intended for cases where you either want to inspect the code or
generate it once and load multiple times (useful in some workflows
with CUDA models).
dust_generate(
filename,
quiet = FALSE,
workdir = NULL,
gpu = FALSE,
real_type = NULL,
linking_to = NULL,
cpp_std = NULL,
compiler_options = NULL,
optimisation_level = NULL,
mangle = FALSE
)
filename |
The path to a single C++ file |
quiet |
Logical, indicating if compilation messages from
|
workdir |
Optional working directory to use. If |
gpu |
Logical, indicating if we should generate GPU
code. This requires a considerable amount of additional software
installed (CUDA toolkit and drivers) as well as a
CUDA-compatible GPU. If |
real_type |
Optionally, a string indicating a substitute type to
swap in for your model's |
linking_to |
Optionally, a character vector of additional
packages to add to the |
cpp_std |
The C++ standard to use, if you need to set one
explicitly. See the section "Using C++ code" in "Writing R
extensions" for the details of this, and how it interacts with
the R version currently being used. For R 4.0.0 and above, C++11
will be used; as dust depends on at least this version of R you
will never need to specify a version this low. Sensible options
are |
compiler_options |
A character vector of additional options
to pass through to the C++ compiler. These will be passed
through without any shell quoting or validation, so check the
generated commands and outputs carefully in case of error. Note
that R will apply these before anything in your personal
|
optimisation_level |
A shorthand way of specifying common
compiler options that control optimisation level. By default
( |
mangle |
Logical, indicating if the model name should be
mangled when creating the package. This is safer if you will
load multiple copies of the package into a single session, but
is |
The path to the generated package (will be workdir
if
that was provided, otherwise a temporary directory).
filename <- system.file("examples/walk.cpp", package = "dust")
path <- dust::dust_generate(filename)
# Simple package created:
dir(path)
dir(file.path(path, "R"))
dir(file.path(path, "src"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.