问题
I got tons of warning from openBLAS like
OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.
OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.
OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.
OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.
OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.
OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.
OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.
OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.
Here is what my src/Makevars file looks like
PKG_CPPFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
And here is my header file:
#define ARMA_NO_DEBUG
#ifdef _OPENMP
#include <omp.h>
#endif
//[[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
//[[Rcpp::depends(RcppProgress)]]
#include <progress.hpp>
#include <Rcpp.h>
#include <R.h>
openMP is used in my code like this
#pragma omp parallel for num_threads(n_threads) schedule(dynamic) private(W, mu)
for (unsigned int j = 0; j < m; j++)
where n_threads
is passed via function argument. Everything is fine when n_threads = 1
but got the above warnings when n_threads = 2
.
A complete code can be found here, which depends on other files as well (sorry I cannot paste here as it is a bit long).
I tried adding USE_OPENMP=1
to src/Makevars, but it does not work. Any body has a solution? Thank you!
回答1:
I got the same warnings while running Torch on CPU mode. Rebuilding OpenBLAS with OPEN_MP 1 fixed it for me.
If you want to rebuild OpenBLAS with OPEN_MP 1, then:
Go to the folder where you cloned OpenBLAS repository (for me it is /home/brt/code/OpenBLAS)
cd /home/brt/code/OpenBLAS/
make clean
make USE_OPENMP=1
sudo make install
if you have not already done so,
sudo vi /etc/ld.so.conf.d/openblas.conf
add the line: /opt/OpenBLAS/lib
save and close
sudo ldconfig
This should rebuild OpenBLAS with OPEN_MP as 1
来源:https://stackoverflow.com/questions/34578526/how-to-make-openblas-work-with-openmp