Skip to content

on parallel processing...

3 messages · Jeff Newmiller, akshay kulkarni

#
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 at 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
#
You don't specify processors. Just invoke the worker functions with the relevant packages and they will be allocated according to how you defined the cluster object... typically automatically. Processors are usually specified (to the cluster object) according to IP address. Cores within the processors are allocated according to how many processes are created.

Maybe you should read some documentation (vignettes), and/or look into R-sig-hpc (https://stat.ethz.ch/mailman/listinfo/r-sig-hpc). This is probably not the best place to pursue this.
On November 4, 2022 12:35:11 PM PDT, akshay kulkarni <akshay_e4 at hotmail.com> wrote:

  
    
#
dear Jeff,
                 Yeah, you are right.....just went through the documentation and found out that clusterApplyLB() from parallel package does the job... Thanks again....

THanking you,
Yours sincerely
AKSHAY M KULKARNI