From ripley at stats.ox.ac.uk  Sat Oct 13 10:57:22 2012
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Sat, 13 Oct 2012 09:57:22 +0100
Subject: [Rd] Multithreaded code in .Call interface
In-Reply-To: <CAApt6DJx=5yH2T=R424XkO9+nDUo_vh-AV7TuYZf8ANESzvJxg@mail.gmail.com>
References: <CAApt6DJx=5yH2T=R424XkO9+nDUo_vh-AV7TuYZf8ANESzvJxg@mail.gmail.com>
Message-ID: <50792CF2.4010006@stats.ox.ac.uk>

On 13/10/2012 08:09, Rob Anderson wrote:
> Hi,
>
> I was wondering if it is safe to call R functions and/or R BLAS functions
> from within multithreaded C/C++ code(.Call interface)? It is not in case
> with MATLAB. I was experimenting  using pthreads and OpenMP.

Not unless it is documented to be so.  (I believe the internal BLAS to 
be fine, but you could use an external one: although with care if that 
also uses threads.)

See also ?8.1.5 of 'Writing R Extensions'.

> Thanks,
> Rob


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Multithreaded code in .Call interface
Prof Brian Ripley