I\'m running R on linux box that has 8 multicore processors, and have an optimization problem I\'d like to speed up by parallelizing the optimization routine itself. Importantly
I used the package doSNOW to run a code on 8 cores. I can just copy&paste the part of the code that refers to this package. Hope it helps!
# use multicore libraries
# specify number of cores to use
cores<- 8
cluster <- makeCluster(cores, type="SOCK")
registerDoSNOW(cluster)
# check how many cores will be used
ncores <- getDoParWorkers()
print(paste("Computing algorithm for ", cores, " cores", sep=""))
fph <- rep(-100,12)
# start multicore cicle on 12 subsets
fph <- foreach(i=1:12, .combine='c') %dopar% {
PhenoRiceRun(sub=i, mpath=MODIS_LOCAL_DIR, masklocaldir=MASK_LOCAL_DIR, startYear=startYear, tile=tile, evismoothopt=FALSE)
}
stopCluster(cluster) # check if gives error
gc(verbose=FALSE)