c++ - Rcpp with Intel MKL Multithreading -


i wrote c++ shared library uses intel mkl blas operations, , threads beautifully, using 12 cores of machine. trying use rcpp call function library, , finding single threaded. in, same data, when same function called c++, uses 12 cores quickly, whereas when rcpp calls it, single threaded , takes longer (but results consistent).

intel mkl dynamically linked library thusly:

makefile:

libraries=-lpthread -wl,--no-as-needed -l<directory>bin -liomp5 -l<bin_directory> -lmkl_mc3 -lmkl_intel_lp64 -lmkl_gnu_thread -ldl  -lmkl_core  -lm  -dmkl_ilp64  -fopenmp lflags=-o3 -i/opt/intel/composer_xe_2015/mkl/include -std=c++0x -m64  #compiles shared library g++ -fpic -shared <cpp files> -oliblibrary.so  $(libraries) -o3 -i/opt/intel/composer_xe_2015/mkl/include -std=c++0x -m64  #compile controller r, can loaded dyn.load() pkg_libs='`rscript -e "rcpp:::ldflags() $(libraries) $(lflags)"`' \ pkg_cxxflags='`rscript -e "rcpp:::cxxflags()"` $(libraries) $(lflags) ' \ r cmd shlib fastrpca.cpp -o../bin/rprogram.so -l../bin -llibrary 

then call in r:

dyn.load("fastrpca.so", local=false); 

please note prefer not setting mkl blas/lapack alternative r, when other people use code don't have change of r. such, trying use in c code.

how can make program multithread in rcpp when run outside of r?

based on this discussion, concerned not possible. however, wanted ask, because believe since intel mkl uses openmp, perhaps there way make work.

there 2 rules working r code:

  1. create package.

  2. follow rule 1.

you making life hard ignoring these.

moreover, there number of packages on cran happily using openmp -- study those. need know , learn thread setting -- see eg rhpcblasctl package this.

lastly, can of course connect r directly mkl; see the gcbd package , vignette.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -