Queue of tasks for parallel computing in R -


the outline of want follows:

#function run 6k times, doesn't return somefunction <- function(integer,string) {...} #parameters passed params <- data.frame(ints=1:6000, strings=...) #number of cores system has numcores <- detectcores()  count <- 1; #run while there still tasks run , there free core while(count <= 6000 && <# of running tasks < numcores>) {    count <- count + 1;    <assign somefunction(params$ints[count],params$strings[count]) free core> } 

the 2 pieces of code in <> brackets not sure how proceed. on ubuntu system, can use multicore package.

i suspect may need integer keep track of how many cores being used , when process finishes, subtracts 1 integer , new process adds one, or maybe array of length numcores keep 0 or 1 if it's being used or not.

you should use either multicore or snow packages. snow, can accomplish after pretty simply:

clust<-makecluster(detectcores()) clusterexport(clust,"somefunction") ## added on edit, see comment steve weston clustfun<-function(i,params){somefunction(params$ints[i],params$strings[i])} clusterapply(clust,1:6000,clustfun,params) 

this evaluate calls in parallel , assign results list of length 6000. can use clusterapplylb performs load-balancing similar describing.

http://cran.r-project.org/web/packages/snow/index.html


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -