[Rcpp-devel] Thread handling

Dirk Eddelbuettel edd at debian.org
Wed Apr 27 15:10:55 CEST 2011

Hi Joseph,

That is a good point so allow me to bounce this back to the list too.

On 26 April 2011 at 21:58, Joseph W. Brown wrote:
| I have been using the multicore package to do multithreading in R. I am pretty
| new to Rcpp. Is there any obvious reason why using multiple R threads to call
| individual Rcpp functions would not work?

Correct.   You can also do 

  -- 'outer MPI program' with multiple independent R instances, see RInside's
     examples/mpi which already does 

  -- similarly, use Rmpi / doMPI, or multicore / doM, or ... to spawn
     multiple R processes each of which can call functions created with Rcpp
     (which each should be thought of as single-threaded as usual)

  -- use openMP as suggested by Peter

  -- and possibly much more.

The point is each R instance is single-threaded and can not be 'touched' by
multiple threads. If they are properly shielded we can of course use several
of them on multicore computers, multiple node clusters, combinations of both,
etc ... 

Hope this helps,  Dirk

Gauss once played himself in a zero-sum game and won $50.
                      -- #11 at http://www.gaussfacts.com

More information about the Rcpp-devel mailing list