Hello. The laboratory where I work has the possibility to get a Sun machine with 12 processors. My question is: can R be used to implememt parallel algorithms which take into account the several processors? Is there a way to run *threads* in R? If this is possible, would somebody share his/her experiences? Thanks. Isabel -- Isabel Cañette Iguá 4225 Centro de Matemática 11400 Montevideo Facultad de Ciencias Uruguay isabelc at cmat.edu.uy -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I don't know much about the internals of R, but I would imagine that one could at least get the large linear algebra problems to work with a parallelized LINPACK or LAPACK. Do you have really large problems? If not, the overhead might be so high that it isn't worth going parallel. -- Ed Borasky http://www.aracnet.com/~znmeb mailto:znmeb at aracnet.com Q: What phrase will you never hear Candice Bergen use? A: "My daddy didn't raise no dummies". -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Wed, 14 Feb 2001, Isabel Canette wrote:> Hello. > > The laboratory where I work has the possibility to get a Sun machine with 12 > processors. My question is: can R be used to implememt parallel algorithms > which take into account the several processors? Is there a way to run *threads* > in R? > > If this is possible, would somebody share his/her experiences?It is not possible to run threads in R. However, it is possible to call other threaded code, as the R-Java and R-Tcl interfaces demonstrate. You could probably call parallel C or Fortran code. Alternatively, for a problem with fairly low communication requirements you could control multiple R processes from one central program and feed them each bits of computation. I usually want to run any given computation lots of times, so the solution is easy: instead of running it 1000 times on 1 processor, run it 80 times on each of 12 processors. -thomas Thomas Lumley Asst. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
R is inefficient enough that if you need 12 processors you may consider writing your function in C. Alternatively you can identify the part of your R code where most your CPU cycles are being used and make that a function in C. Porting large chucks of R code or even small routines that are gobbling up CPU cycles can give your orders of magnitude speed changes! Once you learn how to do it, letting R call external compiled function is really very easy. At 8:26 AM -0800 2/15/01, Thomas Lumley wrote:>On Wed, 14 Feb 2001, Isabel Canette wrote: > >> Hello. >> >> The laboratory where I work has the possibility to get a Sun machine with 12 >> processors. My question is: can R be used to implememt parallel algorithms >> which take into account the several processors? Is there a way to >>run *threads* >> in R? >> >> If this is possible, would somebody share his/her experiences? > >It is not possible to run threads in R. However, it is possible to call >other threaded code, as the R-Java and R-Tcl interfaces demonstrate. You >could probably call parallel C or Fortran code. Alternatively, for a >problem with fairly low communication requirements you could control >multiple R processes from one central program and feed them each bits of >computation. > >I usually want to run any given computation lots of times, so the solution >is easy: instead of running it 1000 times on 1 processor, run it 80 times >on each of 12 processors. > > -thomas > >Thomas Lumley Asst. Professor, Biostatistics >tlumley at u.washington.edu University of Washington, Seattle > >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- >r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html >Send "info", "help", or "[un]subscribe" >(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch >_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- Tony Long Ecology and Evolutionary Biology Steinhaus Hall University of California at Irvine Irvine, CA 92697-2525 Tel: (949) 824-2562 (office) Tel: (949) 824-5994 (lab) Fax: (949) 824-2181 email: tdlong at uci.edu http://hjmuller.bio.uci.edu/~labhome/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> Cc: Isabel Canette <isabelc at cmat.edu.uy>, <r-help at stat.math.ethz.ch>This is a general response to some of the issues raised in the discussion about utilizing multiple processors within R. Sorry for responding to this at such a late stage. Time seems to be passing me by quicker than usual these days :-) (This is more suited to r-devel, but since the topic was on r-help, it will hopefully conclude there.) There are plans for multi-threading R, perhaps at the end of this summer. Doing this smoothly so that it doesn't break user-level code and packages requires some planning and thought. I have a plan for this and need to find time to implement it with anyone that is interested. The design I have in mind is much that same as John Chambers and I implemented in S version 4, but implemented entirely from scratch. (See http://cm.bell-labs.com/stat/doc/multi-threaded-S.ps. I'll make a condensed version available when we get closer to implementing the facilities.) I am working on a several different packages that integrate R with (potentially) threaded systems (e.g. Java, Perl, Python, Apache, Netscape, XSLT, Postgres etc.) with the side effect of finding out what support for threads is most urgently needed. Hopefully these will stretch the model and show any deficiencies before we start. Threads, connections, embedding R within databases, distributed computing via CORBA/DCOM/SOAP/RMI, etc., all point to the fact that we need to be working on parallel algorithms. It would be terrific to see people exploring that. * While threads do provide some simplification to the event loop handling, it does so be merely formalizing the synchronization, not removing it. * Clustered or distributed computing is probably most efficient at run-time for many statistical tasks, as Thomas (I believe) pointed out. There are some facilities to do this for R and S-Plus. * It would be good for developers of new C code to write it so that it is thread-safe. There are some guidelines as to how to do this at http://developer.r-project.org/RThreads/ (specifically in guide.html) * From a practical perspective, there are a lot of pitfalls in loading multi-threaded code into R. The order in which libraries are loaded, interacting with the event loop if the multi-threaded code uses X11, etc. are all important. One trick to simplify this is to embed R within the multi-threaded application. This allows the multi-threaded application to be (initially) in control and get its environment appropriately organized before R enters the picture. Thanks for your time. D. -- _______________________________________________________________ Duncan Temple Lang duncan at research.bell-labs.com Bell Labs, Lucent Technologies office: (908)582-3217 700 Mountain Avenue, Room 2C-259 fax: (908)582-3340 Murray Hill, NJ 07974-2070 http://cm.bell-labs.com/stat/duncan -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._