Hello again R HPC People:

I'm trying items with mpi.remote.exec, but to no avail.  Every slave gets the same simulated values!

Here are the functions:

[hodgess@grid bin]$ cat chowsim.R
chow1 <- function() {
	x1 <- arima.sim(list(order=c(1,0,0),ar=phi1),360)
	y1 <- arima.sim(list(order=c(1,0,0),ar=phi1),360)
	x <- x1
	y <- y1
	nm <- length(x)
	n <- nm/m
	xq <- yq <- matrix(0,nrow=n,ncol=1)
	c1 <- (1/m)*cdgen(n,m)
	xq <- c1 %*% x
	yq <- c1 %*% y
	vv <- c1 %*% t(c1)
	vvi <- solve(vv)
	xvx <- t(xq) %*% vvi %*% xq
	xvxi <- solve(xvx)
	beta <- xvxi %*% t(xq) %*% vvi %*% yq
	res1 <- yq - xq %*% beta
	cv1 <- t(c1) %*% vvi
	newy <- x %*% beta + cv1%*%res1
	w <- sum((x-newy)^2)/360
	return(w)
}




cdgen <- function(n,m) {
	x <- rep(1,m)
	nm <- n*m
	cd <- matrix(0,nrow=n,ncol=nm)
	xg <- seq(from=1,by=m,length=n)
	xh <- seq(from=m,by=m,length=n)
	for(i in 1:n) {
		cd[i,xg[i]:xh[i]] <- x
	}
	return(cd)
}


chowsim <- function(n1=10,phi1=0.5) {
library("Rmpi")

# Notice we just say "give us all the slaves you've got."
mpi.spawn.Rslaves(nslaves=5)

if (mpi.comm.size() < 2) {
    print("More slave processes are required.")
    mpi.quit()
    }

.Last <- function(){
    if (is.loaded("mpi_initialize")){
        if (mpi.comm.size(1) > 0){
            print("Please use mpi.close.Rslaves() to close slaves.")
            mpi.close.Rslaves()
        }
        print("Please use mpi.quit() to quit R")
        .Call("mpi_finalize")
    }
}


	w <- NULL
	m <- 3
	for(ii in 1:n1) {
	mpi.bcast.Robj2slave(phi1)
	mpi.bcast.Robj2slave(m)
	mpi.bcast.Robj2slave(chow1)
	mpi.bcast.Robj2slave(cdgen)
	mpi.bcast.cmd(chow1)
	newone <- mpi.remote.exec(chow1())
	cat(ii,unlist(newone),"\n")
#	newone <- chow1(x=x1,y=y1,m=3)
	w <- c(w,unlist(newone))
	}
	cat(str(w),"\n")
	zzz <- list(mean=mean(w),sd=sd(w)/sqrt(360))
	return(zzz)
}

Is there something obvious that I'm missing (probably), please?

Any suggestions would be much appreciated.

Thanks,
Erin



Erin M. Hodgess, PhD
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: hodgesse@uhd.edu


	[[alternative HTML version deleted]]

