[R] How to verify R is running with multi-threads

Charles C. Berry cberry at tajo.ucsd.edu
Thu Feb 19 02:56:06 CET 2009


On Wed, 18 Feb 2009, Jong wrote:

> Hi all,
>
> I've compiled R (version 2.8.1) from the source code with "--with-
> blas=" option in order to use external multi-threaded blas package.
> However, it's very hard to verify that compilation is correct and R is
> using multi-threads correctly or not. Which command or operation in R
> will run with multi-threads?
>
> I assumed that matrix multiplication %*% may call multi-threaded blas
> operation. So, I run the following code:
>
> n <- 2000
> T = matrix(runif(n*n), nrow=n, ncol=n)
> system.time(T %*% T)

that should have done it. On my (Core 2 Duo) MacBook

> x <- matrix(rnorm(1e6),100)
> system.time(t(x)%*%x) ## user + system < elapsed
    user  system elapsed
   4.221   0.951   2.719
> system.time(crossprod(x)) ## ditto
    user  system elapsed
   2.933   0.898   2.665
>

showing the vecLib (Mac's BLAS) is multithreaded.

HTH,

Chuck

>
> and watch R process by using unix top command with show-all-threads
> option. However, it seems like my R doesn't use multi-threads but just
> run with single thread. Is there any other command that I can use to
> verify multi-threads use?
>
> Regarding the with-blas option, I have tried to use either atlas or
> gotoblas with the following configure option:
> --with-blas="-lptf77blas -lpthread -latlas"
> --with-blas="-lgotocblas -lgotoblas -lpthread"
>
> Not sure if my options are correct or not.
>
> Thank you for your and comment or advice in advance.
>
>
> Thanks,
> Jong
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901




More information about the R-help mailing list