rmultithreadingparallel-processingmultiprocessingmclapply

mclapply() using only 2 cores on 32 core system


I'm trying to speed up computation times associated with the raup-crick dissimilarity as calculated by Chase et al. 2011. In order to accomplish this, I am attempting to utilize parallel computing on a 32 core ubuntu based-machine which is running Rstudio server.

This is the code that I am using to try to run the computation in parallel. Rstudio is using two cores to process the computation (determined via htop) suggesting I have achieved some level of parallel computation. However, I would like Rstudio to use more cores as it has up to 32 at its disposal.

f <- function(i) {
rc.shedding.otu <- raup_crick(df.shedding.otu, classic_metric = TRUE, plot_names_in_col1 = FALSE, reps = 999)
}

mclapply(1:100, f)

The application of mclapply() for parallel computing is relatively new to me. However, I was hoping that others more experienced in this field would be able to determine if this the result of an error in my code or a limitation based on the function that I am trying to perform. Any insight or advice is greatly appreciated!


Solution

  • As user12728748 suggested, the fix for this issue was issuing a value for the argument mc.cores = #L