[R] revolution foreach oddity
pdb
philb at philbrierley.com
Tue May 8 03:18:44 CEST 2012
I know this is not a revolution support forum, but as anyone noticed the
following?
I have a foreach loop to generate random samples. If I run the exact code
below in normal r (2.14.1) it works as expected, but if I run it from
revolution 4.2.0 each loop returns the same numbers.
The only way I can get revolution to give different numbers is using 1
instead of 8 in
registerDoSNOW(makeCluster(8, type = "SOCK"))
but that seems to defeat the point.
library(foreach)
library(doSNOW)
registerDoSNOW(makeCluster(8, type = "SOCK"))
getDoParWorkers()
getDoParName()
getDoParVersion()
mySamples <- foreach (jj = 1:4, .combine=cbind) %dopar% {
return(sample(1:10,10,replace=TRUE))
}
mySamples
##########
r 2.14.1
##########
> library(foreach)
> library(doSNOW)
> registerDoSNOW(makeCluster(8, type = "SOCK"))
> getDoParWorkers()
[1] 8
> getDoParName()
[1] "doSNOW"
> getDoParVersion()
[1] "1.0.6"
>
>
> mySamples <- foreach (jj = 1:4, .combine=cbind) %dopar% {
+ return(sample(1:10,10,replace=TRUE))
+ }
>
> mySamples
result.1 result.2 result.3 result.4
[1,] 5 3 1 4
[2,] 1 10 10 3
[3,] 7 9 4 9
[4,] 2 5 9 3
[5,] 2 7 10 1
[6,] 7 8 10 10
[7,] 6 9 10 4
[8,] 8 6 6 2
[9,] 10 7 9 4
[10,] 2 4 1 9
>
####################
# revolution r
####################
> library(foreach)
Loading required package: iterators
Loading required package: codetools
foreach: simple, scalable parallel programming from REvolution Computing
Use REvolution R for scalability, fault tolerance and more.
http://www.revolution-computing.com
> library(doSNOW)
Loading required package: snow
> registerDoSNOW(makeCluster(8, type = "SOCK"))
> getDoParWorkers()
[1] 8
> getDoParName()
[1] "doSNOW"
> getDoParVersion()
[1] "1.0.3"
>
>
> mySamples <- foreach (jj = 1:4, .combine=cbind) %dopar% {
+ return(sample(1:10,10,replace=TRUE))
+ }
>
> mySamples
result.1 result.2 result.3 result.4
[1,] 4 4 4 4
[2,] 10 10 10 10
[3,] 4 4 4 4
[4,] 10 10 10 10
[5,] 5 5 5 5
[6,] 5 5 5 5
[7,] 9 9 9 9
[8,] 2 2 2 2
[9,] 6 6 6 6
[10,] 9 9 9 9
>
--
View this message in context: http://r.789695.n4.nabble.com/revolution-foreach-oddity-tp4616237.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list