Skip to content

Instantly share code, notes, and snippets.

@vjcitn
Created July 18, 2025 09:16
Show Gist options
  • Save vjcitn/1db65a60e322221d9340913823431cca to your computer and use it in GitHub Desktop.
Save vjcitn/1db65a60e322221d9340913823431cca to your computer and use it in GitHub Desktop.
code and tests for BLAS setup in macOS
# reference for managing BLAS usage -- https://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#Which-BLAS-is-used-and-how-can-it-be-changed_003f-1
# script
print(extSoftVersion()["BLAS"])
# global matrix value
set.seed(1234)
x = rnorm(500)
y = x %*% t(x)
# compute svd
dosvd = function() svd(y)
# quiet iteration
sink("/tmp/dmp")
tim = system.time(uu <- replicate(100, dosvd()))
sink(NULL)
# timing
tim
# result of source('testsvd.R') with R 4.5.1 as shipped for macOS on old M1 mac
#
# BLAS
#"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib"
#...
#> tim
# user system elapsed
# 37.253 0.144 37.534
#
# # result after switching to vecLib as suggested in FAQ noted above via symlinks
#
# BLAS
#"/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib"
#...
#> tim
# user system elapsed
# 4.766 1.670 4.349
# result within container obtained via docker pull bioconductor/bioconductor_docker:devel on jul 19 2025
#
# BLAS
#"/usr/lib/aarch64-linux-gnu/openblas-pthread/libblas.so.3"
#> tim
# user system elapsed
# 88.020 64.182 25.628
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment