--- title: "Getting Started with RsimdDispatch" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Getting Started with RsimdDispatch} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set(collapse = TRUE, comment = "#>") ``` `RsimdDispatch` demonstrates a single-shared-library runtime dispatch pattern for C code in R packages. The package stages scalar and SIMD kernel objects during configuration and switches among compiled, CPU-supported implementations through a guarded resolved operation table. ```{r} library(RsimdDispatch) x <- as.raw(c(0, 1, 2, 0, 255)) a <- c(1, 2, 3) b <- c(10, 100) count_nonzero(x) convolve1d(a, b) simd_backend() ``` Inspect the installed build: ```{r} simd_info()[c("compiled_backends", "available_backends", "operation_selected_backends")] ``` Switching is allowed in the same R process: ```{r} simd_set_backend("scalar") count_nonzero(x) convolve1d(a, b) candidate <- setdiff(simd_info()$operation_backends$convolve1d, "scalar")[1] if (!is.na(candidate)) { simd_set_backend(candidate) count_nonzero(x) convolve1d(a, b) } simd_set_backend("auto") simd_backend() ``` An explicit backend is accepted only when it was compiled and the current CPU/runtime supports it. Unsupported choices error before any ISA-specific code runs.