[R] Parallel code runs slower!

jim holtman jholtman at gmail.com
Wed Nov 10 15:20:20 CET 2010


Can you provide a little more information.  What operating system are
you using?  Have you monitored the CPU and memory utilizations of the
processes?  Do you have enough physical memory; e.g., are you paging?
How big are the matrices that you are processing; e.g., str(tTA) and
object.size(tTA).  This is the type of information that would be
required to make an informed guess at what is happening.

On Wed, Nov 10, 2010 at 9:07 AM, Santosh Srinivas
<santosh.srinivas at gmail.com> wrote:
> My parallel code is running slower than my non-parallel code! Can someone
> pls advise what am I doing wrong here?
>
> t and tTA are simple matrices of equal dimensions.
>
> #NON PARALLEL CODE
>
> nCols=ncol(t)
> nRows=nrow(t)
> tTA = matrix(nrow=nRows,ncol=nCols)
>
> require(TTR)
> system.time(
> for (i in 1:nCols) {
>        x = t[,i]
>        xROC = ROC(x)
>        tTA[,i]=xROC
>
>        }
> )
>
>   user  system elapsed
>  123.24    0.07  123.47
>
>
> # PARALLEL CODE
>
> nCols=ncol(t)
> nRows=nrow(t)
> tTA = matrix(nrow=nRows,ncol=nCols)
>
> require(doSMP)
> workers <- startWorkers(4) # My computer has 4 cores
> registerDoSMP(workers)
> system.time(
> foreach (i=1:nCols) %dopar%{
>        x = t[,i]
>        xROC = ROC(x)
>        tTA[,i]=xROC
>
>        }
> )
>
> # stop workers
> stopWorkers(workers)
>
> It is taking ages!
>
> Thanks,
> S
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list