flexiblas-backends {flexiblas}R Documentation

Handle Backends

Description

Get current backend, list available ones, load and switch between backends.

Usage

flexiblas_current_backend()

flexiblas_list()

flexiblas_list_loaded()

flexiblas_load_backend(name)

flexiblas_switch(n)

Arguments

name

character vector of backend names or paths (case insensitive).

n

loaded backend index.

Value

flexiblas_current_backend and ⁠flexiblas_list*⁠ return a character vector of backend names or paths.

flexiblas_load_backend and flexiblas_switch return the indices of the loaded backends if the operation was successful, or fail otherwise.

See Also

flexiblas_avail, flexiblas_version, flexiblas-threads

Examples


n <- 2000
runs <- 10
ignore <- "__FALLBACK__"

A <- matrix(runif(n*n), nrow=n)
B <- matrix(runif(n*n), nrow=n)

# load backends
backends <- setdiff(flexiblas_list(), ignore)
idx <- flexiblas_load_backend(backends)

# benchmark
timings <- sapply(idx, function(i) {
  flexiblas_switch(i)

  # warm-up
  C <- A[1:100, 1:100] %*% B[1:100, 1:100]

  unname(system.time({
    for (j in seq_len(runs))
      C <- A %*% B
  })[3])
})

if (length(timings)) {
  results <- data.frame(
    backend = backends,
    `timing [s]` = timings,
    `performance [GFlops]` = (2 * (n / 1000)^3) / timings,
    check.names = FALSE)

  results[order(results$performance),]
}


[Package flexiblas version 3.4.0 Index]