0

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!

4

1 に答える 1

1

Torch を CPU モードで実行しているときに、同じ警告が表示されました。OPEN_MP 1 で OpenBLAS を再構築すると、修正されました。

OPEN_MP 1 で OpenBLAS を再構築する場合は、次のようにします。

OpenBLAS リポジトリのクローンを作成したフォルダーに移動します (私にとっては /home/brt/code/OpenBLAS です)。

cd /home/brt/code/OpenBLAS/
make clean
make USE_OPENMP=1
sudo make install

まだ行っていない場合は、

sudo vi /etc/ld.so.conf.d/openblas.conf

次の行を追加します: /opt/OpenBLAS/lib

保存して閉じます

sudo ldconfig

これにより、OPEN_MP を 1 として OpenBLAS が再構築されます。

于 2016-06-29T18:06:23.910 に答える