On 23 October 2012 at 09:46, Rodney Sparapani wrote: | On 09/25/2012 04:45 PM, Dirk Eddelbuettel wrote: | > | > I use and recommend ~/.R/Makevars for that --- as setting certain values at | > the package level is very verboten ("non portable code" and all that) as far | > as CRAN is concerned. | > | > Now, that's the "how do you" part. As for "does it matter" that is a | > different beast as -O2 (or better) is already the default for R on my systems | > (running the vanilla Ubuntu packages based on my Debian packaging). | > | > Dirk | > | | Hi Dirk: | | I hope this not too far off-topic. I don't want to show my messy code, | but I learned a lot about optimization on my own system which I assume | would be useful to others. I was comparing an MCMC sampler written in | R with a line for line translation via inline/RcppEigen. | | So, getting back to this discussion... "The way" to do this is to | optimize R from the get go and then Rcpp/RcppEigen/etc. inherit the | appropriate switches. And, as Dirk said, the RPM of R in the repo does | have -O2 (and a bunch of other switches which I don't know anything | about). However, I found that R in the repo was no faster than my | naive compilation of R from source which did not include -O2 (or any | other black magic). | | What gives? What I found that does speed up the code dramatically | is the -march switch. I guess that can't be repo-ed because it is | CPU dependent, right? Here's the important settings that I used to | compile R from source:
Using -march=native lets gcc pick the best one without you having to know the label gcc may use. That said, _distribution builds_ cannot use this as they will not know your cpu, and need to provide code for all compatible platforms (eg all 'amd64'). But configuration and optimisation of R is (I fear) a little off-topic here. Maybe try r-devel? Dirk | | CC="gcc" | CFLAGS="-g -O2 -march=amdfam10" | CXX="g++" | CXXFLAGS="-g -O2 -march=amdfam10" | | With these settings... | | MCMC Code Switches Relative Time | R none or -O2 1.0 | RcppEigen none or -O2 0.09 | R -O2 -march=amdfam10 0.5 | RcppEigen -O2 -march=amdfam10 0.013 | | -- | Rodney Sparapani, PhD Center for Patient Care and Outcomes Research | Sr. Biostatistician http://www.mcw.edu/pcor | 4 wheels good, 2 wheels better! Medical College of Wisconsin (MCW) | WWLD?: What Would Lombardi Do? Milwaukee, WI, USA -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel