2

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!

Eric
  • 253
  • 1
  • 3
  • 7
  • 2
    Can you please post a _complete and reproducible example_ rather than mere snippets? – Dirk Eddelbuettel Jan 03 '16 at 16:40
  • @DirkEddelbuettel Thanks for quick reply. The code is big long and depends on others, but you can see it on my github [here](https://github.com/linxihui/NNLM/blob/master/src/update_with_missing.cpp). Does it sound OK, or too much that I should probably create a standalone similar but smaller example? – Eric Jan 03 '16 at 16:52
  • 2
    It's easy: If you want help, _make it easy for us to help you_. I am sorry but I don't have time to chase yet another random GH repo. And for starters: consider 1) Remove RcppProgress and 2) Check the Rcpp Gallery examples for OpenMP. This stuff generally works. OpenMP is even used inside R. But without a reproducible example ... – Dirk Eddelbuettel Jan 03 '16 at 16:59

1 Answers1

3

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

Arijit Ray
  • 51
  • 6