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
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?
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