title: OpenBLAS routine used from R/Rcpp runs only on a single core in linux
body: <p>I am trying to run a QR decomposition (LAPACKE_dgeqrf) in R on a linux machine (CentOS) using a C++ program that is interfaced with Rcpp. Unfortunately, I see only 100% using top. This also happens on a Red Hat Enterprise Linux Server. However, the C++ program (with LAPACKE_dgeqrf) runs at nthreads * 100% when started from the terminal (independently outside of R). I compiled OpenBLAS with </p>
  
  <pre><code>NO_AFFINITY=1 
  </code></pre>
  
  <p>and tried </p>
  
  <pre><code>export OPENBLAS_NUM_THREADS=4
  export GOTO_NUM_THREADS=4
  export OMP_NUM_THREADS=4
  export OPENBLAS_MAIN_FREE=1
  </code></pre>
  
  <p>Nothing works. Everything works fine on a Mac though. 'mcaffinity()' from the parallel R package returns NULL. I configured R using </p>
  
  <pre><code>configure  'CFLAGS=-g -O3 -Wall -pedantic' 'CXXFLAGS=-g -O3 -Wall -pedantic' 'FCFLAGS=-g -O3' 'F77FLAGS=-g -O3' '--with-system-zlib' '--enable-memory-profiling'
  </code></pre>
  
  <p>My C++ code:</p>
  
  <pre><code>#include &lt;Rcpp.h&gt;
  #include &lt;lapacke.h&gt;
  #include &lt;cblas.h&gt;
  
  //[[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;
  }
  </code></pre>
  
  <p>My R code:</p>
  
  <pre><code>PKG_LIBS &lt;- '/pathto/openblas/lib/libopenblas.a' 
  PKG_CPPFLAGS &lt;- '-I/pathto/openblas/include'
  Sys.setenv(PKG_LIBS = PKG_LIBS , PKG_CPPFLAGS = PKG_CPPFLAGS) 
  Rcpp::sourceCpp('/pathto/QRopenblas.cpp', rebuild = TRUE)
  
  n_row &lt;- 4000
  n_col &lt;- 4000
  A &lt;- matrix(rnorm(n_row * n_col), n_row, n_col)
  res &lt;- QRopenblas(A)
  </code></pre>