[R-sig-hpc] request help with replication and snowFT

Hana Sevcikova hanas at uw.edu
Tue Jul 26 18:09:50 CEST 2011


Paul,
> And then explain how a user can grab any one arbitrary stream and
> re-run it for interactive investigation of its properties.  When we
> run this thing 1000 times and 2 are really off the usual result, we
> want to dig in and try to see what happened.
I know this is not exactly what you have in mind but one way to explore 
the individual streams is to set the number of nodes to 0 (in your 
example cnt=0) in which case the process runs sequentially using the 
same random numbers as in parallel case. Thus, you can use any R 
debugger to see what's going on with your streams.

Hana


> Here's my test case:
>
> ### r: number of streams. Should be set as BIGGEST number of runs=streams
> ### you could ever want to replicate.  It sets a framework of streams
> ### that is the same on all nodes.  Here I have 33 streams, only 10 nodes.
> ### snowFT handles the problem of creating 33 separate streams, so there
> ### is one ready for each possible run, no matter which node is doing
> ### the work.
> r<- 33
> ### cnt: number of nodes
> cnt<- 10
>
> cl<- makeClusterFT(cnt, type="MPI")
>
> ### From snowFT methods:
> printClusterInfo(cl)
>
> ### Can use SNOW methods as well.
> ### Testing with SNOW methods: sends function to each system
> clusterCall( cl, function() Sys.info()[c("nodename","machine")])
>
> ### Some user-written functions involved in a simulation
> myA<- function( x ){
>    2 *x
> }
>
> myB<- function( x ){
>    3 * x
> }
>
>
> myC<- function( x, y){
>    x + y
> }
>
> ## The main function of interest
> myNorm<- function (x){
>    whew<-  myA(x)
>    whewyou<- myB(whew)
>    whewwho<- myC(whew, whewyou)
>    y<- rnorm(whewwho)
>    list(x, whew, whewyou, whewwho, y, sum(y))
> }
>
>
> mySeeds<- c(1231, 2323, 43435, 12123, 22442, 634654)
> ##create "x" vector.
> myx<- sample(1:8, r, replace=T)
>
> ## Send functions to systems with SNOW functions
> clusterExport(cl, "myA")
> clusterExport(cl, "myB")
> clusterExport(cl, "myC")
>
> clusterSetupRNG.FT(cl, type = "RNGstream", streamper="replicate", n=r,
> seed=mySeeds)
> res1<- clusterApplyFT(cl, x=myx, fun=myNorm, seed=mySeeds)
>
> print(res1[[1]])
>
>
>
>



More information about the R-sig-hpc mailing list