<div dir="ltr">Good point by Dirk.<br><div class="gmail_extra"><br></div><div class="gmail_extra">And why not just adding a line "export OPENBLAS_NUM_THREADS=1" to your .bashrc file, or compiling OpenBlas again by setting NUM_THREADS = 1 in the Makefile.rule?<br>
<br><br></div><div class="gmail_extra">Best,<br></div><div class="gmail_extra">Yixuan<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-08-11 18:55 GMT-04:00 Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Hi Scott,<br>
<div><div class="h5"><br>
<br>
On 12 August 2014 at 08:43, Scott Ritchie wrote:<br>
| Hi Everyone,<br>
|<br>
| I'm having trouble with restricting the Armadillo function "svd_econ" to run on<br>
| a single thread.<br>
|<br>
| I am able to restrict it if I `export OPENBLAS_NUM_THREADS=1` before opening an<br>
| R session, but not from within R (`Sys.setenv(OPENBLAS_NUM_THREADS=1)` has no<br>
| effect).<br>
|<br>
| I'm wondering if theirs an option native to armadillo/RcppArmadillo that I'm<br>
| missing to enable me to:<br>
|<br>
|   • Restrict the number of threads used to 1<br>
|   • In a library agnostic manner (i.e. if the user has a different LAPACK or<br>
|     BLAS library installed).<br>
|<br>
| or if I can "trick" Rcpp into thinking the machine only has 1 core?<br>
<br>
</div></div>I fear you may be misstating / misdiagnosing the problem.<br>
<br>
I am fairly certain that there is not a single line in Rcpp or<br>
(Rcpp)Armadillo which sets thread counts for your LAPACK / BLAS.<br>
<br>
Rather, and this is a point that I tried to make in the 'Benchmarking GPUs<br>
and CPUs on Debian-based systems' package (gcbd on CRAN etc) and its vignette<br>
is that __BLAS and LAPACK sit behind a standardized interface__ and can be<br>
installed / swapped via plug and play. (Which in turn enables the<br>
benchmarking ...)<br>
<br>
If you're on a Debian-based system, just remove openblas and use atlas. Case<br>
closed.  Atlas will not multithread (unless something changed recently).<br>
<br>
There is also a helper function or package somewhere, and a post by Claudia<br>
Beleites on StackOverflow, which show the explicit function call to reset<br>
OpenBLAS in its count.  But if everything else fails -- just use a different<br>
BLAS.  I sometimes do that too when I use multicore / parallel to launch<br>
multiple R jobs and each one of those should not spawn additional linear<br>
algebra threads.<br>
<br>
Hope this helps,  Dirk<br>
<br>
<br>
<br>
| Regards,<br>
|<br>
| Scott Ritchie<br>
| _______________________________________________<br>
| Rcpp-devel mailing list<br>
| <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
| <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
<span class=""><font color="#888888"><br>
--<br>
<a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a><br>
_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a></font></span></blockquote></div><br><br clear="all">
<br>-- <br>Yixuan Qiu <<a href="mailto:yixuan.qiu@cos.name" target="_blank">yixuan.qiu@cos.name</a>><br>Department of Statistics,<br>Purdue University<br>
</div></div>