| Title: | Runtime 'SIMD' Dispatch Templates for 'C' Code in 'R' Packages |
|---|---|
| Description: | Provides templates and a working example for runtime Single Instruction Multiple Data ('SIMD') dispatch in 'C' code used by 'R' packages. Packages can stage scalar and architecture-specific kernel objects during configuration, then select a compiled and CPU-supported implementation at runtime through guarded function pointers. The package also vendors the header-only 'SIMDe' library for downstream packages through the 'LinkingTo' field. |
| Authors: | Sounkou Mahamane Toure [aut, cre], Evan Nemerson [cph] (SIMDe copyright holder), SIMDe contributors [ctb] (Contributors to the bundled SIMDe header library) |
| Maintainer: | Sounkou Mahamane Toure <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.1.1 |
| Built: | 2026-06-01 21:02:24 UTC |
| Source: | https://github.com/cran/RsimdDispatch |
Demonstration kernel for the runtime dispatch template. count_nonzero()
counts bytes that are not 00 in a raw vector using the currently selected
backend. The default backend is "auto", which selects the best compiled
backend supported by the current CPU/runtime.
count_nonzero(x)count_nonzero(x)
x |
A raw vector. |
A numeric scalar count.
count_nonzero(as.raw(c(0, 1, 0, 2)))count_nonzero(as.raw(c(0, 1, 0, 2)))
Report the currently selected SIMD backend
simd_backend()simd_backend()
A character scalar naming the selected backend.
simd_backend()simd_backend()
use_simd_dispatch() copies the dispatch scaffold into an R package and
performs the package-name and C-prefix substitutions needed for a working
package. It writes package files, updates DESCRIPTION, .Rbuildignore,
and .gitignore, and returns the copied paths invisibly.
simd_dispatch_template_path() use_simd_dispatch( path = ".", pkg = NULL, prefix = NULL, overwrite = FALSE, quiet = FALSE )simd_dispatch_template_path() use_simd_dispatch( path = ".", pkg = NULL, prefix = NULL, overwrite = FALSE, quiet = FALSE )
path |
Package root where the template should be copied. |
pkg |
R package name. If |
prefix |
C symbol prefix used to replace |
overwrite |
Whether to overwrite existing files. |
quiet |
Whether to suppress progress messages. |
Invisibly returns copied file paths.
This function is intended for package authors. It is not needed at runtime by users of packages that already include generated dispatch code.
simd_dispatch_template_path()simd_dispatch_template_path()
Returns the requested backend, selected backend, compiled backends, CPU-supported backends, SIMDe-native backends, target information, and SIMDe provenance compiled into the shared library. Calling this initializes the lazy auto-dispatch selection if it has not already been initialized.
simd_info()simd_info()
A named list of dispatch and CPU feature diagnostics. Backend-set entries are character vectors, not comma-separated strings.
names(simd_info())names(simd_info())
Select the backend used by subsequent calls to count_nonzero().
RsimdDispatch keeps all compiled variants in one shared object and switches
guarded function pointers. This makes same-process benchmarking possible.
simd_set_backend( backend = c("auto", "scalar", "sse2", "sse41", "avx2", "avx512", "neon") )simd_set_backend( backend = c("auto", "scalar", "sse2", "sse41", "avx2", "avx512", "neon") )
backend |
One of |
The selected backend, invisibly. For "auto", this is the backend
chosen from the compiled and CPU-supported set.
old <- simd_backend() simd_set_backend("scalar") simd_set_backend("auto")old <- simd_backend() simd_set_backend("scalar") simd_set_backend("auto")
simde_info() reports the version, upstream repository, pinned commit, and
commit date for the bundled header-only SIMDe library.
simde_info()simde_info()
A named list of character scalars describing the vendored SIMDe copy.
simde_info()[c("version", "commit")]simde_info()[c("version", "commit")]