On 08/29/2011 05:36 PM, Simon Urbanek wrote:
On Aug 29, 2011, at 7:48 PM, Alireza Mahani wrote:
I am trying to parallelize part of a C function that is called from
R (via .C) using OpenMP's parallel for pragma. I get mixed
results: some runs finish with no problem, but some lead to R
crashing
Note that currently R internals do not actually use multiple threads
in OpenMP, and there is no documented way to make them do so.
The main issue is that there is insufficient knowlege of where they
are worthwhile (which is both OS and platform-dependent: we don't even
have reliable
.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(5)); .Internal(setNumMathThreads(5)); m -
matrix(rnorm(81),900,900);
On Aug 30, 2011, at 12:57 PM, pawelm wrote:
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
On Aug 30, 2011, at 12:57 PM, pawelm wrote:
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
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
Pawel,
On Aug 31, 2011, at 4:46 PM, pawelm wrote:
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
I have no R API calls inside the parallelized block. I will work on creating
a self-contained example and post it for your review. Thanks! -Alireza
--
View this message in context:
http://r.789695.n4.nabble.com/How-to-safely-use-OpenMP-pragma-inside-a-C-function-tp3777036p3778482.html
Sent from
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
I am trying to parallelize part of a C function that is called from R (via
.C) using OpenMP's parallel for pragma. I get mixed results: some runs
finish with no problem, but some lead to R crashing after issuing a long
error message involving memory violations.
I found this post, which describes
On Aug 29, 2011, at 7:48 PM, Alireza Mahani wrote:
I am trying to parallelize part of a C function that is called from R (via
.C) using OpenMP's parallel for pragma. I get mixed results: some runs
finish with no problem, but some lead to R crashing after issuing a long
error message
11 matches
Mail list logo