[R-sig-hpc] multicore performance question

Mauricio Zambrano-Bigiarini mauricio.zambrano at jrc.ec.europa.eu
Mon Jul 9 12:18:31 CEST 2012


I apologise. In my previous e-mail I did not write the time spent in 
each function:

# No multicore
nr <- 500 ; X <- matrix(rnorm(1000), ncol=30, nrow=nr)
set.seed(100)
system.time(
    unlist(lapply(1:nr, FUN=fn1, x=X))
)
#   user  system elapsed
#  0.013   0.000   0.013

# multicore
nr <- 500 ; X <- matrix(rnorm(1000), ncol=30, nrow=nr)
set.seed(100)
system.time(
   unlist(mclapply(1:nr, FUN=fn1, x=X, mc.cores=6))
)
#   user  system elapsed
#  0.030   0.380   0.125

Running on RHEL6 (64) with 8 cores.

Thanks in advance,

Mauricio

-- 
====================================================
Water Resources Unit
Institute for Environment and Sustainability (IES)
Joint Research Centre (JRC), European Commission
webinfo    : http://floods.jrc.ec.europa.eu/
====================================================
DISCLAIMER:
"The views expressed are purely those of the writer
and may not in any circumstances be regarded as sta-
ting an official position of the European Commission"
====================================================
Linux user #454569 -- Ubuntu user #17469
====================================================
"If you torture any data set long enough,
it will confess anything!" (Murray Lark)

On 09/07/12 10:49, Mauricio Zambrano-Bigiarini wrote:
> Dear list,
>
> I need to evaluate a vectorial function (~30 dimensions), and I would
> like to know if it is possible to take advantage of a multicore machine.
>
> So far, I'm using the multicore package, and I'm not getting any time
> saving. I guess the larger the computation time the larger the gain in
> performance, and probably that is the reason why I'm not speeding up my
> computations by using multicore.
>
> However, I would like to ask you if the reason for not getting any time
> saving by using 'multicore' is the short time of my computations OR the
> way in which I defined the function to be run (fn and fn1):
>
> ----------- START --------------
> library(multicore)
>
> fn <- function(x) {
> n <- length(x)
> return(1 + (1/4000) * sum(x^2) - prod(cos(x/sqrt(seq(1:n)))))
> }
>
> fn1 <- function(i, x) fn(x[i,])
>
> nr <- 500
> X <- matrix(rnorm(1000), ncol=30, nrow=nr)
>
> # No multicore
> set.seed(100)
> system.time(
> unlist(lapply(1:nr, FUN=fn1, x=X))
> )
>
> # multicore
> set.seed(100)
> system.time(
> unlist(mclapply(1:nr, FUN=fn1, x=X, mc.cores=6))
> )
>
> sessionInfo()
> R version 2.15.0 (2012-03-30)
> Platform: x86_64-redhat-linux-gnu (64-bit)
>
> locale:
> [1] LC_CTYPE=en_GB.utf8 LC_NUMERIC=C
> [3] LC_TIME=en_GB.utf8 LC_COLLATE=en_GB.utf8
> [5] LC_MONETARY=en_GB.utf8 LC_MESSAGES=en_GB.utf8
> [7] LC_PAPER=C LC_NAME=C
> [9] LC_ADDRESS=C LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_GB.utf8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] multicore_0.1-7 hydroPSO_0.1-57 hydroTSM_0.3-5-2 xts_0.8-6
> [5] zoo_1.7-7 sp_0.9-99
>
> loaded via a namespace (and not attached):
> [1] automap_1.0-12 class_7.3-4 cluster_1.14.2 e1071_1.6 grid_2.15.0
> [6] gstat_1.0-12 Hmisc_3.9-3 lattice_0.20-6 tools_2.15.0
>
> ----------- END --------------
>
>
> any comment will be very much appreciated.
>
>
> Thanks in advance,
>
>
> Mauricio Zambrano-Bigiarini
>



More information about the R-sig-hpc mailing list