[Rd] How to safely using OpenMP pragma inside a .C() function?

pawelm pawel.matykiewicz at gmail.com
Wed Aug 31 22:46:06 CEST 2011

I just found this (performance improvement of the "dist" function when using

.Internal(setMaxNumMathThreads(1)); .Internal(setNumMathThreads(1)); m <-
matrix(rnorm(810000),900,900); system.time(d <- dist(m))

  user  system elapsed 
  3.510   0.013   3.524 

.Internal(setMaxNumMathThreads(5)); .Internal(setNumMathThreads(5)); m <-
matrix(rnorm(810000),900,900); system.time(d <- dist(m));

   user  system elapsed 
  3.536   0.007   1.321 

Works great! Just the question stays if it's a good practice to use
"R_num_math_threads" in external packages?


View this message in context: http://r.789695.n4.nabble.com/How-to-safely-use-OpenMP-pragma-inside-a-C-function-tp3777036p3782178.html
Sent from the R devel mailing list archive at Nabble.com.

More information about the R-devel mailing list