我正在尝试使用与Rcpp连接的C++程序在Linux机器(CentOS)上运行R分解(LAPACKE_dgeqrf).不幸的是,我看到只有100%使用top.这也发生在Red Hat Enterprise Linux服务器上.但是,从终端(独立于R外部)启动时,C++程序(带有LAPACKE_dgeqrf)以nthreads*100%运行.我用Open编译了OpenBLAS
NO_AFFINITY=1
Run Code Online (Sandbox Code Playgroud)
并尝试过
export OPENBLAS_NUM_THREADS=4
export GOTO_NUM_THREADS=4
export OMP_NUM_THREADS=4
export OPENBLAS_MAIN_FREE=1
Run Code Online (Sandbox Code Playgroud)
什么都行不通.虽然在Mac上一切正常.并行R包中的'mcaffinity()'返回NULL.我用R配置了R.
configure 'CFLAGS=-g -O3 -Wall -pedantic' 'CXXFLAGS=-g -O3 -Wall -pedantic' 'FCFLAGS=-g -O3' 'F77FLAGS=-g -O3' '--with-system-zlib' '--enable-memory-profiling'
Run Code Online (Sandbox Code Playgroud)
我的C++代码:
#include <Rcpp.h>
#include <lapacke.h>
#include <cblas.h>
//[[Rcpp::export]]
Rcpp::NumericMatrix QRopenblas(Rcpp::NumericMatrix X)
{
// Declare variables
int n_rows = X.nrow(), n_cols = X.ncol(), min_mn = std::min(n_rows, n_cols);
Rcpp::NumericVector tau(min_mn);
// Perform QR decomposition
LAPACKE_dgeqrf(CblasColMajor, n_rows, n_cols, X.begin(), n_rows, tau.begin());
return X;
}
Run Code Online (Sandbox Code Playgroud)
我的R代码:
PKG_LIBS <- '/pathto/openblas/lib/libopenblas.a'
PKG_CPPFLAGS <- '-I/pathto/openblas/include'
Sys.setenv(PKG_LIBS = …Run Code Online (Sandbox Code Playgroud)