[R] on parallel processing...

akshay kulkarni @k@h@y_e4 @end|ng |rom hotm@||@com
Fri Nov 4 20:35:11 CET 2022


Dear members,
                              I want to send the same function with different arguments to different processors. This solution was provided in Stack Overflow https://stackoverflow.com/questions/25045998/send-function-calls-with-different-arguments-to-different-processors-in-r-using
[https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon@2.png?v=73d79a89bded]<https://stackoverflow.com/questions/25045998/send-function-calls-with-different-arguments-to-different-processors-in-r-using>
Send function calls with different arguments to different processors in R using parallel package - Stack Overflow<https://stackoverflow.com/questions/25045998/send-function-calls-with-different-arguments-to-different-processors-in-r-using>
Teams. Q&A for work. Connect and share knowledge within a single location that is structured and easy to search. Learn more about Teams
stackoverflow.com
I have a 48 core processor. My question is, how do i loop through the cores without explicitly mentioning the core numbers?
Will this work?



library(parallel)
cl <- makeCluster(4)
clusterExport(cl, "foo")
cores <- seq_along(cl)
r <- clusterApply(cl[cores], cores, function(core) {

  for(i in 1:48) {

      if (core ==i) {

        foo( x[i] )

}
}
})

Many thanks in advance......

Thanking you,
Your sincerely,
AKSHAY M KULKARNI

	[[alternative HTML version deleted]]



More information about the R-help mailing list