The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
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 function
pointer.
library(RsimdDispatch)
x <- as.raw(c(0, 1, 2, 0, 255))
count_nonzero(x)
#> [1] 3
simd_backend()
#> [1] "avx2"Inspect the installed build:
simd_info()[c("compiled_backends", "cpu_supported_backends", "available_backends")]
#> $compiled_backends
#> [1] "scalar" "sse2" "sse41" "avx2" "avx512"
#>
#> $cpu_supported_backends
#> [1] "scalar" "sse2" "sse41" "avx2"
#>
#> $available_backends
#> [1] "scalar" "sse2" "sse41" "avx2"Switching is allowed in the same R process:
simd_set_backend("scalar")
count_nonzero(x)
#> [1] 3
candidate <- setdiff(simd_info()$available_backends, "scalar")[1]
if (!is.na(candidate)) {
simd_set_backend(candidate)
count_nonzero(x)
}
#> [1] 3
simd_set_backend("auto")
simd_backend()
#> [1] "avx2"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.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.