r - do I still need to makeCluster if I'm already doing registerDoParallel(cl) -
reading vignette doparallel.
are following 2 code blocks 1 , same?
library(doparallel) no_cores <- 8 cl <- makecluster(no_cores) registerdoparallel(cl) pieces <- foreach(i = seq_len(length(pieces))) %dopar% { # stuff}
is above same this:
library(doparallel) registerdoparallel(cores = 8) pieces <- foreach(i = seq_len(length(pieces))) %dopar% { # stuff}
must makecluster()
when using doparallel if want use multiple cores? or single line enough registerdoparallel(cores = 8)
on windows machine, these 2 examples equivalent. difference first example uses explicit cluster object , second uses implicit cluster object created when execute registerdoparallel
. performance of 2 examples should same.
on mac or linux machine, first example uses snow
derived backend (exactly same on windows machine), using clusterapplylb
perform parallel computations. second example uses multicore
derived backend (which never available on windows), using mclapply
perform parallel computations more efficient first example.
Comments
Post a Comment