Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
^scripts$
^AGENTS.md$
^CRAN-SUBMISSION$
^docs$
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Suggests:
cli,
pkgload (>= 1.4.0),
rlang,
testthat (>= 3.0.0)
testthat (>= 3.0.0),
withr
Config/testthat/edition: 3
Config/testthat/parallel: true
Config/testthat/start-first: unary-intrinsics, loops
Expand Down
2 changes: 2 additions & 0 deletions R/c-wrapper.R
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ dims2c_eval_base_env[["%%"]] <- function(e1, e2) {
glue("((R_xlen_t){e1} % (R_xlen_t){e2})")
}
dims2c_eval_base_env[["^"]] <- function(e1, e2) glue("({e1}**{e2})")
dims2c_eval_base_env[["min"]] <- function(e1, e2) glue("(((R_xlen_t){e1} < (R_xlen_t){e2}) ? (R_xlen_t){e1} : (R_xlen_t){e2})")
dims2c_eval_base_env[["max"]] <- function(e1, e2) glue("(((R_xlen_t){e1} > (R_xlen_t){e2}) ? (R_xlen_t){e1} : (R_xlen_t){e2})")


dims2c <- function(dims, scope) {
Expand Down
2 changes: 2 additions & 0 deletions R/manifest.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ dims2f_eval_base_env[["%%"]] <- function(e1, e2) {
glue("mod(int({e1}), int({e2}))")
}
dims2f_eval_base_env[["^"]] <- function(e1, e2) glue("({e1})**({e2})")
dims2f_eval_base_env[["min"]] <- function(e1, e2) glue("min({e1}, {e2})")
dims2f_eval_base_env[["max"]] <- function(e1, e2) glue("max({e1}, {e2})")


dims2f <- function(dims, scope) {
Expand Down
24 changes: 23 additions & 1 deletion R/quick.R
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,32 @@ compile <- function(fsub, build_dir = tempfile(paste0(fsub@name, "-build-"))) {
writeLines(fsub, fsub_path)
writeLines(c_wrapper, c_wrapper_path)

# Link against the same BLAS/LAPACK/Fortran libs as the running R
# to support generated calls to vendor BLAS (e.g., dgemm, dgesv).
cfg <- function(var) tryCatch({
out <- system2(
R.home("bin/R"),
c("CMD", "config", var),
stdout = TRUE,
stderr = FALSE
)
paste(out, collapse = " ")
}, error = function(e) "")

BLAS_LIBS <- strsplit(cfg("BLAS_LIBS"), "[[:space:]]+")[[1]]
LAPACK_LIBS <- strsplit(cfg("LAPACK_LIBS"), "[[:space:]]+")[[1]]
FLIBS <- strsplit(cfg("FLIBS"), "[[:space:]]+")[[1]]
# clean empties
BLAS_LIBS <- BLAS_LIBS[nzchar(BLAS_LIBS)]
LAPACK_LIBS <- LAPACK_LIBS[nzchar(LAPACK_LIBS)]
FLIBS <- FLIBS[nzchar(FLIBS)]

link_flags <- c(LAPACK_LIBS, BLAS_LIBS, FLIBS)

suppressWarnings({
result <- system2(
R.home("bin/R"),
c("CMD SHLIB --use-LTO", "-o", dll_path, fsub_path, c_wrapper_path),
c("CMD SHLIB --use-LTO", "-o", dll_path, fsub_path, c_wrapper_path, link_flags),
stdout = TRUE,
stderr = TRUE
)
Expand Down
Loading
Loading