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

From: pawelm <>
Date: Wed, 31 Aug 2011 13:46:06 -0700 (PDT)

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

.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:
Sent from the R devel mailing list archive at

______________________________________________ mailing list
Received on Wed 31 Aug 2011 - 20:49:05 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 01 Sep 2011 - 03:30:25 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive