在R中如何控制BLAS并行矩阵乘积中的multi-threading
In R how to control multi-threading in BLAS parallel matrix product
我有一个关于在 R 中使用 BLAS 并行化矩阵乘积的问题(至少从 R-3.4 开始,可能是更早的默认矩阵乘积)。
矩阵乘积(c.f。下面的示例)的默认行为(至少在我的机器上)现在使用机器上所有可用的内核,这可能是个问题。
你知道在R中如何控制标准矩阵乘积的核数吗?
提前致谢
示例:
n=10000
p=1000
q=5000
A = matrix(runif(n*p),nrow=n, ncol=p)
B = matrix(runif(p*q),nrow=p, ncol=q)
C = A %*% B # multi-threaded matrix product
Session 信息:
> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS
Matrix products: default
BLAS: /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.18.so
locale:
[1] LC_CTYPE=fr_FR.utf8 LC_NUMERIC=C
[3] LC_TIME=fr_FR.utf8 LC_COLLATE=fr_FR.utf8
[5] LC_MONETARY=fr_FR.utf8 LC_MESSAGES=fr_FR.utf8
[7] LC_PAPER=fr_FR.utf8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=fr_FR.utf8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.1
包 RhpcBLASctl 只是。
根据其描述:
Control the number of threads on 'BLAS' (Aka 'GotoBLAS', 'ACML' and 'MKL'). and possible to control the number of threads in 'OpenMP'. get a number of logical cores and physical cores if feasible.
我们在CRAN Task View on HPC中提到了它。
我有一个关于在 R 中使用 BLAS 并行化矩阵乘积的问题(至少从 R-3.4 开始,可能是更早的默认矩阵乘积)。
矩阵乘积(c.f。下面的示例)的默认行为(至少在我的机器上)现在使用机器上所有可用的内核,这可能是个问题。
你知道在R中如何控制标准矩阵乘积的核数吗?
提前致谢
示例:
n=10000
p=1000
q=5000
A = matrix(runif(n*p),nrow=n, ncol=p)
B = matrix(runif(p*q),nrow=p, ncol=q)
C = A %*% B # multi-threaded matrix product
Session 信息:
> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS
Matrix products: default
BLAS: /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.18.so
locale:
[1] LC_CTYPE=fr_FR.utf8 LC_NUMERIC=C
[3] LC_TIME=fr_FR.utf8 LC_COLLATE=fr_FR.utf8
[5] LC_MONETARY=fr_FR.utf8 LC_MESSAGES=fr_FR.utf8
[7] LC_PAPER=fr_FR.utf8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=fr_FR.utf8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.1
包 RhpcBLASctl 只是。
根据其描述:
Control the number of threads on 'BLAS' (Aka 'GotoBLAS', 'ACML' and 'MKL'). and possible to control the number of threads in 'OpenMP'. get a number of logical cores and physical cores if feasible.
我们在CRAN Task View on HPC中提到了它。