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

2011-08-31 Thread pawelm
I just found this (performance improvement of the "dist" function when using openmp): .Internal(setMaxNumMathThreads(1)); .Internal(setNumMathThreads(1)); m <- matrix(rnorm(81),900,900); system.time(d <- dist(m)) user system elapsed 3.510 0.013 3.524 .Internal(setMaxNumMathThreads

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

2011-08-31 Thread pawelm
Simon, This is very useful example and explanation. Thank you very, very much. The icing on the cake would be some guidelines how to set up the number of threads. R source code uses global variable R_num_math_threads. Can we use that? Or each openmp-enabled R package would have it's own mechanism?

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

2011-08-30 Thread pawelm
Simon, I found that files R-2.13.1/src/library/stats/src/distance.c and R-2.13.1/src/main/array.c have openmp code (example below). I have couple questions regarding best practices when using R internals and openmp. Can we use R-2.13.1/src/library/stats/src/distance.c and R-2.13.1/src/main/array