[Rd] Single-threaded aspect

Duncan Murdoch murdoch.duncan at gmail.com
Thu May 12 15:12:07 CEST 2016


On 12/05/2016 8:45 AM, Charles Determan wrote:
> R Developers,
>
> Could someone help explain what it means that R is single threaded?  I am
> trying to understand what is actually going on inside R when users want to
> parallelize code.  For example, using mclapply or foreach (with some
> backend) somehow allows users to benefit from multiple CPUs.

I don't know what document you are quoting when you say "R is single 
threaded", but one possible meaning is that most base R calculations are 
done in a single thread.  When you do vectorized calculations like x+y 
for long vectors x and y, they are done internally as loops over the 
entries.

On Windows, there are two threads when running Rterm, with one to 
maintain the display, since otherwise the plot display couldn't update 
while R is waiting for input.

The mclapply function in the parallel package forks the process to do 
its calculations.

Other packages can do other variations on parallel computations.

I can't help you with the rest of your question, I don't know what XPtr 
objects are.

Duncan Murdoch

>
> Similarly there is the RcppParallel package for RMatrix/RVector objects.
> But none of these address the general XPtr objects in Rcpp.  Some readers
> here may recognize my question on SO (
> http://stackoverflow.com/questions/37167479/rcpp-parallelize-functions-that-return-xptr)
> where I was curious about parallel calls to C++/Rcpp functions that return
> XPtr objects.  I am being a little more persistent here as this limitation
> provides a very hard stop on the development on one of my packages that
> heavily uses XPtr objects.  It's not meant to be a criticism or intended to
> be rude, I just want to fully understand.
>
> I am willing to accept that it may be impossible currently but I want to at
> least understand why it is impossible so I can explain to future users why
> parallel functionality is not available.  Which just echos my original
> question, what does it mean that R is single threaded?
>
> Kind Regards,
> Charles
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



More information about the R-devel mailing list