[R-sig-hpc] Question about output the objects on slave by SNOW
Stephen Weston
stephen.b.weston at gmail.com
Fri Mar 16 17:45:42 CET 2012
'cat' and 'print' work from the workers, but the
output is redirected to /dev/null (or NUL:) by
default. If you set the 'outfile' option to an
empty string when creating the cluster object,
then output won't be redirected in the workers,
and will generally be displayed in your session.
For example:
> f <- function(iter,x) {
+ y <- sin(x)
+ cat('x=', x,'\n')
+ return(y)
+ }
> library(snow)
> cl <- makeSOCKcluster(2, outfile="")
starting worker for localhost:10187
starting worker for localhost:10187
> clusterExport(cl, ls())
Type: EXEC
Type: EXEC
Type: EXEC
Type: EXEC
>
> parSapply(cl,1:2,f,1)
Type: EXEC
x= 1
Type: EXEC
x= 1
[1] 0.841471 0.841471
The output can be a bit jumbled, and it includes
other output generated by the workers, but I find it
very useful for debugging.
- Steve
On Fri, Mar 16, 2012 at 12:23 PM, Libo Sun <libosun at rams.colostate.edu> wrote:
> Hi all,
>
> I am using SNOW package on my multi-core Windows machine. I am wondering if
> there is a way to output the objects on slave, as far as I know 'cat' or
> 'print' doesn't work. One simple example:
>
>> f<-function(iter,x) {
> + y=sin(x)
> + cat('x=', x,'\n')
> + return(y)
> + }
>>
>> library(snow)
>> cl<-makeCluster(2)
>> clusterExport(cl,ls())
>>
>> parSapply(cl,1:2,f,1)
> [1] 0.841471 0.841471
>>
>
> I would like to get the information about 'x', like this,
>
>> sapply(1:2,f,1)
> x= 1
> x= 1
> [1] 0.841471 0.841471
>>
>
> Thanks,
> Libo
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-hpc mailing list
> R-sig-hpc at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-hpc
More information about the R-sig-hpc
mailing list